Skip to content

Commit 4f7caaa

Browse files
mhiramatrostedt
authored andcommitted
bpf: Use ftrace_get_symaddr() for kprobe_multi probes
Add ftrace_get_entry_ip() which is only for ftrace based probes, and use it for kprobe multi probes because they are based on fprobe which uses ftrace instead of kprobes. Cc: Alexei Starovoitov <[email protected]> Cc: Florent Revest <[email protected]> Cc: Martin KaFai Lau <[email protected]> Cc: bpf <[email protected]> Cc: Alexei Starovoitov <[email protected]> Cc: Jiri Olsa <[email protected]> Cc: Alan Maguire <[email protected]> Cc: Mark Rutland <[email protected]> Link: https://lore.kernel.org/173566081414.878879.10631096557346094362.stgit@devnote2 Signed-off-by: Masami Hiramatsu (Google) <[email protected]> Signed-off-by: Steven Rostedt (Google) <[email protected]>
1 parent 2bc56fd commit 4f7caaa

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

kernel/trace/bpf_trace.c

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2591,6 +2591,13 @@ static DEFINE_PER_CPU(struct pt_regs, bpf_kprobe_multi_pt_regs);
25912591
#define bpf_kprobe_multi_pt_regs_ptr() (NULL)
25922592
#endif
25932593

2594+
static unsigned long ftrace_get_entry_ip(unsigned long fentry_ip)
2595+
{
2596+
unsigned long ip = ftrace_get_symaddr(fentry_ip);
2597+
2598+
return ip ? : fentry_ip;
2599+
}
2600+
25942601
static int copy_user_syms(struct user_syms *us, unsigned long __user *usyms, u32 cnt)
25952602
{
25962603
unsigned long __user usymbol;
@@ -2829,7 +2836,8 @@ kprobe_multi_link_handler(struct fprobe *fp, unsigned long fentry_ip,
28292836
int err;
28302837

28312838
link = container_of(fp, struct bpf_kprobe_multi_link, fp);
2832-
err = kprobe_multi_link_prog_run(link, get_entry_ip(fentry_ip), fregs, false, data);
2839+
err = kprobe_multi_link_prog_run(link, ftrace_get_entry_ip(fentry_ip),
2840+
fregs, false, data);
28332841
return is_kprobe_session(link->link.prog) ? err : 0;
28342842
}
28352843

@@ -2841,7 +2849,8 @@ kprobe_multi_link_exit_handler(struct fprobe *fp, unsigned long fentry_ip,
28412849
struct bpf_kprobe_multi_link *link;
28422850

28432851
link = container_of(fp, struct bpf_kprobe_multi_link, fp);
2844-
kprobe_multi_link_prog_run(link, get_entry_ip(fentry_ip), fregs, true, data);
2852+
kprobe_multi_link_prog_run(link, ftrace_get_entry_ip(fentry_ip),
2853+
fregs, true, data);
28452854
}
28462855

28472856
static int symbols_cmp_r(const void *a, const void *b, const void *priv)

0 commit comments

Comments
 (0)