-
Notifications
You must be signed in to change notification settings - Fork 182
cleanup(driver,userspace/libscap,userspace/libsinsp): dropped simpleconsumer mode and simple driver concepts #521
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
a4262fe
9b993d3
db62a72
1b89ed5
046001c
9c0298c
b978031
fdc58a9
db79e54
42ca2f2
9993fae
a049e16
1e75573
a46471c
e5689fd
9417dbb
cb3ba23
76f9581
5db8905
6155d52
3a1b968
340c061
f642963
d9e1900
4ce017f
dfecb83
6645f62
e2710fe
3d2d1ca
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -40,6 +40,7 @@ BPF_PROBE("raw_syscalls/", sys_enter, sys_enter_args) | |||||||||||||||||||
| enum ppm_event_type evt_type; | ||||||||||||||||||||
| int drop_flags; | ||||||||||||||||||||
| long id; | ||||||||||||||||||||
| bool enabled; | ||||||||||||||||||||
|
|
||||||||||||||||||||
| if (bpf_in_ia32_syscall()) | ||||||||||||||||||||
| return 0; | ||||||||||||||||||||
|
|
@@ -48,6 +49,12 @@ BPF_PROBE("raw_syscalls/", sys_enter, sys_enter_args) | |||||||||||||||||||
| if (id < 0 || id >= SYSCALL_TABLE_SIZE) | ||||||||||||||||||||
FedeDP marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||||||||||||||
| return 0; | ||||||||||||||||||||
|
|
||||||||||||||||||||
| enabled = is_syscall_interesting(id); | ||||||||||||||||||||
| if (enabled == false) | ||||||||||||||||||||
| { | ||||||||||||||||||||
| return 0; | ||||||||||||||||||||
| } | ||||||||||||||||||||
|
|
||||||||||||||||||||
| settings = get_bpf_settings(); | ||||||||||||||||||||
| if (!settings) | ||||||||||||||||||||
| return 0; | ||||||||||||||||||||
|
|
@@ -59,9 +66,6 @@ BPF_PROBE("raw_syscalls/", sys_enter, sys_enter_args) | |||||||||||||||||||
| if (!sc_evt) | ||||||||||||||||||||
| return 0; | ||||||||||||||||||||
|
|
||||||||||||||||||||
| if (sc_evt->flags & UF_UNINTERESTING) | ||||||||||||||||||||
| return 0; | ||||||||||||||||||||
|
|
||||||||||||||||||||
| if (sc_evt->flags & UF_USED) { | ||||||||||||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Unsure about the use case for these settings that are probably legacy leftovers? Lines 65 to 71 in fb22f8e
Would it be possible to remove all of the code related to dropping_mode and kernel side random sampling? libs/userspace/libscap/engine/bpf/scap_bpf.c Line 1421 in fb22f8e
For every bpf tail call in sys enter and exit for the interesting syscalls we make an unnecessary call to drop_event libs/driver/bpf/plumbing_helpers.h Line 545 in fb22f8e
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. FWIW, we do need kernel side sampling and UF_ALWAYS_DROP/UF_NEVER_DROP (or equivalent functionality provided by some other mechanism)
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yup, agree with @gnosek .
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yeah agree with @FedeDP we cannot remove all this stuff in just one step, we will do it in little steps to avoid breaking all 🤣
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Totally, sorry should have been more clear about that this is a comment not intended for refactor all in once, but rather to not forget about it 🙃 @gnosek just out of curiosity what are those use cases for threat detection that require random kernel side sampling? yes, also think in the future there can be even better mechanisms for more deterministic kernel side dropping / filtering to alleviate unwanted back pressure from userspace. Will retain some suggestions for a future discussion to not overload this discussion here.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @FedeDP oops totally overlooked your previous comment, thanks for linking to it.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @incertum not for threat detection but for performance monitoring (the threat detection events are never dropped anyway). When we're running under high load, we can drop the less important events to make more room in the ring buffers for the critical ones. The current implementation is basically "drop non-critical events for all but the first 1/nth of every second", with n being a power of two between 1 and 128 (inclusive), set from userspace.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks @gnosek , this makes sense for performance monitoring. Hopefully we find the right approach to support both use cases. For threat detection use cases more system calls should probably have
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah right now there is quite a mess in our flags, we need to clean them a little bit, but I think this will be a future step 🚀 We need to specify the specific meaning of each one and understand when we have to label a syscall with it! @incertum these are all good points in my opinion maybe we can create an issue on that 🤔 WDYT? |
||||||||||||||||||||
| evt_type = sc_evt->enter_event_type; | ||||||||||||||||||||
| drop_flags = sc_evt->flags; | ||||||||||||||||||||
|
|
@@ -92,6 +96,7 @@ BPF_PROBE("raw_syscalls/", sys_exit, sys_exit_args) | |||||||||||||||||||
| enum ppm_event_type evt_type; | ||||||||||||||||||||
| int drop_flags; | ||||||||||||||||||||
| long id; | ||||||||||||||||||||
| bool enabled; | ||||||||||||||||||||
|
|
||||||||||||||||||||
| if (bpf_in_ia32_syscall()) | ||||||||||||||||||||
| return 0; | ||||||||||||||||||||
|
|
@@ -100,6 +105,12 @@ BPF_PROBE("raw_syscalls/", sys_exit, sys_exit_args) | |||||||||||||||||||
| if (id < 0 || id >= SYSCALL_TABLE_SIZE) | ||||||||||||||||||||
| return 0; | ||||||||||||||||||||
|
|
||||||||||||||||||||
| enabled = is_syscall_interesting(id); | ||||||||||||||||||||
| if (enabled == false) | ||||||||||||||||||||
| { | ||||||||||||||||||||
| return 0; | ||||||||||||||||||||
| } | ||||||||||||||||||||
|
|
||||||||||||||||||||
| settings = get_bpf_settings(); | ||||||||||||||||||||
| if (!settings) | ||||||||||||||||||||
| return 0; | ||||||||||||||||||||
|
|
@@ -111,9 +122,6 @@ BPF_PROBE("raw_syscalls/", sys_exit, sys_exit_args) | |||||||||||||||||||
| if (!sc_evt) | ||||||||||||||||||||
| return 0; | ||||||||||||||||||||
|
|
||||||||||||||||||||
| if (sc_evt->flags & UF_UNINTERESTING) | ||||||||||||||||||||
| return 0; | ||||||||||||||||||||
|
|
||||||||||||||||||||
| if (sc_evt->flags & UF_USED) { | ||||||||||||||||||||
| evt_type = sc_evt->exit_event_type; | ||||||||||||||||||||
| drop_flags = sc_evt->flags; | ||||||||||||||||||||
|
|
@@ -180,9 +188,6 @@ static __always_inline int bpf_page_fault(struct page_fault_args *ctx) | |||||||||||||||||||
| if (!settings) | ||||||||||||||||||||
| return 0; | ||||||||||||||||||||
|
|
||||||||||||||||||||
| if (!settings->page_faults) | ||||||||||||||||||||
| return 0; | ||||||||||||||||||||
|
|
||||||||||||||||||||
| if (!settings->capture_enabled) | ||||||||||||||||||||
| return 0; | ||||||||||||||||||||
|
|
||||||||||||||||||||
|
|
||||||||||||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -220,8 +220,9 @@ enum scap_map_types { | |
| SCAP_TMP_SCRATCH_MAP = 7, | ||
| SCAP_SETTINGS_MAP = 8, | ||
| SCAP_LOCAL_STATE_MAP = 9, | ||
| SCAP_INTERESTING_SYSCALLS_TABLE = 10, | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hmm how didn't we have this table before?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We passed a sentinel value while filling the syscall_table map instead; see old impl of populate_syscall_table_map() in scap_bpf.c |
||
| #ifndef BPF_SUPPORTS_RAW_TRACEPOINTS | ||
| SCAP_STASH_MAP = 10, | ||
| SCAP_STASH_MAP = 11, | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'd remove the
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Indeed it is unused 😆 https://github.com/falcosecurity/libs/search?q=SCAP_STASH_MAP |
||
| #endif | ||
| }; | ||
|
|
||
|
|
@@ -232,7 +233,6 @@ struct scap_bpf_settings { | |
| uint32_t sampling_ratio; | ||
| bool capture_enabled; | ||
| bool do_dynamic_snaplen; | ||
| bool page_faults; | ||
| bool dropping_mode; | ||
| bool is_dropping; | ||
| bool tracers_enabled; | ||
|
|
||
Large diffs are not rendered by default.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
New interesting syscalls map for bpf.