• Dave Marchevsky's avatar
    bpf: Introduce opaque bpf_refcount struct and add btf_record plumbing · d54730b5
    Dave Marchevsky authored
    A 'struct bpf_refcount' is added to the set of opaque uapi/bpf.h types
    meant for use in BPF programs. Similarly to other opaque types like
    bpf_spin_lock and bpf_rbtree_node, the verifier needs to know where in
    user-defined struct types a bpf_refcount can be located, so necessary
    btf_record plumbing is added to enable this. bpf_refcount is sized to
    hold a refcount_t.
    
    Similarly to bpf_spin_lock, the offset of a bpf_refcount is cached in
    btf_record as refcount_off in addition to being in the field array.
    Caching refcount_off makes sense for this field because further patches
    in the series will modify functions that take local kptrs (e.g.
    bpf_obj_drop) to change their behavior if the type they're operating on
    is refcounted. So enabling fast "is this type refcounted?" checks is
    desirable.
    
    No such verifier behavior changes are introduced in this patch, just
    logic to recognize 'struct bpf_refcount' in btf_record.
    Signed-off-by: default avatarDave Marchevsky <davemarchevsky@fb.com>
    Link: https://lore.kernel.org/r/20230415201811.343116-3-davemarchevsky@fb.comSigned-off-by: default avatarAlexei Starovoitov <ast@kernel.org>
    d54730b5
syscall.c 130 KB