在 2025/5/1 06:23, Alexei Starovoitov 写道:
On Wed, Apr 30, 2025 at 10:57 AM Alan Maguire <alan.maguire@xxxxxxxxxx> wrote:
+
+ if (!addr && (prog->expected_attach_type == BPF_TRACE_FENTRY ||
+ prog->expected_attach_type == BPF_TRACE_FEXIT)) {
+ fname = kallsyms_lookup((unsigned long)prog->aux->fentry_func,
+ NULL, NULL, NULL, trace_symbol);
+ if (fname)
+ addr = (long)prog->aux->fentry_func;
We should do some validation that the fname we get back matches the BTF
func name prefix (fname "foo.isra.0" matches "foo") I think?
I don't think that will be enough.
User space should not be able to pass a random kernel address
and convince the kernel that it matches a particular btf_id.
As discussed in the other thread matching based on name is
breaking apart.
pahole does all the safety check to make sure name/addr/btf_id
are consistent.
We shouldn't be adding workarounds like this because
pahole/btf/kernel build is not smart enough.
Got it thanks for your reply, it is hoped that pahole/btf can have a
better way to solve such problems.
pw-bot: cr
--
Best Regards
Tao Chen