Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bad kfunc argument handling for functions with multiple BTF entries #3140

Open
ajor opened this issue Apr 26, 2024 · 0 comments
Open

Bad kfunc argument handling for functions with multiple BTF entries #3140

ajor opened this issue Apr 26, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@ajor
Copy link
Member

ajor commented Apr 26, 2024

My kernel contains multiple BTF entries representing functions of the same name, for several different functions. This can be confirmed with sudo bpftool btf dump file /boot/vmlinux-xxx.

Some of these BTF entries appear to be duplicates of a single function, where the arguments are given different names in different source files:

# bpftrace -lv 'kfunc:bpf_arch_text_poke'
kfunc:vmlinux:bpf_arch_text_poke
    void * ip
    enum bpf_text_poke_type t
    void * old_addr
    void * new_addr
    int retval
    void * ip
    enum bpf_text_poke_type t
    void * addr1
    void * addr2
    int retval

Others functions actually have multiple entries in kallsyms and versions with different numbers of arguments:

# bpftrace -lv 'kfunc:check_version'
kfunc:vmlinux:check_version
    unsigned int cmd
    struct dm_ioctl __attribute__((btf_type_tag("user"))) * user
    int retval
    const struct load_info * info
    const char * symname
    struct module * mod
    const s32 * crc
    int retval

There can be more than two BTF entries for a given function:

# bpftrace -lv 'kfunc:s_next'
kfunc:vmlinux:s_next
    struct seq_file * m
    void * v
    loff_t * pos
    void * retval
    struct seq_file * f
    void * data
    loff_t * pos
    void * retval
    struct seq_file * m
    void * p
    loff_t * pos
    void * retval

A sample of some others on my kernel (there are many more):

kfunc:vmlinux:c_next
kfunc:vmlinux:cgroup_storage_lookup
kfunc:vmlinux:check_extent_item
kfunc:vmlinux:cookie_hash
kfunc:vmlinux:s_show
kfunc:vmlinux:type_show
kfunc:vmlinux:user_read
kfunc:vmlinux:version_show
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant