uprobe: Add data pointer to consumer handlers

Adding data pointer to both entry and exit consumer handlers and all
its users. The functionality itself is coming in following change.

Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Acked-by: Oleg Nesterov <oleg@redhat.com>
Acked-by: Andrii Nakryiko <andrii@kernel.org>
Link: https://lore.kernel.org/r/20241018202252.693462-2-jolsa@kernel.org
This commit is contained in:
Jiri Olsa 2024-10-18 22:22:51 +02:00 committed by Peter Zijlstra
parent de20037e1b
commit da09a9e0c3
5 changed files with 17 additions and 11 deletions

View File

@ -37,10 +37,10 @@ struct uprobe_consumer {
* for the current process. If filter() is omitted or returns true, * for the current process. If filter() is omitted or returns true,
* UPROBE_HANDLER_REMOVE is effectively ignored. * UPROBE_HANDLER_REMOVE is effectively ignored.
*/ */
int (*handler)(struct uprobe_consumer *self, struct pt_regs *regs); int (*handler)(struct uprobe_consumer *self, struct pt_regs *regs, __u64 *data);
int (*ret_handler)(struct uprobe_consumer *self, int (*ret_handler)(struct uprobe_consumer *self,
unsigned long func, unsigned long func,
struct pt_regs *regs); struct pt_regs *regs, __u64 *data);
bool (*filter)(struct uprobe_consumer *self, struct mm_struct *mm); bool (*filter)(struct uprobe_consumer *self, struct mm_struct *mm);
struct list_head cons_node; struct list_head cons_node;

View File

@ -2090,7 +2090,7 @@ static void handler_chain(struct uprobe *uprobe, struct pt_regs *regs)
int rc = 0; int rc = 0;
if (uc->handler) { if (uc->handler) {
rc = uc->handler(uc, regs); rc = uc->handler(uc, regs, NULL);
WARN(rc & ~UPROBE_HANDLER_MASK, WARN(rc & ~UPROBE_HANDLER_MASK,
"bad rc=0x%x from %ps()\n", rc, uc->handler); "bad rc=0x%x from %ps()\n", rc, uc->handler);
} }
@ -2128,7 +2128,7 @@ handle_uretprobe_chain(struct return_instance *ri, struct pt_regs *regs)
rcu_read_lock_trace(); rcu_read_lock_trace();
list_for_each_entry_rcu(uc, &uprobe->consumers, cons_node, rcu_read_lock_trace_held()) { list_for_each_entry_rcu(uc, &uprobe->consumers, cons_node, rcu_read_lock_trace_held()) {
if (uc->ret_handler) if (uc->ret_handler)
uc->ret_handler(uc, ri->func, regs); uc->ret_handler(uc, ri->func, regs, NULL);
} }
rcu_read_unlock_trace(); rcu_read_unlock_trace();
} }

View File

@ -3244,7 +3244,8 @@ uprobe_multi_link_filter(struct uprobe_consumer *con, struct mm_struct *mm)
} }
static int static int
uprobe_multi_link_handler(struct uprobe_consumer *con, struct pt_regs *regs) uprobe_multi_link_handler(struct uprobe_consumer *con, struct pt_regs *regs,
__u64 *data)
{ {
struct bpf_uprobe *uprobe; struct bpf_uprobe *uprobe;
@ -3253,7 +3254,8 @@ uprobe_multi_link_handler(struct uprobe_consumer *con, struct pt_regs *regs)
} }
static int static int
uprobe_multi_link_ret_handler(struct uprobe_consumer *con, unsigned long func, struct pt_regs *regs) uprobe_multi_link_ret_handler(struct uprobe_consumer *con, unsigned long func, struct pt_regs *regs,
__u64 *data)
{ {
struct bpf_uprobe *uprobe; struct bpf_uprobe *uprobe;

View File

@ -89,9 +89,11 @@ static struct trace_uprobe *to_trace_uprobe(struct dyn_event *ev)
static int register_uprobe_event(struct trace_uprobe *tu); static int register_uprobe_event(struct trace_uprobe *tu);
static int unregister_uprobe_event(struct trace_uprobe *tu); static int unregister_uprobe_event(struct trace_uprobe *tu);
static int uprobe_dispatcher(struct uprobe_consumer *con, struct pt_regs *regs); static int uprobe_dispatcher(struct uprobe_consumer *con, struct pt_regs *regs,
__u64 *data);
static int uretprobe_dispatcher(struct uprobe_consumer *con, static int uretprobe_dispatcher(struct uprobe_consumer *con,
unsigned long func, struct pt_regs *regs); unsigned long func, struct pt_regs *regs,
__u64 *data);
#ifdef CONFIG_STACK_GROWSUP #ifdef CONFIG_STACK_GROWSUP
static unsigned long adjust_stack_addr(unsigned long addr, unsigned int n) static unsigned long adjust_stack_addr(unsigned long addr, unsigned int n)
@ -1517,7 +1519,8 @@ trace_uprobe_register(struct trace_event_call *event, enum trace_reg type,
} }
} }
static int uprobe_dispatcher(struct uprobe_consumer *con, struct pt_regs *regs) static int uprobe_dispatcher(struct uprobe_consumer *con, struct pt_regs *regs,
__u64 *data)
{ {
struct trace_uprobe *tu; struct trace_uprobe *tu;
struct uprobe_dispatch_data udd; struct uprobe_dispatch_data udd;
@ -1548,7 +1551,8 @@ static int uprobe_dispatcher(struct uprobe_consumer *con, struct pt_regs *regs)
} }
static int uretprobe_dispatcher(struct uprobe_consumer *con, static int uretprobe_dispatcher(struct uprobe_consumer *con,
unsigned long func, struct pt_regs *regs) unsigned long func, struct pt_regs *regs,
__u64 *data)
{ {
struct trace_uprobe *tu; struct trace_uprobe *tu;
struct uprobe_dispatch_data udd; struct uprobe_dispatch_data udd;

View File

@ -461,7 +461,7 @@ static struct bin_attribute bin_attr_bpf_testmod_file __ro_after_init = {
static int static int
uprobe_ret_handler(struct uprobe_consumer *self, unsigned long func, uprobe_ret_handler(struct uprobe_consumer *self, unsigned long func,
struct pt_regs *regs) struct pt_regs *regs, __u64 *data)
{ {
regs->ax = 0x12345678deadbeef; regs->ax = 0x12345678deadbeef;