Skip to content

Commit da09a9e

Browse files
olsajiriPeter Zijlstra
authored andcommitted
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 <[email protected]> Signed-off-by: Peter Zijlstra (Intel) <[email protected]> Acked-by: Oleg Nesterov <[email protected]> Acked-by: Andrii Nakryiko <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent de20037 commit da09a9e

File tree

5 files changed

+17
-11
lines changed

5 files changed

+17
-11
lines changed

include/linux/uprobes.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,10 @@ struct uprobe_consumer {
3737
* for the current process. If filter() is omitted or returns true,
3838
* UPROBE_HANDLER_REMOVE is effectively ignored.
3939
*/
40-
int (*handler)(struct uprobe_consumer *self, struct pt_regs *regs);
40+
int (*handler)(struct uprobe_consumer *self, struct pt_regs *regs, __u64 *data);
4141
int (*ret_handler)(struct uprobe_consumer *self,
4242
unsigned long func,
43-
struct pt_regs *regs);
43+
struct pt_regs *regs, __u64 *data);
4444
bool (*filter)(struct uprobe_consumer *self, struct mm_struct *mm);
4545

4646
struct list_head cons_node;

kernel/events/uprobes.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2090,7 +2090,7 @@ static void handler_chain(struct uprobe *uprobe, struct pt_regs *regs)
20902090
int rc = 0;
20912091

20922092
if (uc->handler) {
2093-
rc = uc->handler(uc, regs);
2093+
rc = uc->handler(uc, regs, NULL);
20942094
WARN(rc & ~UPROBE_HANDLER_MASK,
20952095
"bad rc=0x%x from %ps()\n", rc, uc->handler);
20962096
}
@@ -2128,7 +2128,7 @@ handle_uretprobe_chain(struct return_instance *ri, struct pt_regs *regs)
21282128
rcu_read_lock_trace();
21292129
list_for_each_entry_rcu(uc, &uprobe->consumers, cons_node, rcu_read_lock_trace_held()) {
21302130
if (uc->ret_handler)
2131-
uc->ret_handler(uc, ri->func, regs);
2131+
uc->ret_handler(uc, ri->func, regs, NULL);
21322132
}
21332133
rcu_read_unlock_trace();
21342134
}

kernel/trace/bpf_trace.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3244,7 +3244,8 @@ uprobe_multi_link_filter(struct uprobe_consumer *con, struct mm_struct *mm)
32443244
}
32453245

32463246
static int
3247-
uprobe_multi_link_handler(struct uprobe_consumer *con, struct pt_regs *regs)
3247+
uprobe_multi_link_handler(struct uprobe_consumer *con, struct pt_regs *regs,
3248+
__u64 *data)
32483249
{
32493250
struct bpf_uprobe *uprobe;
32503251

@@ -3253,7 +3254,8 @@ uprobe_multi_link_handler(struct uprobe_consumer *con, struct pt_regs *regs)
32533254
}
32543255

32553256
static int
3256-
uprobe_multi_link_ret_handler(struct uprobe_consumer *con, unsigned long func, struct pt_regs *regs)
3257+
uprobe_multi_link_ret_handler(struct uprobe_consumer *con, unsigned long func, struct pt_regs *regs,
3258+
__u64 *data)
32573259
{
32583260
struct bpf_uprobe *uprobe;
32593261

kernel/trace/trace_uprobe.c

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -89,9 +89,11 @@ static struct trace_uprobe *to_trace_uprobe(struct dyn_event *ev)
8989
static int register_uprobe_event(struct trace_uprobe *tu);
9090
static int unregister_uprobe_event(struct trace_uprobe *tu);
9191

92-
static int uprobe_dispatcher(struct uprobe_consumer *con, struct pt_regs *regs);
92+
static int uprobe_dispatcher(struct uprobe_consumer *con, struct pt_regs *regs,
93+
__u64 *data);
9394
static int uretprobe_dispatcher(struct uprobe_consumer *con,
94-
unsigned long func, struct pt_regs *regs);
95+
unsigned long func, struct pt_regs *regs,
96+
__u64 *data);
9597

9698
#ifdef CONFIG_STACK_GROWSUP
9799
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,
15171519
}
15181520
}
15191521

1520-
static int uprobe_dispatcher(struct uprobe_consumer *con, struct pt_regs *regs)
1522+
static int uprobe_dispatcher(struct uprobe_consumer *con, struct pt_regs *regs,
1523+
__u64 *data)
15211524
{
15221525
struct trace_uprobe *tu;
15231526
struct uprobe_dispatch_data udd;
@@ -1548,7 +1551,8 @@ static int uprobe_dispatcher(struct uprobe_consumer *con, struct pt_regs *regs)
15481551
}
15491552

15501553
static int uretprobe_dispatcher(struct uprobe_consumer *con,
1551-
unsigned long func, struct pt_regs *regs)
1554+
unsigned long func, struct pt_regs *regs,
1555+
__u64 *data)
15521556
{
15531557
struct trace_uprobe *tu;
15541558
struct uprobe_dispatch_data udd;

tools/testing/selftests/bpf/bpf_testmod/bpf_testmod.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -461,7 +461,7 @@ static struct bin_attribute bin_attr_bpf_testmod_file __ro_after_init = {
461461

462462
static int
463463
uprobe_ret_handler(struct uprobe_consumer *self, unsigned long func,
464-
struct pt_regs *regs)
464+
struct pt_regs *regs, __u64 *data)
465465

466466
{
467467
regs->ax = 0x12345678deadbeef;

0 commit comments

Comments
 (0)