Skip to content

Commit f44a435

Browse files
authored
uprobe: fix uprobe trigger triggered from multiple tracee instances (#2230)
Fixes the issue that multiple tracee instances are all invoking the uprobe trigger events for each instance. Fixes: #2225
1 parent 9965fd9 commit f44a435

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

pkg/ebpf/c/tracee.bpf.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3689,6 +3689,7 @@ SEC("uprobe/trigger_syscall_event")
36893689
int uprobe_syscall_trigger(struct pt_regs *ctx)
36903690
{
36913691
u64 caller_ctx_id = 0;
3692+
u32 trigger_pid = bpf_get_current_pid_tgid() >> 32;
36923693

36933694
// clang-format off
36943695
//
@@ -3720,6 +3721,10 @@ int uprobe_syscall_trigger(struct pt_regs *ctx)
37203721
if (!init_event_data(&data, ctx))
37213722
return 0;
37223723

3724+
// uprobe was triggered from other tracee instance
3725+
if (data.config->tracee_pid != trigger_pid)
3726+
return 0;
3727+
37233728
int key = 0;
37243729
// TODO: https://github.com/aquasecurity/tracee/issues/2055
37253730
if (bpf_map_lookup_elem(&syscalls_to_check_map, (void *) &key) == NULL)
@@ -3761,6 +3766,7 @@ int uprobe_seq_ops_trigger(struct pt_regs *ctx)
37613766
u64 caller_ctx_id = 0;
37623767
u64 *address_array = NULL;
37633768
u64 struct_address;
3769+
u32 trigger_pid = bpf_get_current_pid_tgid() >> 32;
37643770

37653771
// clang-format off
37663772
//
@@ -3795,6 +3801,10 @@ int uprobe_seq_ops_trigger(struct pt_regs *ctx)
37953801
if (!init_event_data(&data, ctx))
37963802
return 0;
37973803

3804+
// uprobe was triggered from other tracee instance
3805+
if (data.config->tracee_pid != trigger_pid)
3806+
return 0;
3807+
37983808
u32 count_off = data.buf_off + 1;
37993809
save_u64_arr_to_buf(&data, NULL, 0, 0); // init u64 array with size 0
38003810

0 commit comments

Comments
 (0)