-
Notifications
You must be signed in to change notification settings - Fork 165
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(driver): support for init_module,finit_module syscalls
Signed-off-by: Roberto Scolaro <[email protected]>
- Loading branch information
1 parent
1a5a031
commit fbd35a1
Showing
19 changed files
with
567 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
86 changes: 86 additions & 0 deletions
86
driver/modern_bpf/programs/tail_called/events/syscall_dispatched_events/finit_module.bpf.c
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
/* | ||
* Copyright (C) 2023 The Falco Authors. | ||
* | ||
* This file is dual licensed under either the MIT or GPL 2. See MIT.txt | ||
* or GPL2.txt for full copies of the license. | ||
*/ | ||
|
||
#include <helpers/interfaces/fixed_size_event.h> | ||
#include <helpers/interfaces/variable_size_event.h> | ||
|
||
/*=============================== ENTER EVENT ===========================*/ | ||
|
||
SEC("tp_btf/sys_enter") | ||
int BPF_PROG(finit_module_e, | ||
struct pt_regs *regs, | ||
long id) | ||
{ | ||
struct ringbuf_struct ringbuf; | ||
if(!ringbuf__reserve_space(&ringbuf, ctx, FINIT_MODULE_E_SIZE, PPME_SYSCALL_FINIT_MODULE_E)) | ||
{ | ||
return 0; | ||
} | ||
|
||
ringbuf__store_event_header(&ringbuf); | ||
|
||
/*=============================== COLLECT PARAMETERS ===========================*/ | ||
|
||
// Here we have no parameters to collect. | ||
|
||
/*=============================== COLLECT PARAMETERS ===========================*/ | ||
|
||
ringbuf__submit_event(&ringbuf); | ||
|
||
return 0; | ||
|
||
|
||
} | ||
|
||
/*=============================== ENTER EVENT ===========================*/ | ||
|
||
/*=============================== EXIT EVENT ===========================*/ | ||
|
||
SEC("tp_btf/sys_exit") | ||
int BPF_PROG(finit_module_x, | ||
struct pt_regs *regs, | ||
long ret) | ||
{ | ||
struct auxiliary_map *auxmap = auxmap__get(); | ||
if(!auxmap) | ||
{ | ||
return 0; | ||
} | ||
|
||
auxmap__preload_event_header(auxmap, PPME_SYSCALL_FINIT_MODULE_X); | ||
|
||
/*=============================== COLLECT PARAMETERS ===========================*/ | ||
|
||
/* Parameter 1: ret (type: PT_ERRNO) */ | ||
auxmap__store_s64_param(auxmap, ret); | ||
|
||
/* Parameter 2: dirfd (type: PT_FD) */ | ||
s64 fd = (s64)extract__syscall_argument(regs, 0); | ||
auxmap__store_s64_param(auxmap, fd); | ||
|
||
u16 snaplen = maps__get_snaplen(); | ||
apply_dynamic_snaplen(regs, &snaplen, false); | ||
|
||
/* Parameter 3: uargs (type: PT_CHARBUF) */ | ||
unsigned long uargs_ptr = extract__syscall_argument(regs, 1); | ||
auxmap__store_charbuf_param(auxmap, uargs_ptr, snaplen, USER); | ||
|
||
/* Parameter 4: flags (type: PT_INT32) */ | ||
s32 flags = extract__syscall_argument(regs, 2); | ||
auxmap__store_u32_param(auxmap, (s32)finit_module_flags_to_scap(flags)); | ||
|
||
|
||
/*=============================== COLLECT PARAMETERS ===========================*/ | ||
|
||
auxmap__finalize_event_header(auxmap); | ||
|
||
auxmap__submit_event(auxmap, ctx); | ||
|
||
return 0; | ||
} | ||
|
||
/*=============================== EXIT EVENT ===========================*/ |
85 changes: 85 additions & 0 deletions
85
driver/modern_bpf/programs/tail_called/events/syscall_dispatched_events/init_module.bpf.c
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
/* | ||
* Copyright (C) 2023 The Falco Authors. | ||
* | ||
* This file is dual licensed under either the MIT or GPL 2. See MIT.txt | ||
* or GPL2.txt for full copies of the license. | ||
*/ | ||
|
||
#include <helpers/interfaces/fixed_size_event.h> | ||
#include <helpers/interfaces/variable_size_event.h> | ||
|
||
/*=============================== ENTER EVENT ===========================*/ | ||
|
||
SEC("tp_btf/sys_enter") | ||
int BPF_PROG(init_module_e, | ||
struct pt_regs *regs, | ||
long id) | ||
{ | ||
struct ringbuf_struct ringbuf; | ||
if(!ringbuf__reserve_space(&ringbuf, ctx, INIT_MODULE_E_SIZE, PPME_SYSCALL_INIT_MODULE_E)) | ||
{ | ||
return 0; | ||
} | ||
|
||
ringbuf__store_event_header(&ringbuf); | ||
|
||
/*=============================== COLLECT PARAMETERS ===========================*/ | ||
|
||
// Here we have no parameters to collect. | ||
|
||
/*=============================== COLLECT PARAMETERS ===========================*/ | ||
|
||
ringbuf__submit_event(&ringbuf); | ||
|
||
return 0; | ||
|
||
|
||
} | ||
|
||
/*=============================== ENTER EVENT ===========================*/ | ||
|
||
/*=============================== EXIT EVENT ===========================*/ | ||
|
||
SEC("tp_btf/sys_exit") | ||
int BPF_PROG(init_module_x, | ||
struct pt_regs *regs, | ||
long ret) | ||
{ | ||
struct auxiliary_map *auxmap = auxmap__get(); | ||
if(!auxmap) | ||
{ | ||
return 0; | ||
} | ||
|
||
auxmap__preload_event_header(auxmap, PPME_SYSCALL_INIT_MODULE_X); | ||
|
||
/*=============================== COLLECT PARAMETERS ===========================*/ | ||
|
||
/* Parameter 1: ret (type: PT_ERRNO) */ | ||
auxmap__store_s64_param(auxmap, ret); | ||
|
||
/* Parameter 3: length (type: PT_UINT64) */ | ||
u64 len = extract__syscall_argument(regs, 1); | ||
|
||
/* Parameter 2: img (type: PT_BYTEBUF) */ | ||
unsigned long img_ptr = extract__syscall_argument(regs, 0); | ||
auxmap__store_bytebuf_param(auxmap, img_ptr, len, USER); | ||
|
||
/* Parameter 3: length (type: PT_UINT64) */ | ||
auxmap__store_u64_param(auxmap, (u64)len); | ||
|
||
/* Parameter 4: uargs (type: PT_CHARBUF) */ | ||
unsigned long uargs_ptr = extract__syscall_argument(regs, 2); | ||
auxmap__store_charbuf_param(auxmap, uargs_ptr, len, USER); | ||
|
||
|
||
/*=============================== COLLECT PARAMETERS ===========================*/ | ||
|
||
auxmap__finalize_event_header(auxmap); | ||
|
||
auxmap__submit_event(auxmap, ctx); | ||
|
||
return 0; | ||
} | ||
|
||
/*=============================== EXIT EVENT ===========================*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.