-
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.
Signed-off-by: Andrea Terzolo <[email protected]>
- Loading branch information
1 parent
227690e
commit c13a4c5
Showing
7 changed files
with
385 additions
and
130 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
94 changes: 94 additions & 0 deletions
94
driver/modern_bpf/programs/tail_called/events/syscall_dispatched_events/io_uring_setup.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,94 @@ | ||
/* | ||
* 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> | ||
|
||
/*=============================== ENTER EVENT ===========================*/ | ||
|
||
SEC("tp_btf/sys_enter") | ||
int BPF_PROG(io_uring_setup_e, | ||
struct pt_regs *regs, | ||
long id) | ||
{ | ||
struct ringbuf_struct ringbuf; | ||
if(!ringbuf__reserve_space(&ringbuf, IO_URING_SETUP_E_SIZE)) | ||
{ | ||
return 0; | ||
} | ||
|
||
ringbuf__store_event_header(&ringbuf, PPME_SYSCALL_IO_URING_SETUP_E); | ||
|
||
/*=============================== 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(io_uring_setup_x, | ||
struct pt_regs *regs, | ||
long ret) | ||
{ | ||
struct ringbuf_struct ringbuf; | ||
if(!ringbuf__reserve_space(&ringbuf, IO_URING_SETUP_X_SIZE)) | ||
{ | ||
return 0; | ||
} | ||
|
||
ringbuf__store_event_header(&ringbuf, PPME_SYSCALL_IO_URING_SETUP_X); | ||
|
||
/*=============================== COLLECT PARAMETERS ===========================*/ | ||
|
||
/* Parameter 1: res (type: PT_ERRNO) */ | ||
ringbuf__store_s64(&ringbuf, ret); | ||
|
||
/* Parameter 2: entries (type: PT_UINT32) */ | ||
u32 entries = (u32)extract__syscall_argument(regs, 0); | ||
ringbuf__store_u32(&ringbuf, entries); | ||
|
||
/* Get the second syscall argument that is a `struct io_uring_params*` | ||
* This struct is defined since kernel release 5.1 | ||
*/ | ||
unsigned long params_pointer = extract__syscall_argument(regs, 1); | ||
struct io_uring_params params = {0}; | ||
bpf_probe_read_user((void *)¶ms, sizeof(struct io_uring_params), (void *)params_pointer); | ||
|
||
/* Parameter 3: sq_entries (type: PT_UINT32) */ | ||
ringbuf__store_u32(&ringbuf, params.sq_entries); | ||
|
||
/* Parameter 4: cq_entries (type: PT_UINT32) */ | ||
ringbuf__store_u32(&ringbuf, params.cq_entries); | ||
|
||
/* Parameter 5: flags (type: PT_FLAGS32) */ | ||
ringbuf__store_u32(&ringbuf, (u32)io_uring_setup_flags_to_scap(params.flags)); | ||
|
||
/* Parameter 6: sq_thread_cpu (type: PT_UINT32) */ | ||
ringbuf__store_u32(&ringbuf, params.sq_thread_cpu); | ||
|
||
/* Parameter 7: sq_thread_idle (type: PT_UINT32) */ | ||
ringbuf__store_u32(&ringbuf, params.sq_thread_idle); | ||
|
||
/* Parameter 8: features (type: PT_FLAGS32) */ | ||
ringbuf__store_u32(&ringbuf, (u32)io_uring_setup_feats_to_scap(params.features)); | ||
|
||
/*=============================== COLLECT PARAMETERS ===========================*/ | ||
|
||
ringbuf__submit_event(&ringbuf); | ||
|
||
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
Oops, something went wrong.