On 12/1/22 20:26, Hao Luo wrote:
On Tue, Nov 29, 2022 at 10:54 PM Viktor Malik <vmalik@xxxxxxxxxx> wrote:
When attaching fentry/fexit/fmod_ret/lsm to a function located in a
module without specifying the target program, the verifier tries to find
the address to attach to in kallsyms. This is always done by searching
the entire kallsyms, not respecting the module in which the function is
located.
This approach causes an incorrect attachment address to be computed if
the function to attach to is shadowed by a function of the same name
located earlier in kallsyms.
Since the attachment must contain the BTF of the program to attach to,
we may extract the module name from it (if the attach target is a
module) and search for the function address in the correct module.
Signed-off-by: Viktor Malik <vmalik@xxxxxxxxxx>
---
Looks like we need to define a trivial
kallsyms_lookup_name_in_module() in !CONFIG_MODULES. With that added,
this patch looks good to me.
Right, I missed that, thanks! I'll fix it and post v3 soon.
Acked-by: Hao Luo <haoluo@xxxxxxxxxx>