ftrace reads the code it patches with copy_from_kernel_nofault(). A program which makes it fail breaks the detach of fentry on x86: unregister_fentry() update_ftrace_direct_del() returns 0 ftrace_replace_code() ftrace_bug(), no text poke ftrace_verify_code() -EFAULT bpf_tramp_image_put() the function still calls the freed image On arm64 ftrace writes the code with aarch64_insn_patch_text_nosync(), which is traceable without KPROBES. The same holds for it. bpf_set_dentry_xattr_locked() and bpf_remove_dentry_xattr_locked() are kfuncs without the "bpf_kfunc" tag: specialize_kfunc() calls them instead of the kfuncs without _locked. Do not tag these four. Signed-off-by: Anton Protopopov --- tools/bpf/resolve_btfids/fmodret.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/tools/bpf/resolve_btfids/fmodret.c b/tools/bpf/resolve_btfids/fmodret.c index 7d26a5c9b028..5a392452471e 100644 --- a/tools/bpf/resolve_btfids/fmodret.c +++ b/tools/bpf/resolve_btfids/fmodret.c @@ -87,6 +87,22 @@ static bool has_bpf_types(const struct btf *btf, const struct btf_type *func) return false; } +static bool excluded_by_name(const char *name) +{ + static const char *const names[] = { + "copy_from_kernel_nofault", + "aarch64_insn_patch_text_nosync", + "bpf_remove_dentry_xattr_locked", + "bpf_set_dentry_xattr_locked", + }; + unsigned int i; + + for (i = 0; i < sizeof(names) / sizeof(names[0]); i++) + if (!strcmp(name, names[i])) + return true; + return false; +} + /* Find kfuncs and helpers */ static bool *find_bpf_funcs(const struct btf *btf) { @@ -290,6 +306,8 @@ int fmodret_tag(Elf *elf, struct btf *btf, int verbose) func = image_func(&img, name); if (!func || !strcmp(func->section, ".init.text")) continue; + if (excluded_by_name(name)) + continue; nr_scanned++; err = scan_func(scan, func, &values); if (err == -EINVAL) { -- 2.43.0