Message ID | 20210212021030.266932-1-kafai@fb.com (mailing list archive) |
---|---|
State | Accepted |
Commit | d2836dddc95d5dd82c7cb23726c97d8c9147f050 |
Delegated to: | BPF |
Headers | show |
Series | [v2,bpf,1/2] libbpf: Ignore non function pointer member in struct_ops | expand |
Context | Check | Description |
---|---|---|
netdev/cover_letter | success | Link |
netdev/fixes_present | success | Link |
netdev/patch_count | success | Link |
netdev/tree_selection | success | Clearly marked for bpf |
netdev/subject_prefix | success | Link |
netdev/cc_maintainers | warning | 4 maintainers not CCed: kpsingh@kernel.org john.fastabend@gmail.com yhs@fb.com songliubraving@fb.com |
netdev/source_inline | success | Was 0 now: 0 |
netdev/verify_signedoff | success | Link |
netdev/module_param | success | Was 0 now: 0 |
netdev/build_32bit | success | Errors and warnings before: 0 this patch: 0 |
netdev/kdoc | success | Errors and warnings before: 0 this patch: 0 |
netdev/verify_fixes | success | Link |
netdev/checkpatch | success | total: 0 errors, 0 warnings, 0 checks, 35 lines checked |
netdev/build_allmodconfig_warn | success | Errors and warnings before: 0 this patch: 0 |
netdev/header_inline | success | Link |
netdev/stable | success | Stable not CCed |
Hello: This series was applied to bpf/bpf-next.git (refs/heads/master): On Thu, 11 Feb 2021 18:10:30 -0800 you wrote: > When libbpf initializes the kernel's struct_ops in > "bpf_map__init_kern_struct_ops()", it enforces all > pointer types must be a function pointer and rejects > others. It turns out to be too strict. For example, > when directly using "struct tcp_congestion_ops" from vmlinux.h, > it has a "struct module *owner" member and it is set to NULL > in a bpf_tcp_cc.o. > > [...] Here is the summary with links: - [v2,bpf,1/2] libbpf: Ignore non function pointer member in struct_ops https://git.kernel.org/bpf/bpf-next/c/d2836dddc95d - [v2,bpf,2/2] bpf: selftests: Add non function pointer test to struct_ops https://git.kernel.org/bpf/bpf-next/c/a79e88dd2ca6 You are awesome, thank you! -- Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html
diff --git a/tools/lib/bpf/libbpf.c b/tools/lib/bpf/libbpf.c index 6ae748f6ea11..a0d4fc4de402 100644 --- a/tools/lib/bpf/libbpf.c +++ b/tools/lib/bpf/libbpf.c @@ -883,24 +883,24 @@ static int bpf_map__init_kern_struct_ops(struct bpf_map *map, if (btf_is_ptr(mtype)) { struct bpf_program *prog; - mtype = skip_mods_and_typedefs(btf, mtype->type, &mtype_id); + prog = st_ops->progs[i]; + if (!prog) + continue; + kern_mtype = skip_mods_and_typedefs(kern_btf, kern_mtype->type, &kern_mtype_id); - if (!btf_is_func_proto(mtype) || - !btf_is_func_proto(kern_mtype)) { - pr_warn("struct_ops init_kern %s: non func ptr %s is not supported\n", + + /* mtype->type must be a func_proto which was + * guaranteed in bpf_object__collect_st_ops_relos(), + * so only check kern_mtype for func_proto here. + */ + if (!btf_is_func_proto(kern_mtype)) { + pr_warn("struct_ops init_kern %s: kernel member %s is not a func ptr\n", map->name, mname); return -ENOTSUP; } - prog = st_ops->progs[i]; - if (!prog) { - pr_debug("struct_ops init_kern %s: func ptr %s is not set\n", - map->name, mname); - continue; - } - prog->attach_btf_id = kern_type_id; prog->expected_attach_type = kern_member_idx;