From d78efe7518faca308f0945674fb0ed282e69ad45 Mon Sep 17 00:00:00 2001 From: Jiri Olsa Date: Thu, 19 Dec 2024 23:05:49 +0000 Subject: [PATCH] tetragon: Switch generic_start_process_filter to use maps directly Signed-off-by: Jiri Olsa --- bpf/process/bpf_generic_kprobe.c | 10 +--------- bpf/process/bpf_generic_lsm_core.c | 10 +--------- bpf/process/bpf_generic_uprobe.c | 9 +-------- bpf/process/generic_calls.h | 4 ++-- bpf/process/types/basic.h | 8 -------- 5 files changed, 5 insertions(+), 36 deletions(-) diff --git a/bpf/process/bpf_generic_kprobe.c b/bpf/process/bpf_generic_kprobe.c index 28d44de3f45..d93695f3c76 100644 --- a/bpf/process/bpf_generic_kprobe.c +++ b/bpf/process/bpf_generic_kprobe.c @@ -43,14 +43,6 @@ struct { #include "generic_maps.h" #include "generic_calls.h" -static struct generic_maps maps = { - .heap = (struct bpf_map_def *)&process_call_heap, - .calls = (struct bpf_map_def *)&kprobe_calls, - .config = (struct bpf_map_def *)&config_map, - .filter = (struct bpf_map_def *)&filter_map, - .override = (struct bpf_map_def *)&override_tasks, -}; - #ifdef __MULTI_KPROBE #define MAIN "kprobe.multi/generic_kprobe" #define OVERRIDE "kprobe.multi/generic_kprobe_override" @@ -85,7 +77,7 @@ static struct generic_maps maps = { __attribute__((section((MAIN)), used)) int generic_kprobe_event(struct pt_regs *ctx) { - return generic_start_process_filter(ctx, &maps); + return generic_start_process_filter(ctx, (struct bpf_map_def *)&kprobe_calls); } __attribute__((section("kprobe"), used)) int diff --git a/bpf/process/bpf_generic_lsm_core.c b/bpf/process/bpf_generic_lsm_core.c index 775c650e059..08c2dc36e78 100644 --- a/bpf/process/bpf_generic_lsm_core.c +++ b/bpf/process/bpf_generic_lsm_core.c @@ -42,20 +42,12 @@ struct { #include "generic_maps.h" #include "generic_calls.h" -static struct generic_maps maps = { - .heap = (struct bpf_map_def *)&process_call_heap, - .calls = (struct bpf_map_def *)&lsm_calls, - .config = (struct bpf_map_def *)&config_map, - .filter = (struct bpf_map_def *)&filter_map, - .override = (struct bpf_map_def *)&override_tasks, -}; - #define MAIN "lsm/generic_lsm_core" __attribute__((section((MAIN)), used)) int generic_lsm_event(struct pt_regs *ctx) { - return generic_start_process_filter(ctx, &maps); + return generic_start_process_filter(ctx, (struct bpf_map_def *)&lsm_calls); } __attribute__((section("lsm"), used)) int diff --git a/bpf/process/bpf_generic_uprobe.c b/bpf/process/bpf_generic_uprobe.c index 34a002805d1..90c7f38158d 100644 --- a/bpf/process/bpf_generic_uprobe.c +++ b/bpf/process/bpf_generic_uprobe.c @@ -42,13 +42,6 @@ struct { #include "generic_maps.h" #include "generic_calls.h" -static struct generic_maps maps = { - .heap = (struct bpf_map_def *)&process_call_heap, - .calls = (struct bpf_map_def *)&uprobe_calls, - .config = (struct bpf_map_def *)&config_map, - .filter = (struct bpf_map_def *)&filter_map, -}; - #ifdef __MULTI_KPROBE #define MAIN "uprobe.multi/generic_uprobe" #else @@ -58,7 +51,7 @@ static struct generic_maps maps = { __attribute__((section((MAIN)), used)) int generic_uprobe_event(struct pt_regs *ctx) { - return generic_start_process_filter(ctx, &maps); + return generic_start_process_filter(ctx, (struct bpf_map_def *)&uprobe_calls); } __attribute__((section("uprobe"), used)) int diff --git a/bpf/process/generic_calls.h b/bpf/process/generic_calls.h index bf21dbe0575..ecc472a86e3 100644 --- a/bpf/process/generic_calls.h +++ b/bpf/process/generic_calls.h @@ -13,7 +13,7 @@ #define MAX_TOTAL 9000 FUNC_INLINE int -generic_start_process_filter(void *ctx, struct generic_maps *maps) +generic_start_process_filter(void *ctx, struct bpf_map_def *calls) { struct msg_generic_kprobe *msg; struct event_config *config; @@ -58,7 +58,7 @@ generic_start_process_filter(void *ctx, struct generic_maps *maps) msg->lsm.post = false; /* Tail call into filters. */ - tail_call(ctx, maps->calls, TAIL_CALL_FILTER); + tail_call(ctx, calls, TAIL_CALL_FILTER); return 0; } diff --git a/bpf/process/types/basic.h b/bpf/process/types/basic.h index e6421cba307..c864c109574 100644 --- a/bpf/process/types/basic.h +++ b/bpf/process/types/basic.h @@ -124,14 +124,6 @@ enum { TAIL_CALL_SEND = 5, }; -struct generic_maps { - struct bpf_map_def *heap; - struct bpf_map_def *calls; - struct bpf_map_def *config; - struct bpf_map_def *filter; - struct bpf_map_def *override; -}; - struct selector_action { __u32 actionlen; __u32 act[];