Skip to content

Commit

Permalink
tetragon: Switch generic_start_process_filter to use maps directly
Browse files Browse the repository at this point in the history
Signed-off-by: Jiri Olsa <[email protected]>
  • Loading branch information
olsajiri committed Dec 19, 2024
1 parent 1b05505 commit d78efe7
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 36 deletions.
10 changes: 1 addition & 9 deletions bpf/process/bpf_generic_kprobe.c
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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
Expand Down
10 changes: 1 addition & 9 deletions bpf/process/bpf_generic_lsm_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
9 changes: 1 addition & 8 deletions bpf/process/bpf_generic_uprobe.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
4 changes: 2 additions & 2 deletions bpf/process/generic_calls.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
}

Expand Down
8 changes: 0 additions & 8 deletions bpf/process/types/basic.h
Original file line number Diff line number Diff line change
Expand Up @@ -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[];
Expand Down

0 comments on commit d78efe7

Please sign in to comment.