-
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 mknod/mknodat syscall
Signed-off-by: Roberto Scolaro <[email protected]>
- Loading branch information
1 parent
3a08024
commit bd2d62c
Showing
19 changed files
with
1,147 additions
and
10 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
83 changes: 83 additions & 0 deletions
83
driver/modern_bpf/programs/tail_called/events/syscall_dispatched_events/mknod.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,83 @@ | ||
/* | ||
* 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(mknod_e, | ||
struct pt_regs *regs, | ||
long id) | ||
{ | ||
struct ringbuf_struct ringbuf; | ||
if(!ringbuf__reserve_space(&ringbuf, ctx, MKNOD_E_SIZE, PPME_SYSCALL_MKNOD_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(mknod_x, | ||
struct pt_regs *regs, | ||
long ret) | ||
{ | ||
struct auxiliary_map *auxmap = auxmap__get(); | ||
if(!auxmap) | ||
{ | ||
return 0; | ||
} | ||
|
||
auxmap__preload_event_header(auxmap, PPME_SYSCALL_MKNOD_X); | ||
|
||
/*=============================== COLLECT PARAMETERS ===========================*/ | ||
|
||
/* Parameter 1: ret (type: PT_ERRNO) */ | ||
auxmap__store_s64_param(auxmap, ret); | ||
|
||
/* Parameter 2: path (type: PT_CHARBUF) */ | ||
unsigned long path_pointer = extract__syscall_argument(regs, 0); | ||
auxmap__store_charbuf_param(auxmap, path_pointer, MAX_PATH, USER); | ||
|
||
/* Parameter 3: mode (type: PT_MODE) */ | ||
u32 mode = (u32)extract__syscall_argument(regs, 1); | ||
auxmap__store_u32_param(auxmap,mknod_mode_to_scap(mode)); | ||
|
||
/* Parameter 4: dev (type: PT_UINT32) */ | ||
u32 dev = (u32)extract__syscall_argument(regs, 2); | ||
auxmap__store_u32_param(auxmap, dev); | ||
|
||
|
||
/*=============================== COLLECT PARAMETERS ===========================*/ | ||
|
||
auxmap__finalize_event_header(auxmap); | ||
|
||
auxmap__submit_event(auxmap, ctx); | ||
|
||
return 0; | ||
} | ||
|
||
/*=============================== EXIT EVENT ===========================*/ |
91 changes: 91 additions & 0 deletions
91
driver/modern_bpf/programs/tail_called/events/syscall_dispatched_events/mknodat.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,91 @@ | ||
/* | ||
* 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(mknodat_e, | ||
struct pt_regs *regs, | ||
long id) | ||
{ | ||
struct ringbuf_struct ringbuf; | ||
if(!ringbuf__reserve_space(&ringbuf, ctx, MKNODAT_E_SIZE, PPME_SYSCALL_MKNODAT_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(mknodat_x, | ||
struct pt_regs *regs, | ||
long ret) | ||
{ | ||
struct auxiliary_map *auxmap = auxmap__get(); | ||
if(!auxmap) | ||
{ | ||
return 0; | ||
} | ||
|
||
auxmap__preload_event_header(auxmap, PPME_SYSCALL_MKNODAT_X); | ||
|
||
/*=============================== COLLECT PARAMETERS ===========================*/ | ||
|
||
/* Parameter 1: ret (type: PT_ERRNO) */ | ||
auxmap__store_s64_param(auxmap, ret); | ||
|
||
/* Parameter 2: dirfd (type: PT_FD) */ | ||
s32 dirfd = (s32)extract__syscall_argument(regs, 0); | ||
if(dirfd == AT_FDCWD) | ||
{ | ||
dirfd = PPM_AT_FDCWD; | ||
} | ||
auxmap__store_s64_param(auxmap, (s64)dirfd); | ||
|
||
/* Parameter 2: path (type: PT_CHARBUF) */ | ||
unsigned long path_pointer = extract__syscall_argument(regs, 1); | ||
auxmap__store_charbuf_param(auxmap, path_pointer, MAX_PATH, USER); | ||
|
||
/* Parameter 3: mode (type: PT_MODE) */ | ||
u32 mode = (u32)extract__syscall_argument(regs, 2); | ||
auxmap__store_u32_param(auxmap, mknod_mode_to_scap(mode)); | ||
|
||
/* Parameter 4: dev (type: PT_UINT32) */ | ||
u32 dev = (u32)extract__syscall_argument(regs, 3); | ||
auxmap__store_u32_param(auxmap, dev); | ||
|
||
|
||
/*=============================== 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
Oops, something went wrong.