Skip to content

Commit

Permalink
tetragon: Add uprobe multi bpf object
Browse files Browse the repository at this point in the history
Compile new bpf_multi_uprobe_v60.o object with __MULTI_KPROBE
defined. It will be used for uprobe multi sensor.

Signed-off-by: Jiri Olsa <[email protected]>
  • Loading branch information
olsajiri committed Dec 25, 2023
1 parent 7e96048 commit 29f9625
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
5 changes: 5 additions & 0 deletions bpf/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ PROCESS = bpf_execve_event.o bpf_execve_event_v53.o bpf_fork.o bpf_exit.o bpf_ge
bpf_generic_tracepoint_v61.o \
bpf_multi_kprobe_v61.o bpf_multi_retkprobe_v61.o \
bpf_generic_uprobe_v61.o \
bpf_multi_uprobe_v61.o \
bpf_loader.o \
bpf_killer.o bpf_multi_killer.o

Expand Down Expand Up @@ -94,6 +95,7 @@ deps/bpf_multi_kprobe_$$(VAR).d: process/bpf_generic_kprobe.c
deps/bpf_multi_retkprobe_$$(VAR).d: process/bpf_generic_retkprobe.c
deps/bpf_generic_tracepoint_$$(VAR).d: process/bpf_generic_tracepoint.c
deps/bpf_generic_uprobe_$$(VAR).d: process/bpf_generic_uprobe.c
deps/bpf_multi_uprobe_$$(VAR).d: process/bpf_generic_uprobe.c
endef

# Generic build targets for each sub-dir
Expand Down Expand Up @@ -133,6 +135,9 @@ $(DEPSDIR)%_v53.d:
objs/bpf_multi_kprobe_v61.ll objs/bpf_multi_retkprobe_v61.ll:
$(CLANG) $(CLANG_FLAGS) -D__LARGE_BPF_PROG -D__V61_BPF_PROG -D__MULTI_KPROBE -c $< -o $@

objs/bpf_multi_uprobe_v61.ll:
$(CLANG) $(CLANG_FLAGS) -D__LARGE_BPF_PROG -D__V60_BPF_PROG -D__MULTI_KPROBE -c $< -o $@

objs/%_v61.ll:
$(CLANG) $(CLANG_FLAGS) -D__LARGE_BPF_PROG -D__V61_BPF_PROG -c $< -o $@

Expand Down
10 changes: 8 additions & 2 deletions bpf/process/bpf_generic_uprobe.c
Original file line number Diff line number Diff line change
Expand Up @@ -79,11 +79,11 @@ generic_uprobe_start_process_filter(void *ctx)
#ifdef __CAP_CHANGES_FILTER
msg->sel.match_cap = 0;
#endif
msg->idx = get_index(ctx);
// setup index and function id
config = map_lookup_elem(&config_map, &msg->idx);
if (!config)
return 0;
msg->idx = 0;
msg->func_id = config->func_id;
msg->retprobe_id = 0;
if (!generic_process_filter_binary(config))
Expand All @@ -93,7 +93,13 @@ generic_uprobe_start_process_filter(void *ctx)
return 0;
}

__attribute__((section(("uprobe/generic_uprobe")), used)) int
#ifdef __MULTI_KPROBE
#define MAIN "uprobe.multi/generic_uprobe"
#else
#define MAIN "uprobe/generic_uprobe"
#endif

__attribute__((section((MAIN)), used)) int
generic_uprobe_event(struct pt_regs *ctx)
{
return generic_uprobe_start_process_filter(ctx);
Expand Down

0 comments on commit 29f9625

Please sign in to comment.