Skip to content
  • Andrii Nakryiko's avatar
    5a30eb23
    selftests/bpf: Fix field existence CO-RE reloc tests · 5a30eb23
    Andrii Nakryiko authored
    
    
    Negative field existence cases for have a broken assumption that FIELD_EXISTS
    CO-RE relo will fail for fields that match the name but have incompatible type
    signature. That's not how CO-RE relocations generally behave. Types and fields
    that match by name but not by expected type are treated as non-matching
    candidates and are skipped. Error later is reported if no matching candidate
    was found. That's what happens for most relocations, but existence relocations
    (FIELD_EXISTS and TYPE_EXISTS) are more permissive and they are designed to
    return 0 or 1, depending if a match is found. This allows to handle
    name-conflicting but incompatible types in BPF code easily. Combined with
    ___flavor suffixes, it's possible to handle pretty much any structural type
    changes in kernel within the compiled once BPF source code.
    
    So, long story short, negative field existence test cases are invalid in their
    assumptions, so this patch reworks them into a single consolidated positive
    case that doesn't match any of the fields.
    
    Fixes: c7566a69 ("selftests/bpf: Add field existence CO-RE relocs tests")
    Reported-by: default avatarLorenz Bauer <lmb@cloudflare.com>
    Signed-off-by: default avatarAndrii Nakryiko <andrii@kernel.org>
    Signed-off-by: default avatarAlexei Starovoitov <ast@kernel.org>
    Acked-by: default avatarLorenz Bauer <lmb@cloudflare.com>
    Link: https://lore.kernel.org/bpf/20210426192949.416837-5-andrii@kernel.org
    5a30eb23
    selftests/bpf: Fix field existence CO-RE reloc tests
    Andrii Nakryiko authored
    
    
    Negative field existence cases for have a broken assumption that FIELD_EXISTS
    CO-RE relo will fail for fields that match the name but have incompatible type
    signature. That's not how CO-RE relocations generally behave. Types and fields
    that match by name but not by expected type are treated as non-matching
    candidates and are skipped. Error later is reported if no matching candidate
    was found. That's what happens for most relocations, but existence relocations
    (FIELD_EXISTS and TYPE_EXISTS) are more permissive and they are designed to
    return 0 or 1, depending if a match is found. This allows to handle
    name-conflicting but incompatible types in BPF code easily. Combined with
    ___flavor suffixes, it's possible to handle pretty much any structural type
    changes in kernel within the compiled once BPF source code.
    
    So, long story short, negative field existence test cases are invalid in their
    assumptions, so this patch reworks them into a single consolidated positive
    case that doesn't match any of the fields.
    
    Fixes: c7566a69 ("selftests/bpf: Add field existence CO-RE relocs tests")
    Reported-by: default avatarLorenz Bauer <lmb@cloudflare.com>
    Signed-off-by: default avatarAndrii Nakryiko <andrii@kernel.org>
    Signed-off-by: default avatarAlexei Starovoitov <ast@kernel.org>
    Acked-by: default avatarLorenz Bauer <lmb@cloudflare.com>
    Link: https://lore.kernel.org/bpf/20210426192949.416837-5-andrii@kernel.org
Loading