Compare commits

...

201 Commits

Author SHA1 Message Date
Angelo Puglisi 082157de78 fix(userspace/libsinsp): sinsp_filter_check_user::extract_single return-stack-address
Address the following warning (we build with -Werror...):
```
/__w/libs/libs/userspace/libsinsp/sinsp_filtercheck_user.cpp:104:26: warning: address of stack memory associated with local variable 'user' returned [-Wreturn-stack-address]
  104 |                         RETURN_EXTRACT_STRING(user);
      |                                               ^~~~
/__w/libs/libs/userspace/libsinsp/sinsp_filtercheck_user.cpp:34:21: note: expanded from macro 'RETURN_EXTRACT_STRING'
   34 |                 return (uint8_t*)(x).c_str(); \
      |                                   ^
```

Signed-off-by: Angelo Puglisi <angelopuglisi86@gmail.com>
2025-08-06 16:39:05 +02:00
Holger Hoffstätte a273f3d05c fix(libsinsp): use proper INET6_ADDRSTRLEN buffer size for inet_ntop
glibc-2.42 added __inet_ntop_chk fortification, which started to fail:

  *** buffer overflow detected ***: terminated
  Program received signal SIGABRT, Aborted.
  0x00007ffff629b0dc in __pthread_kill_implementation () from /lib64/libc.so.6
  (gdb) bt
  #0  0x00007ffff629b0dc in __pthread_kill_implementation () from /lib64/libc.so.6
  #1  0x00007ffff6242572 in raise () from /lib64/libc.so.6
  #2  0x00007ffff6229f3b in abort () from /lib64/libc.so.6
  #3  0x00007ffff622b148 in __libc_message_impl.cold () from /lib64/libc.so.6
  #4  0x00007ffff6327337 in __fortify_fail () from /lib64/libc.so.6
  #5  0x00007ffff6326c92 in __chk_fail () from /lib64/libc.so.6
  #6  0x00007ffff6327a62 in __inet_ntop_chk () from /lib64/libc.so.6
  #7  0x000055555569da3d in inet_ntop (__af=10, __src=0x555555ee0800, __dst=0x7fffffff4f90 "\260P\377\377\377\177", __dst_size=100) at /usr/include/bits/inet-fortified.h:36
  #8  ipv6tuple_to_string[abi:cxx11](ipv6tuple*, bool) (tuple=0x555555ee0800, resolve=false) at /tmp/portage/dev-debug/sysdig-0.40.1/work/libs-0.20.0/userspace/libsinsp/utils.c

Use INET6_ADDRSTRLEN as destination buffer size.

Fixes: https://github.com/falcosecurity/libs/issues/2573
Signed-off-by: Holger Hoffstätte <holger@applied-asynchrony.com>
2025-08-04 12:16:49 +02:00
Federico Di Pierro 8cd5fbf687 fix(userspace/libsinsp): properly check `lastevent_retrieved` value before accessing `enter_evt` in `parse_open_openat_creat_exit` for `PPME_SYSCALL_OPENAT_X`.
Also, fixed a small bug in a test.

Signed-off-by: Federico Di Pierro <nierro92@gmail.com>
2025-08-04 10:00:48 +02:00
Federico Di Pierro b530bf90fb cleanup(userspace/libsinsp): drop `sinsp_parser::m_tmp_events_buffer`.
Signed-off-by: Federico Di Pierro <nierro92@gmail.com>
2025-08-04 10:00:48 +02:00
Tero Kauppinen fc31690604 feat(savefile): add empty parameter support for PPME_SETPGID_X
Support for empty parameters was added with
https://github.com/falcosecurity/libs/pull/2550.

This update adds empty parameter support for `PPME_SYSCALL_SETPGID_X`.

Signed-off-by: Tero Kauppinen <tero.kauppinen@est.tech>
2025-08-04 09:46:48 +02:00
Tero Kauppinen 831ed012e0 feat(savefile): add empty parameter support for PPME_SYSCALL_SETNS_X
Support for empty parameters was added with
https://github.com/falcosecurity/libs/pull/2550.

This update adds empty parameter support for `PPME_SYSCALL_SETNS_X`.

Signed-off-by: Tero Kauppinen <tero.kauppinen@est.tech>
2025-08-04 09:46:48 +02:00
Tero Kauppinen 90c9ffecd5 feat(savefile): added empty parameter support for PPME_SYSCALL_FCHDIR_X
Support for empty parameters was added with
https://github.com/falcosecurity/libs/pull/2550.

This update adds empty parameter support for `PPME_SYSCALL_FCHDIR_X`.

Signed-off-by: Tero Kauppinen <tero.kauppinen@est.tech>
2025-08-01 12:39:29 +02:00
Leonardo Di Giovanna 719eeed0bc refactor(userspace/libsinsp): remove timestamp saving custom logic
Remove unused timestamp saving custom logic in parser for
`PPME_SYSCALL_SELECT_E`, `PPME_SYSCALL_POLL_X`,
`PPME_SYSCALL_PPOLL_X` and `PPME_SYSCALL_EPOLLWAIT_X` events

Signed-off-by: Leonardo Di Giovanna <leonardodigiovanna1@gmail.com>
2025-08-01 12:11:29 +02:00
Federico Di Pierro 59960f5df1 update(cmake): bumped container plugin to 0.3.4.
Signed-off-by: Federico Di Pierro <nierro92@gmail.com>
2025-08-01 10:19:28 +02:00
Tero Kauppinen b5e18368c5 cleanup(libsinsp): utilize `get_exit_event_fd_location`
The current implementation uses custom code for fetching
the location of fd-related arguments for specific syscalls.

This update removes the custom code and utilizes the
existing `get_exit_event_fd_location` function instead by
expanding it with the location of the `dirfd' argument.

Signed-off-by: Tero Kauppinen <tero.kauppinen@est.tech>
2025-07-31 15:39:24 +02:00
Tero Kauppinen 6685f4a0ec fix: add `EF_USES_FD` flag to events missing it
Some of the events in `g_event_info` structure are not flagged
with `EF_USES_FD` but still use the fd information when parsing.

Add the flag to the following events:

PPME_SYSCALL_SYMLINKAT_X
PPME_SYSCALL_UNLINKAT_2_X
PPME_SYSCALL_MKDIRAT_X
PPME_SYSCALL_FCHMODAT_X
PPME_SYSCALL_FCHOWNAT_X

Signed-off-by: Tero Kauppinen <tero.kauppinen@est.tech>
2025-07-31 15:39:24 +02:00
Leonardo Di Giovanna 7c1aecf4c6 feat: make `PPME_SYSCALL_CLONE3_{E, X}` managed by scap-converter
Make `PPME_SYSCALL_CLONE3_E` and `PPME_SYSCALL_CLONE3_X` managed by
the scap converter and contextually fix some tests using clone3 and
clone events.

Signed-off-by: Leonardo Di Giovanna <leonardodigiovanna1@gmail.com>
2025-07-31 12:08:23 +02:00
Leonardo Di Giovanna 39ab969475 feat: make `PPME_SYSCALL_VFORK_{E, X}` managed by scap-converter
Make both `PPME_SYSCALL_VFORK_E` and `PPME_SYSCALL_VFORK_X` events
managed by the scap-converter. Specifically, convert them to the
corresponding `PPME_SYSCALL_VFORK_17_{E, X}` event types; this allows
userspace code to get rid of special handling code for them.

Signed-off-by: Leonardo Di Giovanna <leonardodigiovanna1@gmail.com>
2025-07-31 12:08:23 +02:00
Leonardo Di Giovanna 870a8a7bc2 feat: make `PPME_SYSCALL_VFORK_17_{E, X}` managed by scap-converter
Make both `PPME_SYSCALL_VFORK_17_E` and `PPME_SYSCALL_VFORK_17_X`
events managed by the scap-converter. Specifically, convert them to
the corresponding `PPME_SYSCALL_VFORK_20_{E, X}` event types; this
allows userspace code to get rid of special handling code for them.

Signed-off-by: Leonardo Di Giovanna <leonardodigiovanna1@gmail.com>
2025-07-31 12:08:23 +02:00
Leonardo Di Giovanna 8808497f1a feat: make `PPME_SYSCALL_VFORK_20_{E, X}` managed by scap-converter
Signed-off-by: Leonardo Di Giovanna <leonardodigiovanna1@gmail.com>
2025-07-31 12:08:23 +02:00
Leonardo Di Giovanna 2618d37a20 feat: make `PPME_SYSCALL_FORK_{E, X}` managed by scap-converter
Make both `PPME_SYSCALL_FORK_E` and `PPME_SYSCALL_FORK_X` events
managed by the scap-converter. Specifically, convert them to the
corresponding `PPME_SYSCALL_FORK_17_{E, X}` event types; this allows
userspace code to get rid of special handling code for them.

Signed-off-by: Leonardo Di Giovanna <leonardodigiovanna1@gmail.com>
2025-07-30 18:34:19 +02:00
Leonardo Di Giovanna 5e0981dc0d feat: make `PPME_SYSCALL_FORK_17_{E, X}` managed by scap-converter
Make both `PPME_SYSCALL_FORK_17_E` and `PPME_SYSCALL_FORK_17_X`
events managed by the scap-converter. Specifically, convert them to
the corresponding `PPME_SYSCALL_FORK_20_{E, X}` event types; this
allows userspace code to get rid of special handling code for them.

Signed-off-by: Leonardo Di Giovanna <leonardodigiovanna1@gmail.com>
2025-07-30 18:34:19 +02:00
Leonardo Di Giovanna 8f3e222d16 feat: make `PPME_SYSCALL_FORK_20_{E, X}` managed by scap-converter
Signed-off-by: Leonardo Di Giovanna <leonardodigiovanna1@gmail.com>
2025-07-30 18:34:19 +02:00
Tero Kauppinen 52d638570a fix(userspace/libsinsp): remove state handling for PPM_SYSCALL_LINK
and PPM_SYSCALL_LINKAT

The new driver does not emit `PPM_SYSCALL_LINK` and
`PPM_SYSCALL_LINKAT` events anymore, and there is no longer need
to handle the old version of the events. This update removes the
state handling and adds conversion rules for the scap files.

Signed-off-by: Tero Kauppinen <tero.kauppinen@est.tech>
2025-07-30 17:40:19 +02:00
Leonardo Di Giovanna 8ad30697ed feat: make `PPME_SYSCALL_CLONE_11_{E, X}` managed by scap-converter
Make both `PPME_SYSCALL_CLONE_11_E` and `PPME_SYSCALL_CLONE_11_X`
events managed by the scap-converter. Specifically, convert them to
the corresponding `PPME_SYSCALL_CLONE_11_{E, X}` event types; this
allows userspace code to get rid of special handling code for them.

Signed-off-by: Leonardo Di Giovanna <leonardodigiovanna1@gmail.com>
2025-07-30 16:01:18 +02:00
Leonardo Di Giovanna fa62300265 feat: make `PPME_SYSCALL_CLONE_16_{E, X}` managed by scap-converter
Make both `PPME_SYSCALL_CLONE_16_E` and `PPME_SYSCALL_CLONE_16_X`
events managed by the scap-converter. Specifically, convert them to
the corresponding `PPME_SYSCALL_CLONE_17_{E, X}` event types; this
allows userspace code to get rid of special handling code for them.

Signed-off-by: Leonardo Di Giovanna <leonardodigiovanna1@gmail.com>
2025-07-30 16:01:18 +02:00
Leonardo Di Giovanna 316fcb2a39 feat: make `PPME_SYSCALL_CLONE_17_{E, X}` managed by scap-converter
Make both `PPME_SYSCALL_CLONE_17_E` and `PPME_SYSCALL_CLONE_17_X`
events managed by the scap-converter. Specifically, convert them to
the corresponding `PPME_SYSCALL_CLONE_20_{E, X}` event types; this
allows userspace code to get rid of special handling code for them.

Signed-off-by: Leonardo Di Giovanna <leonardodigiovanna1@gmail.com>
2025-07-30 16:01:18 +02:00
Leonardo Di Giovanna 6b56ab9ab7 feat: make `PPME_SYSCALL_CLONE_20_{E, X}` managed by scap-converter
Signed-off-by: Leonardo Di Giovanna <leonardodigiovanna1@gmail.com>
2025-07-30 16:01:18 +02:00
Tero Kauppinen a7ba9de555 fix(userspace/libsinsp): remove state handling for PPM_SYSCALL_UNLINK
and PPM_SYSCALL_UNLINKAT

The new driver does not emit `PPM_SYSCALL_UNLINK` and
`PPM_SYSCALL_UNLINKAT` events anymore, and there is no longer need
to handle the old version of the events. This update removes the
state handling and adds conversion rules for the scap files.

Signed-off-by: Tero Kauppinen <tero.kauppinen@est.tech>
2025-07-30 14:03:18 +02:00
Leonardo Di Giovanna 1e35de4388 feat: make `PPME_SYSCALL_EXECVE_8_{E, X}` managed by scap-converter
Make both `PPME_SYSCALL_EXECVE_8_E` and `PPME_SYSCALL_EXECVE_8_X`
events managed by the scap-converter. Specifically, convert them to
the corresponding `PPME_SYSCALL_EXECVE_13_{E, X}` event types; this
allows userspace code to get rid of special handling code for them.

Signed-off-by: Leonardo Di Giovanna <leonardodigiovanna1@gmail.com>
2025-07-30 10:42:56 +02:00
Leonardo Di Giovanna 78acd68141 feat: make `PPME_SYSCALL_EXECVE_13_{E, X}` managed by scap-converter
Make both `PPME_SYSCALL_EXECVE_13_E` and `PPME_SYSCALL_EXECVE_13_X`
events managed by the scap-converter. Specifically, convert them to
the corresponding `PPME_SYSCALL_EXECVE_14_{E, X}` event types; this
allows userspace code to get rid of special handling code for them.

Signed-off-by: Leonardo Di Giovanna <leonardodigiovanna1@gmail.com>
2025-07-30 10:42:56 +02:00
Leonardo Di Giovanna 21e8b0c1c0 feat: make `PPME_SYSCALL_EXECVE_14_{E, X}` managed by scap-converter
Make both `PPME_SYSCALL_EXECVE_14_E` and `PPME_SYSCALL_EXECVE_14_X`
events managed by the scap-converter. Specifically, convert them to
the corresponding `PPME_SYSCALL_EXECVE_15_{E, X}` event types; this
allows userspace code to get rid of special handling code for them.

Signed-off-by: Leonardo Di Giovanna <leonardodigiovanna1@gmail.com>
2025-07-30 10:42:56 +02:00
Leonardo Di Giovanna c3d38df059 feat: make `PPME_SYSCALL_EXECVE_15_{E, X}` managed by scap-converter
Make both `PPME_SYSCALL_EXECVE_15_E` and `PPME_SYSCALL_EXECVE_15_X`
events managed by the scap-converter. Specifically, convert them to
the corresponding `PPME_SYSCALL_EXECVE_16_{E, X}` event types; this
allows userspace code to get rid of special handling code for them.

Signed-off-by: Leonardo Di Giovanna <leonardodigiovanna1@gmail.com>
2025-07-30 10:42:56 +02:00
Leonardo Di Giovanna ebe35459a3 feat: make `PPME_SYSCALL_EXECVE_16_{E, X}` managed by scap-converter
Make both `PPME_SYSCALL_EXECVE_16_E` and `PPME_SYSCALL_EXECVE_16_X`
events managed by the scap-converter. Specifically, convert them to
the corresponding `PPME_SYSCALL_EXECVE_17_{E, X}` event types; this
allows userspace code to get rid of special handling code for them.

Signed-off-by: Leonardo Di Giovanna <leonardodigiovanna1@gmail.com>
2025-07-30 10:42:56 +02:00
Leonardo Di Giovanna 9b991ad442 feat: make `PPME_SYSCALL_EXECVE_17_{E, X}` managed by scap-converter
Make both `PPME_SYSCALL_EXECVE_17_E` and `PPME_SYSCALL_EXECVE_17_X`
events managed by the scap-converter. Specifically, convert them to
the corresponding `PPME_SYSCALL_EXECVE_18_{E, X}` event types; this
allows userspace code to get rid of special handling code for them.

Signed-off-by: Leonardo Di Giovanna <leonardodigiovanna1@gmail.com>
2025-07-30 10:42:56 +02:00
Leonardo Di Giovanna 828935f0e5 feat: make `PPME_SYSCALL_EXECVE_18_{E, X}` managed by scap-converter
Make both `PPME_SYSCALL_EXECVE_18_E` and `PPME_SYSCALL_EXECVE_18_X`
events managed by the scap-converter. Specifically, convert them to
the corresponding `PPME_SYSCALL_EXECVE_19_{E, X}` event types; this
allows userspace code to get rid of special handling code for them.

Signed-off-by: Leonardo Di Giovanna <leonardodigiovanna1@gmail.com>
2025-07-30 10:42:56 +02:00
Leonardo Di Giovanna d021cbfd34 feat: make `PPME_SYSCALL_EXECVEAT_X` "scap converter"-managed
Let the scap converter managing all the possible variation of
`PPME_SYSCALL_EXECVEAT_X` event, adapting the userspace code to
handle possible empty values coming from the conversion.

The `PPME_SYSCALL_EXECVEAT_E` event is stil sent to sinsp, as its
parameters are still used as a fallback if the `trusted_exepath`
parameter is not present in the exit event.

Moreover, fixes some execveat tests.

Signed-off-by: Leonardo Di Giovanna <leonardodigiovanna1@gmail.com>
2025-07-29 14:12:09 +02:00
Leonardo Di Giovanna b8a55f471e test(userspace/libsinsp): add scap conversion test for execve
Signed-off-by: Leonardo Di Giovanna <leonardodigiovanna1@gmail.com>
2025-07-29 14:12:09 +02:00
Leonardo Di Giovanna b4d1072d66 feat(userspace/libsinsp)!: defer sinsp evt params null-encoding logic
In the previous implementation, some specific parameter configurations
(empty or containing '(NULL)', with the type being equal to
`PT_CHARBUF`, `PT_FSPATH` or `PT_FSRELPATH`) were patched at loading
time with the following configuration:
- data: "<NA>"
- len: 5
This made empty parameters indistinguishable from non-empty
parameters.

The new implementation loads the parameters and keeps them untouched:
in this way, it is possible to inspect their original data and
lengths.

Since majority of the userspace space implementation still relies on
the aforementioned particular "null" encoding, a couple of new methods
(i.e. `sinsp_evt_param::used_legacy_null_encoding()` and
`sinsp_evt_param::data_and_len_with_legacy_null_encoding()`),
helping to check or simulate the old behaviour, are provided.
Moreover, parameter conversion methods (e.g.
`sinsp_evt_param::as<T>()`), still return the legacy encoded version.

BREAKING CHANGE: make parameter data and len private

Signed-off-by: Leonardo Di Giovanna <leonardodigiovanna1@gmail.com>
2025-07-29 10:10:09 +02:00
Leonardo Grasso 2a3b01dbb1 fix(userspace/libscap/engine/gvisor): handle read() < 0
Co-authored-by: Leonardo Di Giovanna <leonardodigiovanna1@gmail.com>
Signed-off-by: Leonardo Grasso <me@leonardograsso.com>
2025-07-28 10:26:05 +02:00
Leonardo Grasso 7d599304a5 fix(userspace/libsinsp): eliminate race condition in plugin async event handler cleanup
Signed-off-by: Leonardo Grasso <me@leonardograsso.com>
2025-07-28 10:26:05 +02:00
Leonardo Grasso b902665cc3 fix(userspace/libscap/engine/gvisor): proper null termination in runsc output handling
Signed-off-by: Leonardo Grasso <me@leonardograsso.com>
2025-07-28 10:26:05 +02:00
Leonardo Grasso a81dc05c16 fix(userspace/libsinsp): prevent path traversal in container memory usage reader
Signed-off-by: Leonardo Grasso <me@leonardograsso.com>
2025-07-28 10:26:05 +02:00
Leonardo Di Giovanna 592217e71c fix(userspace/libsinsp): partially fix filterchecks for empty params
Introduce two fixes:
- turn "NULL" into "<NA>" upon string conversion for parameters that
  couldn't be empty before the introduction of the notion of "empty
  parameters" in the scap-converter
- fix implementation of `exists` operator for `evt.rawarg` by
flagging zero-length parameters as non-existing.

Moreover, introduce a bunch of unit tests for `evt.arg.*` and
`evt.rawarg.*`, and move some of the old one to new locations. Tests
are annotated in order to reflect the expectation of a future good
implementation.

Signed-off-by: Leonardo Di Giovanna <leonardodigiovanna1@gmail.com>
2025-07-25 10:48:44 +02:00
Leonardo Di Giovanna 1f177d0599 fix(userspace/libscap): fix `SCAP_EMPTY_PARAMS_SET` def on Windows
Do not use GCC extension to define `SCAP_EMPTY_PARAMS_SET`. In this
way, it can be used in Windows.

Signed-off-by: Leonardo Di Giovanna <leonardodigiovanna1@gmail.com>
2025-07-25 10:48:44 +02:00
Leonardo Di Giovanna 31673d110d fix(userspace/libscap): populate error in case of failing `stat` on fd
Signed-off-by: Leonardo Di Giovanna <leonardodigiovanna1@gmail.com>
2025-07-24 15:31:41 +02:00
Tero Kauppinen a04a40f95f fix(libscap): add missing fd locations for dup exit events
The function extracting `fd` parameter's location from the
exit event is missing information for the dup syscalls.

Add location of the `fd` parameter in the exit event for
all dup syscalls.

Signed-off-by: Tero Kauppinen <tero.kauppinen@est.tech>
2025-07-24 11:11:40 +02:00
Leonardo Di Giovanna 5afd8eee0e fix: `evt.rawarg.*` raw val eval for pids, uids, gids and socktuples
Add support for `evt.rawarg.*` raw value evaluation for `PT_PID`,
`PT_UID`, `PT_GID` and `PT_SOCKTUPLE`.

Moreover, add support for numerical comparison for `PT_UID` and
`PT_GID`.

Finally, introduce some helpers letting generating execve and connect
events for testing purposes.

Signed-off-by: Leonardo Di Giovanna <leonardodigiovanna1@gmail.com>
2025-07-23 16:01:36 +02:00
Francesco Emmi 7deb173ca5 fix(sinsp_suppress): Fix comm-based suppression to cascade to child processes after /proc scan
Addresses https://github.com/falcosecurity/libs/issues/2546
Ensures that `comm-based` suppression correctly applies not only to processes matching
the configured comm values, but also to their child processes—even when those processes
were already running at the time the library is initialized.
This is achieved by having scap notify sinsp when a `/proc` scan refresh begins and ends.
While the scan is in progress, sinsp builds a temporary `TID` tree to track parent-child relationships.
Once the scan completes, sinsp performs a post-processing step that traverses the tree and suppresses
all children of any process already marked as suppressed by comm.

Signed-off-by: Francesco Emmi <francesco.as@gmail.com>
2025-07-22 09:37:28 +02:00
Leonardo Di Giovanna 9f7c159c49 feat: add support for creating events with empty parameters
Add scap API to create/encode events with empty parameters, as this is
required to easily tests events whose type is managed by the scap
converter.

Signed-off-by: Leonardo Di Giovanna <leonardodigiovanna1@gmail.com>
2025-07-21 15:32:29 +02:00
Tero Kauppinen 398f606986 fix(userspace/libsinsp): remove state handling for PPM_SYSCALL_RMDIR
The new driver does not emit `PPM_SYSCALL_RMDIR` events anymore, and
there is no longer need to handle the old version of the rmdir event.
This update removes the state handling and adds conversion rules for
the scap files.

Signed-off-by: Tero Kauppinen <tero.kauppinen@est.tech>
2025-07-21 13:02:26 +02:00
Tero Kauppinen a8d69fc285 cleanup(libsinsp): removed unused PPME_SYSCALL_MKDIR_X statements
The current implementation does no longer emit PPME_SYSCALL_MKDIR_X
events and these events are also converted to PPME_SYSCALL_MKDIR_2_X
events for older scap files. Remove unused PPME_SYSCALL_MKDIR_X
statements from the codebase.

Added the CIF_FALLBACK_TO_EMPTY flag for parameters copied from
the enter event.

Signed-off-by: Tero Kauppinen <tero.kauppinen@est.tech>
2025-07-21 13:02:26 +02:00
Tero Kauppinen c1cd8e2387 fix(testing): adjust gvisor testing for execve
https://github.com/falcosecurity/libs/pull/2544 implements conversion
of the exceve_x event which increases the number of parameters to 30.

Adjust the number of expected parameters from 27 to 30 for execve_x
events with the gvisor engine.

Signed-off-by: Tero Kauppinen <tero.kauppinen@est.tech>
2025-07-21 10:13:31 +02:00
Leonardo Di Giovanna 17a7da6ceb feat: make `PPME_SYSCALL_EXECVE_19_X` "scap converter"-managed
Let the scap converter managing all the possible variation of
`PPME_SYSCALL_EXECVE_19_X` event, adapting the userspace code to
handle possible empty values coming from the conversion.

The `PPME_SYSCALL_EXECVE_19_E` event is stil sent to sinsp, as its
`filename` parameter value is still used as a fallback if the
`trusted_exepath` parameter is not present in the exit event.

Moreover, fixes some execve and execveat tests and align comments
to the new one-line style in the kernel drivers and tests.

Signed-off-by: Leonardo Di Giovanna <leonardodigiovanna1@gmail.com>
2025-07-16 11:04:54 +02:00
Tero Kauppinen 878d24507b cleanup(libsinsp): retrieve parameters from the prlimit exit events
There is no need to store the prlimit entry event, because all
required parameters are available in the exit event.

Modify the prlimit exit event handler to retrieve information from
the exit event instead of the entry event. Added scap conversion
rules for the exit event with 5 parameters.

Signed-off-by: Tero Kauppinen <tero.kauppinen@est.tech>
2025-07-16 10:36:53 +02:00
Tero Kauppinen 92703f2b42 feat(libscap): support for old PPME_SYSCALL_PTRACE_X events
Old PPME_SYSCALL_PTRACE_X events have zero parameters and they
need conversion support. Add support for converting events
with zero parameters to events with 3 parameters.

Signed-off-by: Tero Kauppinen <tero.kauppinen@est.tech>
2025-07-15 14:28:47 +02:00
Leonardo Di Giovanna 605d8366b7 feat: fall back to empty gid instead of default one in scap converter
Signed-off-by: Leonardo Di Giovanna <leonardodigiovanna1@gmail.com>
2025-07-15 10:57:46 +02:00
Leonardo Di Giovanna d6bf8e983f feat: fall back to empty uid instead of default one in scap converter
Signed-off-by: Leonardo Di Giovanna <leonardodigiovanna1@gmail.com>
2025-07-15 10:57:46 +02:00
Leonardo Di Giovanna 109ef4fd73 feat(userspace/libscap): add scap converter "from empty" instruction
Add `C_INSTR_FROM_EMPTY` converter instruction code. This specify
to generate an empty parameter. In order to keep compatibility with
old scap files, an empty parameter has a parameter length set to 0
but it still have `len` bytes set to 0 as parameter value, where
`len` is determined from the parameter type.
E.g.: a `PT_UINT64` parameter will have the length set to 0 and its
value will occupy 8 bytes, all set to 0.

Contextually, introduce the notion of conversion flags and
particularly, the `CIF_FALLBACK_TO_EMPTY` flag: by default, if a
`C_INSTR_FROM_ENTER` instruction is encountered, and for some reason
the converter is not able to obtain a parameter from the enter event,
it pushes a default parameter; if `CIF_FALLBACK_TO_EMPTY` is
specified, it will fallback to an empty parameter.

This flag is a temporary solution to avoid handling empty parameters
in place of default ones in a single shot.

Signed-off-by: Leonardo Di Giovanna <leonardodigiovanna1@gmail.com>
2025-07-15 10:57:46 +02:00
Leonardo Di Giovanna 7f6e58baaf ci: switch `debian:buster` apt debian repository URL to snapshot URL
As buster reached its EOL, the official debian repo URL doesn't
host anymore buster packages info. For this reason, change the URLs
to point to the `20250630T203427Z` snapshot, which still contains
them.

Signed-off-by: Leonardo Di Giovanna <leonardodigiovanna1@gmail.com>
2025-07-15 09:58:46 +02:00
Leonardo Di Giovanna 0394af7612 fix(userspace/libsinsp): fix recv data buffer index
Signed-off-by: Leonardo Di Giovanna <leonardodigiovanna1@gmail.com>
2025-07-11 18:21:24 +02:00
Leonardo Di Giovanna 45952bf4c7 fix: fix scap converter `PT_UID` parameters default value
Fix the scap converter `PT_UID` parameters default value by setting it
to `UINT32_MAX`. Moreover, fix scap converter tests and sinsp parser
code to correctly account for the default value.

Signed-off-by: Leonardo Di Giovanna <leonardodigiovanna1@gmail.com>
2025-07-10 20:09:18 +02:00
Leonardo Di Giovanna e8d3b78fff fix(userspace/libsinsp): fix threadinfo ctor params forward decl
`sinsp_threadinfo_ctor_params` is declared as struct but
forward-declared as class. Fix forward declaration by declaring it
as struct.

Signed-off-by: Leonardo Di Giovanna <leonardodigiovanna1@gmail.com>
2025-07-10 14:53:17 +02:00
Leonardo Di Giovanna c658df0835 refactor: clean scap converter tests
Constify wherever possible and remove redundant qualifiers.

Signed-off-by: Leonardo Di Giovanna <leonardodigiovanna1@gmail.com>
2025-07-10 12:38:16 +02:00
Leonardo Di Giovanna 25159de410 feat: add `PPME_SYSCALL_CONNECT_E` params to `PPME_SYSCALL_CONNECT_X`
Add `PPME_SYSCALL_CONNECT_E` parameters to` PPME_SYSCALL_CONNECT_X`
event definition and align all 3 kernel drivers to it.

Add new rules to scap file converter table to convert events in old
scap files to the new layout.

Add/update connect-related drivers, scap converter and sinsp parser
tests to account the new layout.

For the moment, do not touch userspace connect "enter event"-related
logic as it requires additional work to be done on driver's tuple
generation logic.

Signed-off-by: Leonardo Di Giovanna <leonardodigiovanna1@gmail.com>
2025-07-10 12:08:17 +02:00
Angelo Puglisi a320519189 feat(userspace/libsinsp/example): print tables entries
Introduced an optional argument to -T, to output the tables entries in a
json format.

Signed-off-by: Angelo Puglisi <angelopuglisi86@gmail.com>
2025-07-09 19:16:10 +02:00
Angelo Puglisi 9494d6f0c5 feat(libsinsp/state): introduce table_input_adapter
Helper class to access subtables

Signed-off-by: Angelo Puglisi <angelopuglisi86@gmail.com>
2025-07-09 19:16:10 +02:00
Angelo Puglisi 3797e18e31 feat(libsinsp/state): typeinfo::from
Introduce typeinfo::from convenience function, to create a typeinfo
object from ss_plugin_state_type

Signed-off-by: Angelo Puglisi <angelopuglisi86@gmail.com>
2025-07-09 19:16:10 +02:00
Leonardo Di Giovanna 0f6ea5c6f2 fix(driver/bpf): fix `sched_process_exec_args` conditional definition
The current `sched_process_exec_args` raw tracepoint definition is
actually the tracepoint one; similarly, the current tracepoint
defintion is actually the raw tracepoint one. Swap them to give the
correct definition on each context.

Signed-off-by: Leonardo Di Giovanna <leonardodigiovanna1@gmail.com>
2025-07-09 17:12:10 +02:00
Tero Kauppinen 94b471887f feat(libscap/libsinsp): fcntl scap conversion
This update adds scap event conversion for the fcntl syscall exit
events and it eliminates the need to store the entry event in
libsinsp.

Signed-off-by: Tero Kauppinen <tero.kauppinen@est.tech>
2025-07-09 15:25:09 +02:00
Angelo Puglisi 4d572b21b9 chore(libsinsp): clean "detect container id" comments
Missed from https://github.com/falcosecurity/libs/pull/2207, the comment
makes no sense now. Drop it.

Signed-off-by: Angelo Puglisi <angelopuglisi86@gmail.com>
2025-07-09 14:06:08 +02:00
Super User 2a5b4c7347 fix(test/drivers): correctly handle accept socketcalls on s390x
Revise the socketcall test case for accept for modern BPF and
other drivers.

On s390x, there is no direct accept syscall and for modern BPF
accept4 is used instead.

The BPF and kernel drivers handle socketcalls internally and, thus,
can handle accept. There was only special handling for setting up
the event.  This commit also adds handling for the argument assertions.

Solving these test case failures:

````
Expected: (m_current_param) <= (m_event_header->nparams), actual: 6 vs 5
>>>>> The param id '6' is too big.

/root/git/libs/test/drivers/event_class/event_class.cpp:1457: Failure
Expected equality of these values:
  size
    Which is: 0
  expected_size
    Which is: 4
>>>>> length of the param is not correct. Param id = 6

[  FAILED  ] SyscallExit.socketcall_acceptX_INET
[  FAILED  ] SyscallExit.socketcall_acceptX_INET6
[  FAILED  ] SyscallExit.socketcall_acceptX_UNIX
[  FAILED  ] SyscallExit.socketcall_acceptX_failure
````

Signed-off-by: Hendrik Brueckner <brueckner@linux.ibm.com>
2025-07-08 15:50:01 +02:00
Super User 52ddeb4950 chore(test/libsinsp_e2e): add climits header file
Recent compilers complain about missing climits header file:

libs/test/libsinsp_e2e/sys_call_test.cpp: In lambda function:
/root/git/libs/test/libsinsp_e2e/sys_call_test.cpp:266:23: error: ‘INT_MAX’ was not declared in this scope
  266 |                 close(INT_MAX);
      |                       ^~~~~~~
libs/test/libsinsp_e2e/sys_call_test.cpp:266:23: note: ‘INT_MAX’ is defined in header ‘<climits>’; this is probably fixable by adding ‘#include <climits>’

Signed-off-by: Hendrik Brueckner <brueckner@linux.ibm.com>
2025-07-08 15:50:01 +02:00
Leonardo Di Giovanna 0752d7502a fix(drivers): align and improve `connect` kernel drivers fillers
The current bpf and kmod's `connect` fillers implementations extract
socket tuple information only if the socket file descriptor is greater
than or equal to zero: this does not ensure that the file descriptor
is valid and that the kernel has the correct amount of information
needed to build the socket tuple.

On the other side, the modern probe implementation correctly checks
the system call return value on the exit program, but doesn't try
hard enough to build the socket tuple, as it does not leverage the
sockaddr provided by the user.

Align all three implementations, checking the system call return value
and leveraging the user-provided sockaddr information to build the
socket tuple.

Signed-off-by: Leonardo Di Giovanna <leonardodigiovanna1@gmail.com>
2025-07-04 14:11:42 +02:00
Angelo Puglisi e3cb9f6941 feat(userspace/libsinsp/example): add -T option to print available tables
Signed-off-by: Angelo Puglisi <angelopuglisi86@gmail.com>
2025-07-04 13:52:42 +02:00
Leonardo Di Giovanna b917815e05 feat: add `PPME_SYSCALL_PWRITEV_E` params to `PPME_SYSCALL_PWRITEV_X`
Add `PPME_SYSCALL_PWRITEV_E` parameters to` PPME_SYSCALL_PWRITEV_X`
event definition and align all 3 kernel drivers to it.

Add new rules to scap file converter table to convert events in old
scap files to the new layout.

Add/update pwritev-related drivers, scap converter and sinsp parser
tests to account the new layout.

Signed-off-by: Leonardo Di Giovanna <leonardodigiovanna1@gmail.com>
2025-07-02 18:33:30 +02:00
Leonardo Di Giovanna e2751c656f feat!(userspace/libsinsp): remove unused sinsp ptr in tinfo factory
Remove unused sinsp pointer instance variable in
`sinsp_threadinfo_factory` component.

BREAKING CHANGE: update `sinsp_threadinfo_factory` constructor

Signed-off-by: Leonardo Di Giovanna <leonardodigiovanna1@gmail.com>
2025-07-02 17:45:30 +02:00
Leonardo Di Giovanna 70c6b3a557 test(e2e): increase `sinsp-example` init waiting interval
Recent additions increased `sinsp-example` instrumentation time in
such a way that now events can be produced by the testing framework
even before `sinsp-example` is initialized and receptive to them.
Increase `sinsp-example` initialization waiting interval to account
for this changes.

Signed-off-by: Leonardo Di Giovanna <leonardodigiovanna1@gmail.com>
Co-authored-by: Mauro Ezequiel Moltrasio <mmoltras@redhat.com>
2025-07-02 17:20:30 +02:00
Leonardo Di Giovanna 0932ac00e6 fix(driver): cast rets and fds to 32 bits before sending them in dup*
Complete the work in 3385c69812 by
aligning the dup2's and dup3's fillers returned value handling to the
other file descriptors handling. Moreover, it also align the dup's
fillers file descriptors handling.

Signed-off-by: Leonardo Di Giovanna <leonardodigiovanna1@gmail.com>
2025-07-01 12:15:21 +02:00
Leonardo Di Giovanna ed45c08a52 test(userspace/libsinsp/parsers): check fd info set by epoll_create{1}
Check that `epoll_create` and `epoll_create1` correctly set fd info
on the event and on the current thread's fd table.

Signed-off-by: Leonardo Di Giovanna <leonardodigiovanna1@gmail.com>
2025-07-01 09:50:20 +02:00
Leonardo Di Giovanna 5a3dab1ff6 feat: add `PPME_SYSCALL_WRITEV_E` params to `PPME_SYSCALL_WRITEV_X`
Add `PPME_SYSCALL_WRITEV_E` parameters to `PPME_SYSCALL_WRITEV_X`
event definition and align all 3 kernel drivers to it.

Add new rules to scap file converter table to convert events in old
scap files to the new layout.

Add/update writev-related drivers, scap converter and sinsp parser
tests to account the new layout.

Signed-off-by: Leonardo Di Giovanna <leonardodigiovanna1@gmail.com>
2025-07-01 09:40:20 +02:00
Leonardo Di Giovanna 0860ad84f2 feat: add `PPME_SYSCALL_LSEEK_E` params to `PPME_SYSCALL_LSEEK_X`
Add `PPME_SYSCALL_LSEEK_E` parameters to `PPME_SYSCALL_LSEEK_X`
event definition and align all 3 kernel drivers to it.

Add new rules to scap file converter table to convert events in old
scap files to the new layout.

Add/update lseek-related drivers, scap converter and sinsp parser
tests to account the new layout.

Signed-off-by: Leonardo Di Giovanna <leonardodigiovanna1@gmail.com>
2025-06-30 17:51:18 +02:00
Gerald Combs 7ad639c989 fix(userspace/libsinsp/example): Allow processing scaps with plugins
Select the SOURCE_PLUGIN_ENGINE only if SAVEFILE_ENGINE hasn't been
previously selected. This lets us process .scap files with a plugin.

This makes the "-s" and "-p" command line flags sensitive to order, so
document that behavior.

Signed-off-by: Gerald Combs <gerald@wireshark.org>
2025-06-30 10:53:15 +02:00
Leonardo Di Giovanna 239b981406 feat: extend `PPME_SYSCALL_{P}READV_X` with enter parameters
Add `PPME_SYSCALL_{P}READV_E` parameters to `PPME_SYSCALL_{P}READV_X`
event definition and align all 3 kernel drivers to it.

Add new rules to scap file converter table to convert events in old
scap files to the new layout.

Add/update {p}readv-related drivers, scap converter and sinsp parser
tests to account the new layout.

Signed-off-by: Leonardo Di Giovanna <leonardodigiovanna1@gmail.com>
2025-06-27 17:28:01 +02:00
Leonardo Di Giovanna 690b08091f feat: extend `PPME_SYSCALL_COPY_FILE_RANGE_X` with enter parameters
Add `PPME_SYSCALL_COPY_FILE_RANGE_E` parameters to
`PPME_SYSCALL_COPY_FILE_RANGE_X` event definition and align all 3
kernel drivers to it.

Add new rules to scap file converter table to convert events in old
scap files to the new layout.

Add/update copy_file_range-related drivers, scap converter and sinsp
parser tests to account the new layout.

Signed-off-by: Leonardo Di Giovanna <leonardodigiovanna1@gmail.com>
2025-06-27 16:12:01 +02:00
Leonardo Di Giovanna 8651bc4112 test(userpsace/libsinsp): add scap conversion test for `splice_x`
Signed-off-by: Leonardo Di Giovanna <leonardodigiovanna1@gmail.com>
2025-06-27 15:11:00 +02:00
Angelo Puglisi 2b2d80fcca chore(threadinfo): protected ctor_params
Signed-off-by: Angelo Puglisi <angelopuglisi86@gmail.com>
2025-06-27 15:04:00 +02:00
Federico Di Pierro 0014b60142 update(cmake): bumped container plugin to 0.3.1.
Signed-off-by: Federico Di Pierro <nierro92@gmail.com>
2025-06-27 14:37:00 +02:00
Leonardo Di Giovanna 254a757a09 feat: add `PPME_SYSCALL_SPLICE_E` params to `PPME_SYSCALL_SPLICE_X`
Add `PPME_SYSCALL_SPLICE_E` parameters to `PPME_SYSCALL_SPLICE_X`
event definition and align all 3 kernel drivers to it.

Add new rules to scap file converter table to convert events in old
scap files to the new layout.

Add/update splice-related drivers, scap converter and sinsp parser
tests to account the new layout.

Signed-off-by: Leonardo Di Giovanna <leonardodigiovanna1@gmail.com>
2025-06-27 14:35:00 +02:00
Leonardo Di Giovanna 269bf4fb1b feat: extend `PPME_SYSCALL_INOTIFY_INIT_X` with enter parameters
Add `PPME_SYSCALL_INOTIFY_INIT_E` parameters to
`PPME_SYSCALL_INOTIFY_INIT_X` event definition and align all 3 kernel
drivers to it.

Add new rules to scap file converter table to convert events in old
scap files to the new layout.

Add/update inotify_init-related drivers, scap converter and sinsp
parser tests to account the new layout.

Signed-off-by: Leonardo Di Giovanna <leonardodigiovanna1@gmail.com>
2025-06-27 13:26:59 +02:00
Leonardo Di Giovanna 04ca7f1813 feat: extend `PPME_SYSCALL_TIMERFD_CREATE_X` with enter parameters
Add `PPME_SYSCALL_TIMERFD_CREATE_E` parameters to
`PPME_SYSCALL_TIMERFD_CREATE_X` event definition and align all 3
kernel drivers to it.

Add new rules to scap file converter table to convert events in old
scap files to the new layout.

Add/update timerfd_create-related drivers, scap converter and sinsp
parser tests to account the new layout.

Signed-off-by: Leonardo Di Giovanna <leonardodigiovanna1@gmail.com>
2025-06-27 12:05:59 +02:00
Leonardo Di Giovanna 51c8323149 feat: extend `PPME_SYSCALL_NANOSLEEP_X` with enter parameters
Add `PPME_SYSCALL_NANOSLEEP_E` parameters to
`PPME_SYSCALL_NANOSLEEP_X` event definition and align all 3 kernel
drivers to it.

Add new rules to scap file converter table to convert events in old
scap files to the new layout.

Add/update nanosleep-related drivers, scap converter and sinsp parser
tests to account the new layout.

Signed-off-by: Leonardo Di Giovanna <leonardodigiovanna1@gmail.com>
2025-06-26 18:13:56 +02:00
Leonardo Di Giovanna cbd6fcd693 feat: extend `PPME_SYSCALL_SIGNALFD_X` with enter parameters
Add `PPME_SYSCALL_SIGNALFD_E` parameters to `PPME_SYSCALL_SIGNALFD_X`
event definition and align all 3 kernel drivers to it.

Add new rules to scap file converter table to convert events in old
scap files to the new layout.

Add/update signalfd-related drivers, scap converter and sinsp parser
tests to account the new layout.

Signed-off-by: Leonardo Di Giovanna <leonardodigiovanna1@gmail.com>
2025-06-26 16:38:55 +02:00
Leonardo Di Giovanna c4ea330ea5 feat: extend `PPME_SOCKET_ACCEPT4_6_X` with enter parameters
Add `PPME_SOCKET_ACCEPT4_6_E` parameters to `PPME_SOCKET_ACCEPT4_6_X`
event definition and align all 3 kernel drivers to it.

Add new rules to scap file converter table to convert events in old
scap files to the new layout.

Add/update accept4-related drivers, scap converter and sinsp parser
tests to account the new layout.

Signed-off-by: Leonardo Di Giovanna <leonardodigiovanna1@gmail.com>
2025-06-26 13:02:53 +02:00
Leonardo Di Giovanna b80c4b2404 feat: extend `PPME_SYSCALL_{KILL,TKILL,TGKILL}_X` with enter params
Add `PPME_SYSCALL_{KILL,TKILL,TGKILL}_E` parameters to
`PPME_SYSCALL_{KILL,TKILL,TGKILL}_X` event definition and align all 3
kernel drivers to it.

Add new rules to scap file converter table to convert events in old
scap files to the new layout.

Add/update kill/tkill/tgkill-related drivers, scap converter and sinsp
parser tests to account the new layout.

Signed-off-by: Leonardo Di Giovanna <leonardodigiovanna1@gmail.com>
2025-06-25 17:16:49 +02:00
Leonardo Di Giovanna 8d2e05bde9 feat: extend `PPME_SYSCALL_QUOTACTL_X` with enter parameters
Add `PPME_SYSCALL_QUOTACTL_E` parameters to `PPME_SYSCALL_QUOTACTL_X`
event definition and align all 3 kernel drivers to it.

Add new rules to scap file converter table to convert events in old
scap files to the new layout.

Add/update quotactl-related drivers, scap converter and sinsp parser
tests to account the new layout.

Signed-off-by: Leonardo Di Giovanna <leonardodigiovanna1@gmail.com>
2025-06-25 14:59:48 +02:00
Leonardo Di Giovanna 0487682879 feat: extend `PPME_SYSCALL_SENDFILE_X` with enter parameters
Add `PPME_SYSCALL_SENDFILE_E` parameters to `PPME_SYSCALL_SENDFILE_X`
event definition and align all 3 kernel drivers to it.

Add new rules to scap file converter table to convert events in old
scap files to the new layout.

Add/update sendfile-related drivers, scap converter and sinsp parser
tests to account the new layout.

Signed-off-by: Leonardo Di Giovanna <leonardodigiovanna1@gmail.com>
2025-06-25 12:05:48 +02:00
Angelo Puglisi dbdfd363fc feat(libsinsp): implement timed reset for proc lookup counters
- implement timed reset for proc lookup counters
- improve max process lookup log

Signed-off-by: Angelo Puglisi <angelopuglisi86@gmail.com>
2025-06-25 09:54:48 +02:00
Leonardo Di Giovanna 4adc56d7f2 fix(driver): cast fds to 32 bits before sending them in dup2 and dup3
Align dup2 and dup3 fillers implementations to other fillers
implementation by casting syscalls' file descriptor parameters to
`int32_t` before sending them.

Signed-off-by: Leonardo Di Giovanna <leonardodigiovanna1@gmail.com>
2025-06-25 09:31:48 +02:00
Angelo Puglisi e2edae006b update(event_processor)!: new build_threadinfo API
- Adapt build_threadinfo to the new sinsp_threadinfo constructor
- Have sinsp_threadinfo_ctor_params to allow forward declaration and
  avoid cyclic dependency

Signed-off-by: Angelo Puglisi <angelopuglisi86@gmail.com>
2025-06-24 18:36:48 +02:00
Leonardo Di Giovanna db53313bb9 feat: extend `PPME_SYSCALL_SIGNALFD4_X` with enter parameters
Add `PPME_SYSCALL_SIGNALFD4_E` parameters to
`PPME_SYSCALL_SIGNALFD4_X` event definition and align all 3 kernel
drivers to it.

Add new rules to scap file converter table to convert events in old
scap files to the new layout.

Add/update signalfd4-related drivers, scap converter and sinsp parser
tests to account the new layout.

Signed-off-by: Leonardo Di Giovanna <leonardodigiovanna1@gmail.com>
2025-06-24 17:41:48 +02:00
Leonardo Di Giovanna cc481dc0d7 feat: extend `PPME_SYSCALL_EVENTFD2_X` with enter parameters
Add `PPME_SYSCALL_EVENTFD2_E` parameters to `PPME_SYSCALL_EVENTFD2_X`
event definition and align all 3 kernel drivers to it.

Add new rules to scap file converter table to convert events in old
scap files to the new layout.

Add/update eventfd2-related drivers, scap converter and sinsp parser
tests to account the new layout.

Signed-off-by: Leonardo Di Giovanna <leonardodigiovanna1@gmail.com>
2025-06-24 16:26:49 +02:00
Leonardo Di Giovanna a008f7d254 feat: add `PPME_SYSCALL_UMOUNT2_E` params to `PPME_SYSCALL_UMOUNT2_X`
Add `PPME_SYSCALL_UMOUNT2_E` parameters to `PPME_SYSCALL_UMOUNT2_X`
event definition and align all 3 kernel drivers to it.

Add new rules to scap file converter table to convert events in old
scap files to the new layout.

Add/update umount2-related drivers, scap converter and sinsp parser
tests to account the new layout.

Signed-off-by: Leonardo Di Giovanna <leonardodigiovanna1@gmail.com>
2025-06-24 15:14:47 +02:00
Leonardo Di Giovanna 0e0b27948f feat: extend `PPME_SYSCALL_EPOLL_CREATE{1}_X` with enter parameters
Add `PPME_SYSCALL_EPOLL_CREATE{1}_E` parameters to
`PPME_SYSCALL_EPOLL_CREATE{1}_X` event definitions and align all 3
kernel drivers to them.

Add new rules to scap file converter table to convert events in old
scap files to the new layouts.

Add/update epoll_create{1}-related drivers, scap converter and sinsp
parser tests to account the new layout.

Signed-off-by: Leonardo Di Giovanna <leonardodigiovanna1@gmail.com>
2025-06-24 13:55:47 +02:00
Leonardo Di Giovanna d5936857e8 feat: extend `PPME_SYSCALL_MPROTECT_X` with enter parameters
Add `PPME_SYSCALL_MPROTECT_E` parameters to `PPME_SYSCALL_MPROTECT_X`
event definition and align all 3 kernel drivers to it.

Add new rules to scap file converter table to convert events in old
scap files to the new layout.

Add/update mprotect-related drivers, scap converter and sinsp parser
tests to account the new layout.

Signed-off-by: Leonardo Di Giovanna <leonardodigiovanna1@gmail.com>
2025-06-23 20:31:40 +02:00
Leonardo Di Giovanna dfa5b70ca7 feat: add `PPME_SYSCALL_SECCOMP_E` params to `PPME_SYSCALL_SECCOMP_X`
Add `PPME_SYSCALL_SECCOMP_E` parameters to `PPME_SYSCALL_SECCOMP_X`
event definition and align all 3 kernel drivers to it.

Add new rules to scap file converter table to convert events in old
scap files to the new layout.

Add/update seccomp-related drivers, scap converter and sinsp parser
tests to account the new layout.

Signed-off-by: Leonardo Di Giovanna <leonardodigiovanna1@gmail.com>
2025-06-23 17:34:39 +02:00
Leonardo Di Giovanna 88b685acf9 feat: add `PPME_SYSCALL_UNSHARE_E` params to `PPME_SYSCALL_UNSHARE_X`
Add `PPME_SYSCALL_UNSHARE_E` parameters to `PPME_SYSCALL_UNSHARE_X`
event definition and align all 3 kernel drivers to it.

Add new rules to scap file converter table to convert events in old
scap files to the new layout.

Add/update unshare-related drivers, scap converter and sinsp parser
tests to account the new layout.

Signed-off-by: Leonardo Di Giovanna <leonardodigiovanna1@gmail.com>
2025-06-23 15:31:38 +02:00
Leonardo Di Giovanna d8d7486f96 feat: add `PPME_SYSCALL_ACCESS_E` params to `PPME_SYSCALL_ACCESS_X`
Add `PPME_SYSCALL_ACCESS_E` parameters to `PPME_SYSCALL_ACCESS_X`
event definition and align all 3 kernel drivers to it.

Add new rules to scap file converter table to convert events in old
scap files to the new layout.

Add/update access-related drivers, scap converter and sinsp parser
tests to account the new layout.

Signed-off-by: Leonardo Di Giovanna <leonardodigiovanna1@gmail.com>
2025-06-23 12:34:36 +02:00
Leonardo Di Giovanna 448b5cd915 feat: add `PPME_SYSCALL_MOUNT_E` params to `PPME_SYSCALL_MOUNT_X`
Add `PPME_SYSCALL_MOUNT_E` parameters to `PPME_SYSCALL_MOUNT_X` event
definition and aligns all 3 kernel drivers to it.

Add new rules to scap file converter table to convert events in old
scap files to the new layout.

Add/update mount-related drivers, scap converter and sinsp parser
tests to account the new layout.

Signed-off-by: Leonardo Di Giovanna <leonardodigiovanna1@gmail.com>
2025-06-23 11:08:35 +02:00
Leonardo Di Giovanna e81b13ab9a feat: add `PPME_SYSCALL_PPOLL_E` params to `PPME_SYSCALL_PPOLL_X`
Add `PPME_SYSCALL_PPOLL_E` parameters to `PPME_SYSCALL_PPOLL_X` event
definition and aligns all 3 kernel drivers to it.

Add new rules to scap file converter table to convert events in old
scap files to the new layout.

Add/update ppoll-related drivers, scap converter and sinsp parser
tests to account the new layout.

Signed-off-by: Leonardo Di Giovanna <leonardodigiovanna1@gmail.com>
2025-06-20 18:16:21 +02:00
Leonardo Di Giovanna 5f249d1bf8 feat: extend `SEMCTL_X` and `SEMGET_X` with enter parameters
Add `PPME_SYSCALL_SEMCTL_E`/`PPME_SYSCALL_SEMGET_E` parameters to
`PPME_SYSCALL_SEMCTL_X`/`PPME_SYSCALL_SEMGET_X` event definitions and
aligns all 3 kernel drivers to it.

Add new rules to scap file converter table to convert events in old
scap files to the new layout.

Add/update semctl/semget-related drivers, scap converter and sinsp
parser tests to account for the new layouts.

Signed-off-by: Leonardo Di Giovanna <leonardodigiovanna1@gmail.com>
2025-06-20 13:22:17 +02:00
Leonardo Di Giovanna 2f1bd46b6f feat: add `PPME_SYSCALL_SEMOP_E` params to `PPME_SYSCALL_SEMOP_X`
Add `PPME_SYSCALL_SEMOP_E` parameters to `PPME_SYSCALL_SEMOP_X` event
definition and aligns all 3 kernel drivers to it.

Add new rules to scap file converter table to convert events in old
scap files to the new layout.

Add/update semop-related drivers, scap converter and sinsp parser
tests to account the new layout.

Signed-off-by: Leonardo Di Giovanna <leonardodigiovanna1@gmail.com>
2025-06-20 11:12:17 +02:00
Leonardo Di Giovanna da77c772d6 feat: add `PPME_SYSCALL_FLOCK_E` params to `PPME_SYSCALL_FLOCK_X`
Add `PPME_SYSCALL_FLOCK_E` parameters to `PPME_SYSCALL_FLOCK_X` event
definition and aligns all 3 kernel drivers to it.

Add new rules to scap file converter table to convert events in old
scap files to the new layout.

Add/update flock-related drivers, scap converter and sinsp parser
tests to account the new layout.

Signed-off-by: Leonardo Di Giovanna <leonardodigiovanna1@gmail.com>
2025-06-20 07:09:16 +02:00
Leonardo Di Giovanna 2c182825d0 feat: extend `PPME_SYSCALL_GETDENTS{64}_X` defs with enter params
Add `PPME_SYSCALL_GETDENTS{64}_E` parameters to
`PPME_SYSCALL_GETDENTS{64}_X` event definitions and aligns all 3
kernel drivers to it.

Add new rules to scap file converter table to convert events in old
scap files to the new layout.

Add/update getdents{64}-related drivers, scap converter and sinsp
parser tests to account for the new layouts.

Signed-off-by: Leonardo Di Giovanna <leonardodigiovanna1@gmail.com>
2025-06-19 16:48:12 +02:00
Leonardo Di Giovanna baec689e4a feat: add `PPME_SYSCALL_MUNMAP_E` params to `PPME_SYSCALL_MUNMAP_X`
Add `PPME_SYSCALL_MUNMAP_E` parameters to `PPME_SYSCALL_MUNMAP_X`
event definition and aligns all 3 kernel drivers and gvisor engine
to it.

Add new rules to scap file converter table to convert events in old
scap files to the new layout.

Add/update munmap-related drivers, scap converter and sinsp parser
tests to account the new layout.

Signed-off-by: Leonardo Di Giovanna <leonardodigiovanna1@gmail.com>
2025-06-19 15:37:12 +02:00
dependabot[bot] ebd2b8ab07 chore(deps): Bump dawidd6/action-download-artifact from 10 to 11
Bumps [dawidd6/action-download-artifact](https://github.com/dawidd6/action-download-artifact) from 10 to 11.
- [Release notes](https://github.com/dawidd6/action-download-artifact/releases)
- [Commits](4c1e823582...ac66b43f0e)

---
updated-dependencies:
- dependency-name: dawidd6/action-download-artifact
  dependency-version: '11'
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-06-19 11:43:10 +02:00
Leonardo Di Giovanna 316ffbee77 feat: add `PPME_SYSCALL_MMAP2_E` params to `PPME_SYSCALL_MMAP2_X`
Signed-off-by: Leonardo Di Giovanna <leonardodigiovanna1@gmail.com>
2025-06-18 17:58:05 +02:00
Tero Kauppinen 3c0a93c9d8 fix(driver): fix offset for the effective id
When setre*id args where moved to exit event with commit

d7d1e7c861

the offset for the effective id was not updated to
point to the correct value. Instead it was pointing to
the offset where the real id is stored.

Signed-off-by: Tero Kauppinen <tero.kauppinen@est.tech>
2025-06-18 13:01:05 +02:00
Tero Kauppinen dd6d0d23f4 new(driver): update exit events PPME_SYSCALL_SETRESUID_X with enter params
This update is part of the implementation for disabling support for
syscall enter events. It implements the following steps:

1. Adds enter parameters to the exit event
2. Adapt sinsp state to work just with exit events.
3. Create a scap-file conversion (in a dedicated scap-file converter)
   to convert ENTER events into merged EXIT ones.
4. Add some tests replaying scap-files.

for the setresuid syscall.

Signed-off-by: Tero Kauppinen <tero.kauppinen@est.tech>
2025-06-18 13:01:05 +02:00
Tero Kauppinen b788826fbe fix(driver): PT_UID is of type uint32_t
Signed-off-by: Tero Kauppinen <tero.kauppinen@est.tech>
2025-06-18 13:01:05 +02:00
dependabot[bot] f122ea93e8 chore(deps): Bump softprops/action-gh-release in the actions group
Bumps the actions group with 1 update: [softprops/action-gh-release](https://github.com/softprops/action-gh-release).


Updates `softprops/action-gh-release` from 2.2.2 to 2.3.2
- [Release notes](https://github.com/softprops/action-gh-release/releases)
- [Changelog](https://github.com/softprops/action-gh-release/blob/master/CHANGELOG.md)
- [Commits](da05d55257...72f2c25fcb)

---
updated-dependencies:
- dependency-name: softprops/action-gh-release
  dependency-version: 2.3.2
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: actions
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-06-18 11:54:05 +02:00
Tero Kauppinen 5830040d66 new(driver): update exit events PPME_SYSCALL_SETRESGID_X with enter params
This update is part of the implementation for disabling support for
syscall enter events. It implements the following steps:

1. Adds enter parameters to the exit event
2. Adapt sinsp state to work just with exit events.
3. Create a scap-file conversion (in a dedicated scap-file converter)
   to convert ENTER events into merged EXIT ones.
4. Add some tests replaying scap-files.

for the setresgid syscall.

Signed-off-by: Tero Kauppinen <tero.kauppinen@est.tech>
2025-06-18 10:26:05 +02:00
Tero Kauppinen 0220333af2 test(userspace/libsinsp/parsers): add setgid parsing test
Signed-off-by: Tero Kauppinen <tero.kauppinen@est.tech>
2025-06-18 10:26:05 +02:00
Leonardo Di Giovanna 71b46c15bf feat: add `PPME_SYSCALL_MMAP_E` params to `PPME_SYSCALL_MMAP_X`
Signed-off-by: Leonardo Di Giovanna <leonardodigiovanna1@gmail.com>
2025-06-17 18:33:45 +02:00
Leonardo Di Giovanna 0fb9d35685 fix(driver/bpf): fix `socket_x` and `socketpair_x` domain encoding
Partially revert changes introduced in
dfdd45cc2c by replacing the usage
of `socket_family_to_scap` helper with a calls to a new ad-hoc helper
for the legacy bpf probe. To avoid breaking the verifier on old kernel
version, just convert user-provided negative socket family values to
`PPM_AF_UNSPEC` and leave positive values as are. This simplified
version relies on the fact that `AF_*` and corresponding `PPM_AF_*`
macros map to the same values.

Signed-off-by: Leonardo Di Giovanna <leonardodigiovanna1@gmail.com>
2025-06-17 14:38:43 +02:00
Leonardo Di Giovanna da0f8f034b feat!: add `PPME_SYSCALL_CLOSE_E` fd param to `PPME_SYSCALL_CLOSE_X`
Extend `PPME_SYSCALL_CLOSE_X` event by adding the fd parameter to its
definition. Keep the sinsp parser logic associating the fdinfo to the
`close` enter event, but don't apply anymore any additional logic
for it: in other words, remove any code associated to the notion of
"close in progress" or "close canceled" as they have no meaning
anymore.

BREAKING CHANGE: remove `FLAGS_CLOSE_IN_PROGRESS` and
  `FLAGS_CLOSE_CANCELED` `sinsp_fdinfo::flags`

Signed-off-by: Leonardo Di Giovanna <leonardodigiovanna1@gmail.com>
2025-06-17 13:20:43 +02:00
Tero Kauppinen 8aad951bcf fix(userspace/libsinsp): remove state handling for `PPM_SYSCALL_MKDIR`
The new driver does not emit `PPM_SYSCALL_MKDIR` events anymore, and
there is no longer need to handle the old version of the mkdir event.
This update removes the state handling and adds conversion rules for
the scap files.

Signed-off-by: Tero Kauppinen <tero.kauppinen@est.tech>
2025-06-16 16:37:37 +02:00
Leonardo Di Giovanna e50c511abf update(cmake/modules): bump container plugin to 0.3.0
Signed-off-by: Leonardo Di Giovanna <leonardodigiovanna1@gmail.com>
2025-06-16 15:13:37 +02:00
Leonardo Di Giovanna 883c697208 feat: add `GETRLIMIT_E` params to `GETRLIMIT_X` and align setrlimit_x
Add `PPM_SYSCALL_GETRLIMIT_E` params to `PPM_SYSCALL_GETRLIMIT_X`
event definition and align all 3 kernel drivers to the it. Moreover,
align setrlimit_x parsing logic to getrlimit_x logic by unify the
implementation and avoiding storing setrlimit_e: this requires
adding ad-hoc conversion rules for old versions of setrlimit events
coming from old scap files.

Signed-off-by: Leonardo Di Giovanna <leonardodigiovanna1@gmail.com>
2025-06-13 14:06:17 +02:00
Federico Di Pierro 2ed1539808 fix(userspace/libsinsp): avoid clearing host users and groups tables every minute.
Since we now do not store users and groups full info inside each threadinfo,
we would lose users and groups info for host processes after 1 minute.

Signed-off-by: Federico Di Pierro <nierro92@gmail.com>
2025-06-12 14:09:11 +02:00
Leonardo Di Giovanna c0771abecc feat: add `PPME_SYSCALL_BRK_4_E` params to `PPME_SYSCALL_BRK_4_X`
Signed-off-by: Leonardo Di Giovanna <leonardodigiovanna1@gmail.com>
2025-06-12 11:45:12 +02:00
Leonardo Di Giovanna f9812eb71a fix(test/drivers): fix multiple driver tests
Signed-off-by: Leonardo Di Giovanna <leonardodigiovanna1@gmail.com>
2025-06-11 16:51:06 +02:00
Leonardo Di Giovanna dfdd45cc2c fix(driver): convert domain before sending it in socket and socketpair
Fix `domain` parameter exported value by converting it to its
corresponding scap representation in both legacy bpf and kernel
probes.

Signed-off-by: Leonardo Di Giovanna <leonardodigiovanna1@gmail.com>
2025-06-11 16:51:06 +02:00
Leonardo Di Giovanna a55e1a89e4 refactor: remove redundant zero init in aggregate initialization
Signed-off-by: Leonardo Di Giovanna <leonardodigiovanna1@gmail.com>
2025-06-11 16:51:06 +02:00
Leonardo Di Giovanna 2b78f3a3a0 ci: remove old libs clones and disable bundled libelf on ppc64 tests
Signed-off-by: Leonardo Di Giovanna <leonardodigiovanna1@gmail.com>
2025-06-11 16:51:06 +02:00
Leonardo Grasso aacbdd3dca update(cmake/modules): bump container plugin to 0.2.6
Signed-off-by: Leonardo Grasso <me@leonardograsso.com>
2025-06-11 12:19:05 +02:00
Tero Kauppinen ec4efa02f7 new(driver): update exit events PPME_SYSCALL_SETGID_X with enter params
This update is part of the implementation for disabling support for
syscall enter events. It implements the following steps:

1. Adds enter parameters to the exit event
2. Adapt sinsp state to work just with exit events.
3. Create a scap-file conversion (in a dedicated scap-file converter)
   to convert ENTER events into merged EXIT ones.
4. Add some tests replaying scap-files.

for the setgid syscall.

Signed-off-by: Tero Kauppinen <tero.kauppinen@est.tech>
2025-06-11 10:58:05 +02:00
Leonardo Di Giovanna e416bbd7bc feat: add `PPME_SYSCALL_FSTAT_E` params to `PPME_SYSCALL_FSTAT_X`
Signed-off-by: Leonardo Di Giovanna <leonardodigiovanna1@gmail.com>
2025-06-10 18:01:01 +02:00
Leonardo Di Giovanna 42182ffe0d feat: add `PPME_SYSCALL_IOCTL_3_E` params to `PPME_SYSCALL_IOCTL_3_X`
Signed-off-by: Leonardo Di Giovanna <leonardodigiovanna1@gmail.com>
2025-06-10 14:19:01 +02:00
Tero Kauppinen cc1d7fa7d4 fix(driver): remove the EF_MODIFIES_STATE flag from setpgid
Event parsing for setpgid has previously been removed with
567c2e23cc.
However, the EF_MODIFIES_STATE flag was still left in the
event definitions.

This update will remove the flag as suggested here:
https://github.com/falcosecurity/libs/issues/2427#issuecomment-2954895278

Signed-off-by: Tero Kauppinen <tero.kauppinen@est.tech>
2025-06-10 13:57:00 +02:00
dependabot[bot] 2a838b7b72 chore(deps): Bump requests from 2.32.2 to 2.32.4 in /test/e2e/tests
Bumps [requests](https://github.com/psf/requests) from 2.32.2 to 2.32.4.
- [Release notes](https://github.com/psf/requests/releases)
- [Changelog](https://github.com/psf/requests/blob/main/HISTORY.md)
- [Commits](https://github.com/psf/requests/compare/v2.32.2...v2.32.4)

---
updated-dependencies:
- dependency-name: requests
  dependency-version: 2.32.4
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-06-10 11:46:00 +02:00
Leonardo Di Giovanna cdcc76090f test(userspace/libsinsp/parsers): add poll parsing test
Signed-off-by: Leonardo Di Giovanna <leonardodigiovanna1@gmail.com>
2025-06-10 11:38:00 +02:00
Leonardo Di Giovanna eedad225ef feat: add `PPME_SYSCALL_LLSEEK_E` params to `PPME_SYSCALL_LLSEEK_X`
Signed-off-by: Leonardo Di Giovanna <leonardodigiovanna1@gmail.com>
2025-06-10 11:38:00 +02:00
Leonardo Di Giovanna fb382debc7 fix(test/drivers): ignore `SO_REUSEPORT` setsockopt syscall error
Commit https://git.kernel.org/pub/scm/linux/kernel/git/netdev/net.git/commit/?id=5b0af621c3f6
restricts `SO_REUSEPORT` socket option to inet sockets: this means
that calls to `setsockopt` setting `SO_REUSEPORT` on unix sockets are
not permitted anymore and will fail on any version backporting the
change. For this reason, still perform the call (to account for socket
belonging to inet families) but ignore its return value and hope any
subsequent call to bind is going to succeed.

Signed-off-by: Leonardo Di Giovanna <leonardodigiovanna1@gmail.com>
2025-06-10 10:28:00 +02:00
Tero Kauppinen b32c29c62c new(driver): update exit events PPME_SYSCALL_SETPGID_X with enter params
This update is part of the implementation for disabling support for
    syscall enter events. It implements the following steps:

1. Adds enter parameters to the exit event
2. Adapt sinsp state to work just with exit events.
3. Create a scap-file conversion (in a dedicated scap-file converter)
   to convert ENTER events into merged EXIT ones.
4. Add some tests replaying scap-files.

for the setpgid syscall.

Signed-off-by: Tero Kauppinen <tero.kauppinen@est.tech>
2025-06-10 10:10:59 +02:00
Angelo Puglisi 298d53de5c chore: rename sinsp_evt::init overload with data param
Improve readability by renaming `init(uint8_t* evdata, uint16_t cpuid)`
to `init_from_raw`

Signed-off-by: Angelo Puglisi <angelopuglisi86@gmail.com>
2025-06-10 09:34:00 +02:00
Angelo Puglisi f4a919b6d1 cleanup: drop unused sinsp_evt::init overloads
Signed-off-by: Angelo Puglisi <angelopuglisi86@gmail.com>
2025-06-10 09:34:00 +02:00
Angelo Puglisi 5ab41edb19 cleanup: drop sinsp_evt::init_keep_threadinfo
After commit 3f3e3fb23 we're not directly using `init_keep_threadinfo()`
anymore, so let's merge it with `init()`.

Signed-off-by: Angelo Puglisi <angelopuglisi86@gmail.com>
2025-06-10 09:34:00 +02:00
Tero Kauppinen 2d9505cda2 new(driver): update exit events PPME_SYSCALL_FCHDIR_X with enter params
This update is part of the implementation for disabling support for
syscall enter events. It implements the following steps:

1. Adds enter parameters to the exit event
2. Adapt sinsp state to work just with exit events.
3. Create a scap-file conversion (in a dedicated scap-file converter)
   to convert ENTER events into merged EXIT ones.
4. Add some tests replaying scap-files.

for the fchdir syscall.

Signed-off-by: Tero Kauppinen <tero.kauppinen@est.tech>
2025-06-09 17:08:56 +02:00
Melissa Kilby 768c2de0d2 doc(OWNERS): move incertum (Melissa Kilby) to emeritus_approvers
Signed-off-by: Melissa Kilby <melissa.kilby.oss@gmail.com>
2025-06-09 12:18:54 +02:00
Iacopo Rozzo 212d997c09 chore(libsinsp): avoid repeating getservbyname
Avoid repeating `getservbyname` call in `sinsp_filter_value_parser::string_to_rawval`.

Signed-off-by: Iacopo Rozzo <iacopo@sysdig.com>
2025-06-06 17:24:39 +02:00
Leonardo Di Giovanna 52fb26ae50 feat: add `PPME_SYSCALL_POLL_E` params to `PPME_SYSCALL_POLL_X`
Signed-off-by: Leonardo Di Giovanna <leonardodigiovanna1@gmail.com>
2025-06-06 14:12:38 +02:00
Tero Kauppinen 8a445f5c96 new(driver): update exit events PPME_SYSCALL_SETNS_X with enter params
This update is part of the implementation for disabling support for
syscall enter events. It implements the following steps:

1. Adds enter parameters to the exit event
2. Adapt sinsp state to work just with exit events.
3. Create a scap-file conversion (in a dedicated scap-file converter)
   to convert ENTER events into merged EXIT ones.
4. Add some tests replaying scap-files.

for the setns syscall.

Signed-off-by: Tero Kauppinen <tero.kauppinen@est.tech>
2025-06-06 13:02:38 +02:00
Leonardo Di Giovanna 067f3d46fe feat: add `EPOLLWAIT_E` params to `EPOLLWAIT_X`
Signed-off-by: Leonardo Di Giovanna <leonardodigiovanna1@gmail.com>
2025-06-05 17:29:31 +02:00
Federico Di Pierro 65c6326eb5 update(cmake): update tbb to v2022.1.0.
Signed-off-by: Federico Di Pierro <nierro92@gmail.com>
2025-06-05 12:52:30 +02:00
Leonardo Di Giovanna 09fc7484d3 feat: add `PPME_SYSCALL_FUTEX_E` params to `PPME_SYSCALL_FUTEX_X`
Signed-off-by: Leonardo Di Giovanna <leonardodigiovanna1@gmail.com>
2025-06-05 12:38:30 +02:00
Federico Di Pierro 8662400108 fix(userspace/libsinsp): properly return after failed assert.
Signed-off-by: Federico Di Pierro <nierro92@gmail.com>
2025-06-05 11:37:30 +02:00
Leonardo Di Giovanna 39b018fc33 feat: add `PPME_SYSCALL_EVENTFD_E` params to `PPME_SYSCALL_EVENTFD_X`
Signed-off-by: Leonardo Di Giovanna <leonardodigiovanna1@gmail.com>
2025-06-04 17:33:25 +02:00
Leonardo Di Giovanna 97d0cedec5 test(userspace/libsinsp/scap_files): add `assert_num_event_types()`
Replace helper to verify the presence of the exact number of events
of specific types inside a single scap file. Differently from the
old `assert_num_event_type()`, this helper is able to perform the
check on multiple event types at the same type: this helps
consolidating all the tests checking the number of events in all scap
file under a single test.

Signed-off-by: Leonardo Di Giovanna <leonardodigiovanna1@gmail.com>
2025-06-04 16:38:58 +02:00
Tero Kauppinen edc27e75ac new(driver): update exit events PPME_SYSCALL_MKDIR_2_X with enter params
This update is part of the implementation for disabling support for
syscall enter events. It implements the following steps:

1. Adds enter parameters to the exit event
2. Adapt sinsp state to work just with exit events.
3. Create a scap-file conversion (in a dedicated scap-file converter)
   to convert ENTER events into merged EXIT ones.
4. Add some tests replaying scap-files.

for the mkdir syscall.

Signed-off-by: Tero Kauppinen <tero.kauppinen@est.tech>
2025-06-04 16:13:24 +02:00
Leonardo Di Giovanna 364f451c08 doc(OWNERS): add `ekoops` to approvers
Signed-off-by: Leonardo Di Giovanna <41296180+ekoops@users.noreply.github.com>
2025-06-04 12:27:23 +02:00
Andrea Terzolo 84779b662d ci: update bpfvalidator action
Signed-off-by: Andrea Terzolo <andreaterzolo3@gmail.com>
2025-06-03 22:38:18 +02:00
Leonardo Di Giovanna 8b9fb7aa0d refactor(userspace/libsinsp/parsers): clean chdir handling logic
Remove unneded `CHDIR_E` event handling and clean `CHDIR_X` handling
code.

Signed-off-by: Leonardo Di Giovanna <leonardodigiovanna1@gmail.com>
2025-06-03 18:22:15 +02:00
Leonardo Di Giovanna a2eff855f6 feat: add `PPME_SOCKET_RECVMSG_E` params to `PPME_SOCKET_RECVMSG_X`
Add enter events parameters to `PPME_SOCKET_RECVMSG_X` and align all
three kernel drivers to the new definition. Contextually, align tuple
parameter extraction in all three drivers, and remove exceptions
in recvmsg driver tests accounting for the removed differences.

Signed-off-by: Leonardo Di Giovanna <leonardodigiovanna1@gmail.com>
2025-06-03 17:31:14 +02:00
Leonardo Di Giovanna 7a0eb59e9f feat: add `PPME_SOCKET_SENDMSG_E` params to `PPME_SOCKET_SENDMSG_X`
Signed-off-by: Leonardo Di Giovanna <leonardodigiovanna1@gmail.com>
2025-06-03 12:40:12 +02:00
Tero Kauppinen a7f8091378 new(driver): update exit events PPME_SYSCALL_PTRACE_X with enter params
This update is part of the implementation for disabling support for
syscall enter events. It implements the following steps:

1. Adds enter parameters to the exit event
2. Adapt sinsp state to work just with exit events.
3. Create a scap-file conversion (in a dedicated scap-file converter)
   to convert ENTER events into merged EXIT ones.
4. Add some tests replaying scap-files.

for the ptrace syscall.

Signed-off-by: Tero Kauppinen <tero.kauppinen@est.tech>
2025-06-03 09:56:11 +02:00
Federico Di Pierro deaf325786 chore(userspace/libsinsp): use a normal `map` instead of unoredered one.
This allows Falco outputs to be appended alphabetically sorted.
Also, should fix the build of Falco with old yaml-cpp versions.

Signed-off-by: Federico Di Pierro <nierro92@gmail.com>
2025-06-03 09:55:11 +02:00
Federico Di Pierro 2c12c631e7 chore(userspace/libsinsp): automatically prepend `static.` to static filters names.
Signed-off-by: Federico Di Pierro <nierro92@gmail.com>
2025-06-03 09:55:11 +02:00
Federico Di Pierro df2f1b48b1 new(userspace/libsinsp): add a `sinsp_filtercheck_static` class.
It allows people to set "static" filterchecks; for now, it only supports string ones.
The API is very simple since the filterchecks are initialized from an unordered_map<string,string>.

Added also a bunch of tests.

Signed-off-by: Federico Di Pierro <nierro92@gmail.com>
2025-06-03 09:55:11 +02:00
Federico Di Pierro 9c64fa99e9 chore(userspace/libsinsp): add small test.
Also, document m_event_info behavior.

Signed-off-by: Federico Di Pierro <nierro92@gmail.com>
2025-06-03 09:54:11 +02:00
Federico Di Pierro 4cd3f9678c cleanup(userspace/libsinsp): enable `names_to_event_set` to match async event names.
Libsinsp will now take a copy (not a reference) of scap event table,
and each plugin loaded with ASYNC cap will append its async_event_names
to the table, that will grow larger than PPM_EVENT_MAX, up to 1024 elements.

Signed-off-by: Federico Di Pierro <nierro92@gmail.com>
2025-06-03 09:54:11 +02:00
dependabot[bot] c810d471eb chore(deps): Bump dawidd6/action-download-artifact from 9 to 10
Bumps [dawidd6/action-download-artifact](https://github.com/dawidd6/action-download-artifact) from 9 to 10.
- [Release notes](https://github.com/dawidd6/action-download-artifact/releases)
- [Commits](07ab29fd4a...4c1e823582)

---
updated-dependencies:
- dependency-name: dawidd6/action-download-artifact
  dependency-version: '10'
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-06-03 09:53:11 +02:00
Grzegorz Nosek a4057823f5 fix(plugin): fix and clarify extract offsets docs/tests
The docs (and a unit test) specified `value_offsets` to be an array
of `ss_plugin_extract_value_offsets` structs, while the code in
plugin_filtercheck.cpp expected it to be a struct of arrays.
Things worked out only because we never extract multiple fields
in one go (at least in libsinsp itself).

Keep the plugin_filtercheck.cpp behavior and adapt the documentation
and tests to match.

Additionally, clarify that the offsets are counted from the start
of the event buffer (including the header).

Signed-off-by: Grzegorz Nosek <grzegorz.nosek@sysdig.com>
2025-05-30 19:02:38 +02:00
Federico Di Pierro 3540a0a923 update(ci): update zig to 0.14.1.
Signed-off-by: Federico Di Pierro <nierro92@gmail.com>
2025-05-30 19:01:39 +02:00
Melissa Kilby 414c9d9156 chore(README): refine build and testing sections
* Remove references to the localhost `test/vm` framework
* Remove overly detailed build guidelines for containers
* Ensure more precise and accurate terminology

Signed-off-by: Melissa Kilby <melissa.kilby.oss@gmail.com>
2025-05-30 16:41:38 +02:00
Melissa Kilby aa17d2472b chore(test/vm): remove localhost `test/vm` framework
* No longer maintained: This framework will not receive updates or support in the future.
* Past usefulness: It was valuable for detecting regressions in legacy drivers but has now outlived its practical use.
* Compatibility issues: It was incompatible with the Firecracker framework. VirtualBox caused interference when trying to integrate it into the CI workflow on the same test server where kernel driver tests using Firecracker were conducted.

Signed-off-by: Melissa Kilby <melissa.kilby.oss@gmail.com>
2025-05-30 16:41:38 +02:00
Leonardo Di Giovanna 1510ba4b60 fix(userspace/libscap/savefile) revert enter event freeing logic
Commit 72a6d4f39a changed the logic
governing when enter events are freed. Specifically, enter events
were freed after having performed a conversion (not a skipped
conversion) involving an exit event. With this configuration, the
following conversion would not work:

```c++
{conversion_key{EXAMPLE_E, 1},
  conversion_info().action(C_ACTION_STORE)},
{conversion_key{EXAMPLE_X, 4},
  conversion_info().action(C_ACTION_ADD_PARAMS)
    .instrs({{C_INSTR_FROM_DEFAULT, 0}})},
{conversion_key{EXAMPLE_X, 5},
  conversion_info().action(C_ACTION_ADD_PARAMS)
    .instrs({{C_INSTR_FROM_ENTER, 0}})}
```

The reason why it would not work, is that the converter would
free the stored enter event upon execution of the second conversion,
and would not find it upon execution of the third one.

Revert only the logic applied to free the enter event, which means
freeing it only if it is used by a `C_INSTR_FROM_ENTER` instruction.

Signed-off-by: Leonardo Di Giovanna <leonardodigiovanna1@gmail.com>
2025-05-30 16:34:37 +02:00
Andrea Terzolo 9c49cfa4fb ci: introduce bpfvalidator for modern bpf probe
Signed-off-by: Andrea Terzolo <andreaterzolo3@gmail.com>
2025-05-30 08:19:34 +02:00
Leonardo Di Giovanna 70cf2f5e58 feat(userpace/libscap): add printing support for `PT_DYN` parameters
Signed-off-by: Leonardo Di Giovanna <leonardodigiovanna1@gmail.com>
2025-05-30 06:54:33 +02:00
Leonardo Di Giovanna 841f0ff10e test(drivers/test_suites/syscall): add coverage for fd parameters
Add test coverage for file descriptor parameters and some spurious
ones of other kind.

Signed-off-by: Leonardo Di Giovanna <leonardodigiovanna1@gmail.com>
2025-05-29 14:37:26 +02:00
Leonardo Di Giovanna d39cae2a9e feat: add `SOCKETPAIR_E` params to `SOCKETPAIR_X`
Signed-off-by: Leonardo Di Giovanna <leonardodigiovanna1@gmail.com>
2025-05-29 14:00:26 +02:00
Leonardo Di Giovanna 3eef3f356e chore: add `/kind test` to PR template
Signed-off-by: Leonardo Di Giovanna <41296180+ekoops@users.noreply.github.com>
2025-05-27 17:55:12 +02:00
Leonardo Di Giovanna 186e522d2c feat: add `PPME_SOCKET_SHUTDOWN_E` params to `PPME_SOCKET_SHUTDOWN_X`
Signed-off-by: Leonardo Di Giovanna <leonardodigiovanna1@gmail.com>
2025-05-27 15:19:11 +02:00
Leonardo Di Giovanna 6b246b3c7d fix(drivers/modern_bpf): fix socket fd conversion error
Signed-off-by: Leonardo Di Giovanna <leonardodigiovanna1@gmail.com>
2025-05-27 12:18:11 +02:00
Leonardo Di Giovanna d259f54eec feat: add `RECVFROM_E` params to `RECVFROM_X`
Add enter events parameters to `RECVFROM_X` event definition and
align all three kernel drivers to the new definition.

Signed-off-by: Leonardo Di Giovanna <leonardodigiovanna1@gmail.com>
2025-05-27 11:30:10 +02:00
Leonardo Di Giovanna 4cde7d2104 test(sinsp/scap_files): add accept events conversion tests
Signed-off-by: Leonardo Di Giovanna <leonardodigiovanna1@gmail.com>
2025-05-27 09:34:11 +02:00
Leonardo Di Giovanna 6c7ef209a0 new: extend `SEND_X` and `SENDTO_X` with enter events parameters
Signed-off-by: Leonardo Di Giovanna <leonardodigiovanna1@gmail.com>
2025-05-26 14:14:05 +02:00
Leonardo Di Giovanna 7e1d4679d5 fix(userspace/libscap): avoid field access to possibly NULL struct
`event` can be NULL and code must not access it without guarding the
access. Fix it by avoiding the access to the event field and using
instead the `event_type` function parameter.

Signed-off-by: Leonardo Di Giovanna <leonardodigiovanna1@gmail.com>
2025-05-26 13:46:04 +02:00
Leonardo Di Giovanna 35c0655bdf feat: add `RECV_E` and `tuple` params and to `RECV_X`
Add enter events parameters to `RECV_X` event definition and align
all three kernel drivers to the new definition. Moreover, add the
`tuple` parameter to it, and align userspace logic to leverage its
presence. Finally, add the capability to leverage the content
extracted from the syscall data buffer in userspace.

Signed-off-by: Leonardo Di Giovanna <leonardodigiovanna1@gmail.com>
2025-05-26 12:46:05 +02:00
Luca Guerra 511597356f chore(build): update container plugin version
Signed-off-by: Luca Guerra <luca@guerra.sh>
2025-05-26 11:19:27 +02:00
Leonardo Di Giovanna 0485889370 fix(userspace/libscap): account unaligned access while printing params
Take into account possible misaligned accesses while printing scap
event parameters to standard output by first copying misaligned bytes
using memcpy. Contextually, factorize multiple switch case, sharing
the same handling code.

Signed-off-by: Leonardo Di Giovanna <leonardodigiovanna1@gmail.com>
2025-05-26 09:54:05 +02:00
Leonardo Di Giovanna 1e844317dd feat(userspace/libsinsp/example): add `-c` and `-A` options in example
Add two new CLI options for the modern eBPF probe in `sinsp-example`:
- `-c <num>, --cpus-for-each-buffer <num>` - allowing to select the
  number of CPUs for each ring buffer
- `-A, --all-cpus` - allowing to allocate ring buffers for all
  available CPUs (not only online ones)

Signed-off-by: Leonardo Di Giovanna <leonardodigiovanna1@gmail.com>
2025-05-22 16:39:41 +02:00
Leonardo Di Giovanna cd8f3f4dde refactor(userspace/libsinsp/examples): replace `NULL` with `nullptr`
Signed-off-by: Leonardo Di Giovanna <leonardodigiovanna1@gmail.com>
2025-05-22 16:39:41 +02:00
Tero Kauppinen d1f550a596 new(driver): update exit events PPME_SYSCALL_SETUID_X with enter params
This update is part of the proposal for disabling support for
syscall enter events. It implements the following steps:

1. Add enter parameters to the exit event.
2. Adapt sinsp state to work just with exit events.
3. Create a scap-file conversion (in a dedicated scap-file converter)
   to convert ENTER events into merged EXIT ones.
4. Add some tests replaying scap-files.

for the setuid syscall.

Signed-off-by: Tero Kauppinen <tero.kauppinen@est.tech>
2025-05-21 12:41:34 +02:00
Leonardo Di Giovanna 41f053ce22 feat(userspace/libsinsp)!: remove `sinsp::get_thread_ref()`
As the end goal is to remove unneeded duties from `sinsp`, remove
`sinsp::get_thread_ref()` API and let users directly call the
corresponding thread manager API.

BREAKING CHANGE: remove `sinsp::get_thread_ref()`

Signed-off-by: Leonardo Di Giovanna <leonardodigiovanna1@gmail.com>
2025-05-20 09:26:27 +02:00
Leonardo Di Giovanna 8a202df952 feat(userspace/libsinsp)!: make some `sinsp_parser` methods const
BREAKING CHANGE: make some `sinsp_parser` methods const

Signed-off-by: Leonardo Di Giovanna <leonardodigiovanna1@gmail.com>
2025-05-20 09:25:27 +02:00
Leonardo Di Giovanna b0abcb8097 feat(userspace/libsinsp)!: make `sinsp_parser::reset()` const
Make `sinsp_parser::reset()` const by removing the logic for
obtaining the syscall event source index and providing it directly
from sinsp.

BREAKING CHANGE: make `sinsp_parser::reset()` const

Signed-off-by: Leonardo Di Giovanna <leonardodigiovanna1@gmail.com>
2025-05-20 09:25:27 +02:00
dependabot[bot] 71e8386925 chore(deps): Bump codecov/codecov-action in the actions group
Bumps the actions group with 1 update: [codecov/codecov-action](https://github.com/codecov/codecov-action).


Updates `codecov/codecov-action` from 5.4.2 to 5.4.3
- [Release notes](https://github.com/codecov/codecov-action/releases)
- [Changelog](https://github.com/codecov/codecov-action/blob/main/CHANGELOG.md)
- [Commits](ad3126e916...18283e04ce)

---
updated-dependencies:
- dependency-name: codecov/codecov-action
  dependency-version: 5.4.3
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: actions
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-05-20 05:49:26 +02:00
Leonardo Di Giovanna 344adc24e0 refactor(libsinsp): use early return in `handle_plugin_async_event()`
Apply early return and idiom in `sinsp::handle_plugin_async_event()`
and contextually reformat comments.

Signed-off-by: Leonardo Di Giovanna <leonardodigiovanna1@gmail.com>
2025-05-19 15:24:02 +02:00
Federico Di Pierro 5a1faed158 update(cmake): bump container plugin to 0.2.3.
Signed-off-by: Federico Di Pierro <nierro92@gmail.com>
2025-05-19 10:46:00 +02:00
Luca Guerra 9c2734a643 cleanup(modern_bpf): address review comments
Signed-off-by: Luca Guerra <luca@guerra.sh>
Co-authored-by: Andrea Terzolo <andreaterzolo3@gmail.com>
2025-05-13 09:58:28 +02:00
Luca Guerra cf1c8ee89d cleanup(modern_bpf): use a regular map for shared ebpf settings
Signed-off-by: Luca Guerra <luca@guerra.sh>
2025-05-13 09:58:28 +02:00
Luca Guerra 4c2cde893b cleanup(modern_bpf): use a separate map for 64bit interesting syscalls table
Signed-off-by: Luca Guerra <luca@guerra.sh>
Co-authored-by: Kondah Mouad <kondah.mouad@gmail.com>
2025-05-13 09:58:28 +02:00
Federico Di Pierro 1983c6371f fix(driver/modern_bpf,userspace/libpman): move `g_64bit_sampling_syscall_table` and `g_ia32_to_64_table` to rodata.
Signed-off-by: Federico Di Pierro <nierro92@gmail.com>

Co-authored-by: Luca Guerra <luca@guerra.sh>
2025-05-13 09:58:28 +02:00
Federico Di Pierro 6c5659b814 fix(userspace/libscap): avoid a possible read past end of buffer.
Signed-off-by: Federico Di Pierro <nierro92@gmail.com>
2025-05-10 12:59:09 +02:00
Federico Di Pierro b1b10eff78 chore(driver/modern_bpf): limit `bpf_loop` helper to 16 iterations.
Signed-off-by: Federico Di Pierro <nierro92@gmail.com>
2025-05-09 10:11:01 +02:00
435 changed files with 28132 additions and 8790 deletions

View File

@ -20,6 +20,8 @@
> /kind failing-test
> /kind test
> /kind feature
<!--

View File

@ -8,29 +8,29 @@ runs:
shell: bash
id: store
env:
ZIG_VERSION: '0.14.0'
ZIG_VERSION: '0.14.1'
run: |
echo "zig_version=${ZIG_VERSION}" >> "$GITHUB_OUTPUT"
- name: Download zig
shell: bash
run: |
curl -L -o zig.tar.xz https://ziglang.org/download/${{ steps.store.outputs.zig_version }}/zig-linux-$(uname -m)-${{ steps.store.outputs.zig_version }}.tar.xz
curl -L -o zig.tar.xz https://ziglang.org/download/${{ steps.store.outputs.zig_version }}/zig-$(uname -m)-linux-${{ steps.store.outputs.zig_version }}.tar.xz
tar -xvf zig.tar.xz
cat > zig-linux-$(uname -m)-${{ steps.store.outputs.zig_version }}/zig-cc <<EOF
cat > zig-$(uname -m)-linux-${{ steps.store.outputs.zig_version }}/zig-cc <<EOF
#!/bin/bash
exec zig cc -target $(uname -m)-linux-gnu.2.17 -mcpu=baseline "\$@"
EOF
chmod +x zig-linux-$(uname -m)-${{ steps.store.outputs.zig_version }}/zig-cc
chmod +x zig-$(uname -m)-linux-${{ steps.store.outputs.zig_version }}/zig-cc
cat > zig-linux-$(uname -m)-${{ steps.store.outputs.zig_version }}/zig-c++ <<EOF
cat > zig-$(uname -m)-linux-${{ steps.store.outputs.zig_version }}/zig-c++ <<EOF
#!/bin/bash
exec zig c++ -target $(uname -m)-linux-gnu.2.17 -mcpu=baseline "\$@"
EOF
chmod +x zig-linux-$(uname -m)-${{ steps.store.outputs.zig_version }}/zig-c++
chmod +x zig-$(uname -m)-linux-${{ steps.store.outputs.zig_version }}/zig-c++
mv zig-linux-$(uname -m)-${{ steps.store.outputs.zig_version }}/ zig
mv zig-$(uname -m)-linux-${{ steps.store.outputs.zig_version }}/ zig
- name: Setup zig
shell: bash
@ -40,4 +40,4 @@ runs:
echo "CC=zig-cc" >> $GITHUB_ENV
echo "CXX=zig-c++" >> $GITHUB_ENV
echo "AR=zig ar" >> $GITHUB_ENV
echo "RANLIB=zig ranlib" >> $GITHUB_ENV
echo "RANLIB=zig ranlib" >> $GITHUB_ENV

View File

@ -36,6 +36,8 @@ jobs:
steps:
- name: Install deps ⛓️
run: |
# Use 20250630T203427Z debian apt snapshot as it still contains support for buster.
printf "deb http://snapshot.debian.org/archive/debian/20250630T203427Z buster main\ndeb http://snapshot.debian.org/archive/debian-security/20250630T203427Z buster/updates main\ndeb http://snapshot.debian.org/archive/debian/20250630T203427Z buster-updates main" > /etc/apt/sources.list
apt update && apt install -y --no-install-recommends curl ca-certificates build-essential git clang llvm pkg-config autoconf automake libtool libelf-dev wget libtbb-dev libjq-dev libjsoncpp-dev protobuf-compiler libgtest-dev libprotobuf-dev linux-headers-${{ matrix.arch }}
- name: Install a recent version of CMake ⛓️

View File

@ -39,7 +39,7 @@ jobs:
# This job run all engine tests and scap-open
test-scap:
name: test-scap-${{ matrix.arch }} 😆 (bundled_deps)
runs-on: ${{ (matrix.arch == 'arm64' && 'ubuntu-22.04-arm') || 'ubuntu-22.04' }}
runs-on: ${{ (matrix.arch == 'arm64' && 'ubuntu-24.04-arm') || 'ubuntu-24.04' }}
needs: paths-filter
strategy:
matrix:
@ -102,6 +102,13 @@ jobs:
cd build
sudo ./test/libscap/libscap_test
- name: Validate scap-open with modern bpf
if: needs.paths-filter.outputs.driver == 'true' || needs.paths-filter.outputs.libscap == 'true' || needs.paths-filter.outputs.libpman == 'true'
uses: Andreagit97/bpfvalidator@v0.3.0
with:
args: |
--config=$GITHUB_WORKSPACE/driver/modern_bpf/bpfvalidator_config.yaml --cmd="$GITHUB_WORKSPACE/build/libscap/examples/01-open/scap-open --modern_bpf --num_events 10"
test-drivers:
name: test-drivers-${{ matrix.arch }} 😇 (bundled_deps)
runs-on: ${{ (matrix.arch == 'arm64' && 'ubuntu-22.04-arm') || 'ubuntu-22.04' }}
@ -180,10 +187,12 @@ jobs:
command_timeout: 60m
script: |
sudo dnf install -y bpftool ca-certificates cmake make automake gcc gcc-c++ kernel-devel clang git pkg-config autoconf automake libbpf-devel
# Remove, if present, any libs clone created by a previous job run.
rm -rf libs
git clone -b $GIT_BRANCH $GITHUB_SERVER_URL/$GITHUB_REPOSITORY.git libs
cd libs
mkdir -p build
cd build && cmake -DBUILD_WARNINGS_AS_ERRORS=On -DUSE_BUNDLED_DEPS=ON -DENABLE_DRIVERS_TESTS=ON -DBUILD_LIBSCAP_MODERN_BPF=ON -DMODERN_BPF_DEBUG_MODE=ON -DBUILD_BPF=True -DBUILD_LIBSCAP_GVISOR=OFF ../
cd build && cmake -DBUILD_WARNINGS_AS_ERRORS=On -DUSE_BUNDLED_DEPS=ON -DENABLE_DRIVERS_TESTS=ON -DBUILD_LIBSCAP_MODERN_BPF=ON -DMODERN_BPF_DEBUG_MODE=ON -DBUILD_BPF=True -DBUILD_LIBSCAP_GVISOR=OFF -DUSE_BUNDLED_LIBELF=OFF ../
make drivers_test driver bpf -j6
sudo ./test/drivers/drivers_test -m
rc_modern=$?

View File

@ -27,7 +27,7 @@ jobs:
uses: ./.github/actions/composite-perf
- name: Download latest master report
uses: dawidd6/action-download-artifact@07ab29fd4a977ae4d2b275087cf67563dfdf0295 # v9
uses: dawidd6/action-download-artifact@ac66b43f0e6a346234dd65d4d0c8fbb31cb316e5 # v11
with:
branch: master
event: push

View File

@ -98,7 +98,7 @@ jobs:
echo "#### Release Manager @${{ github.event.release.author.login }}" >> release-body.md
- name: Release
uses: softprops/action-gh-release@da05d552573ad5aba039eaac05058a918a7bf631 # v2.2.2
uses: softprops/action-gh-release@72f2c25fcb47643c292f7107632f7a47c1df5cd8 # v2.3.2
with:
body_path: ./release-body.md
tag_name: ${{ github.event.release.tag_name }}
@ -203,7 +203,7 @@ jobs:
echo "#### Release Manager @${{ github.event.release.author.login }}" >> release-body.md
- name: Release
uses: softprops/action-gh-release@da05d552573ad5aba039eaac05058a918a7bf631 # v2.2.2
uses: softprops/action-gh-release@72f2c25fcb47643c292f7107632f7a47c1df5cd8 # v2.3.2
with:
body_path: ./release-body.md
tag_name: ${{ github.event.release.tag_name }}

View File

@ -37,7 +37,7 @@ jobs:
gcovr --xml -o ./libsinsp.coverage.xml
- name: Upload to codecov
uses: codecov/codecov-action@ad3126e916f78f00edff4ed0317cf185271ccc2d # v5.4.2
uses: codecov/codecov-action@18283e04ce6e62d37312384ff67231eb8fd56d24 # v5.4.3
with:
fail_ci_if_error: true
files: ./libsinsp.coverage.xml

View File

@ -62,7 +62,6 @@ option(ENABLE_DRIVERS_TESTS "Enable driver tests (bpf, kernel module, modern bpf
option(ENABLE_LIBSCAP_TESTS "Enable libscap unit tests" OFF)
option(ENABLE_LIBSINSP_E2E_TESTS "Enable libsinsp e2e tests" OFF)
option(BUILD_SHARED_LIBS "Build libscap and libsinsp as shared libraries" OFF)
option(ENABLE_VM_TESTS "Enable driver sanity tests" OFF)
option(USE_ASAN "Build with AddressSanitizer" OFF)
option(USE_UBSAN "Build with UndefinedBehaviorSanitizer" OFF)
option(USE_TSAN "Build with ThreadSanitizer" OFF)
@ -145,10 +144,6 @@ if(CREATE_TEST_TARGETS)
add_subdirectory(test/libsinsp_e2e/resources)
endif()
if(ENABLE_VM_TESTS)
add_subdirectory(test/vm)
endif()
endif()
option(ENABLE_BENCHMARKS "Enable Benchmarks" OFF)

3
OWNERS
View File

@ -7,10 +7,11 @@ approvers:
- molter73
- lucaguerra
- jasondellaluce
- incertum
- ekoops
reviewers:
- hbrueckner
emeritus_approvers:
- fntlnz
- leodido
- ldegio
- incertum

View File

@ -11,7 +11,7 @@ This repository contains **libsinsp**, **libscap**, the **kernel module** and th
These components are at the foundation of [Falco](https://github.com/falcosecurity/falco) and other projects that work with the same kind of data.
This component stack mainly operates on syscall events. We monitor syscalls using either a kernel module or an eBPF probe, which we call *drivers*. On top of the drivers, `libscap` manages the data capture process, while `libsinsp` enriches the data, and provides a rich set of API to consume the data. Furthermore, these two libraries also implement a [plugin](https://github.com/falcosecurity/plugins) framework that extends this stack to potentially any other data sources. For further details, please refer to the [official documentation](https://falco.org/docs/).
This component stack mainly operates on syscall events. We monitor syscalls using either a kernel module or an eBPF probe, which we call *drivers*. On top of the drivers, `libscap` manages the data capture process, while `libsinsp` enriches the data, and provides a rich set of API to consume the data. Furthermore, these two libraries also implement a [plugin](https://github.com/falcosecurity/plugins) framework that extends this stack to potentially any other data sources. For further details, please refer to Falco's [official documentation](https://falco.org/docs/).
An image is worth a thousand words, they say:
@ -104,13 +104,13 @@ If you are building this project outside of a Git working directory, or if you w
<details>
<summary>Expand Build Instructions</summary>
For your convenience, we have included the instructions for building the `libs` modules here, in addition to the information available in the [official documentation](https://falco.org/docs/install-operate/source/). These instructions are designed for building and testing `libs` on your own Linux development machine. However, if you intend to adopt CI or build within containers, there are additional considerations to take into account. The official [website]((https://falco.org/docs/install-operate/source/)) continually extends its guidance in this respect.
For your convenience, we have included the instructions for building the `libs` modules here, in addition to the information available in Falco's [official documentation](https://falco.org/docs/install-operate/source/). These instructions are designed for building and testing `libs` on your own Linux development machine. However, if you intend to adopt CI or build within containers, there are additional considerations to take into account. The official [website]((https://falco.org/docs/install-operate/source/)) continually extends its guidance in this respect.
The project utilizes the `cmake` build system, and the key `make` targets are as follows:
* `driver` -> build the kmod
* `bpf` -> build the eBPF probe
* `scap` -> build libscap (`modern_bpf` driver will be bundled into `scap` if enabled)
* `bpf` -> build the legacy `ebpf` probe
* `scap` -> build libscap (`modern_ebpf` driver will be bundled into `scap` if enabled)
* `sinsp` -> build libsinsp (depends upon `scap` target)
* `scap-open` -> build a small example binary for `libscap` to test the drivers (dependent on `scap`)
* `sinsp-example` -> build a small example binary for `libsinsp` to test the drivers and/or `libsinsp` functionality (dependent on `scap` and `sinsp`)
@ -135,7 +135,7 @@ make sinsp
### Build userspace using system deps
To build using the system deps instead, first, make sure to have all the needed packages installed. Refer to the [official documentation](https://falco.org/docs/install-operate/source/).
To build using the system deps instead, first, make sure to have all the needed packages installed. Refer to Falco's [official documentation](https://falco.org/docs/install-operate/source/).
```bash
cmake -DUSE_BUNDLED_DEPS=OFF ../;
@ -146,29 +146,27 @@ make sinsp
### Build driver - kmod
To build the kmod driver, you need your kernel headers installed. Check out the [official documentation](https://falco.org/docs/install-operate/source/).
To build the kmod driver, you need your kernel headers installed. Check out Falco's [official documentation](https://falco.org/docs/install-operate/source/).
```bash
make driver
# Verify the kmod object code was created, uses `.ko` extension.
# Verify the kmod binary object file was created, uses `.ko` extension.
ls -l driver/src/scap.ko;
```
### Build driver - eBPF probe
To build the eBPF probe, you need `clang` and `llvm` packages and you also need your kernel headers installed. Check out the [official documentation](https://falco.org/docs/install-operate/source/).
To build the eBPF probe, you need `clang` and `llvm` packages and you also need your kernel headers installed. Check out Falco's [official documentation](https://falco.org/docs/install-operate/source/).
```bash
cmake -DBUILD_BPF=ON ../;
make bpf
# Verify the eBPF object code was created, uses `.o` extension.
# Verify the eBPF bytecode file was created, uses `.o` extension.
ls -l driver/bpf/probe.o;
```
>__WARNING__: **clang-7** is the oldest supported version to build our BPF probe.
Initial guidance for CI and building within containers: To build either the kmod or eBPF probe in a container, you will need to make the extracted kernel headers available. The [test/vm](test/vm/) directory contains example [scripts](test/vm/scripts/compile_drivers.sh) demonstrating how to pass them to the `make` command using the argument `KERNELDIR=${EXTRACTED_KERNEL_HEADERS_DIR}`. You can also use the [falcosecurity/driverkit](https://github.com/falcosecurity/driverkit) or explore the scripts within the driverkit repository. The mentioned resources also provide candidate builder containers.
### Build driver - modern eBPF probe
To build the modern eBPF probe, further prerequisites are necessary:
@ -193,13 +191,13 @@ To build the modern eBPF probe, further prerequisites are necessary:
> __NOTE:__ These are not the requirements to use the modern BPF probe, but rather for building it from source.
Regarding the previously discussed bpf drivers, they create a kernel-specific object code (`driver/bpf/probe.o`) for your machine's kernel release (`uname -r`). This object code is then used as an argument for testing with `scap-open` and `sinsp-example` binaries.
Regarding the previously discussed legacy eBPF driver, it generates kernel-specific bytecode (`driver/bpf/probe.o`) tailored to your machine's kernel release (`uname -r`). The location of the bytecode file can then be passed as an argument for testing with the `scap-open` and `sinsp-example` binaries.
However, the modern BPF driver operates differently. It doesn't require kernel headers, and its build isn't tied to your kernel release. This is enabled by the CO-RE (Compile Once - Run Everywhere) feature of the modern BPF driver. CO-RE allows the driver to work on kernels with backported BTF (BPF Type Format) support or kernel versions >= 5.8.
However, the modern eBPF driver build process doesn't require kernel headers, and it isn't tied to your kernel release. This is enabled by the CO-RE (Compile Once - Run Everywhere) feature of the modern eBPF driver.
To comprehend how the driver understands kernel data structures without knowledge of the kernel it runs on, there's no black magic involved. We maintain a [vmlinux.h](driver/modern_bpf/definitions/vmlinux.h) file in our project containing all necessary kernel data structure definitions. Additionally, we sometimes rely on macros or functions typically found in system header files, which we redefine in [struct_flavors.h](driver/modern_bpf/definitions/struct_flavors.h).
CO-RE allows the driver to work on kernels with backported BTF (BPF Type Format) support or kernel versions >= 5.8. The way the driver interprets kernel data structures without direct knowledge of the running kernel is not magic — it leverages predefined type information and BTF-based relocations. We maintain a [vmlinux.h](driver/modern_bpf/definitions/vmlinux.h) file containing essential kernel data structure definitions, allowing the eBPF program to reference fields dynamically. Additionally, for cases where macros or functions from system headers are required, we redefine them in [struct_flavors.h](driver/modern_bpf/definitions/struct_flavors.h). Combined with CO-RE (Compile Once, Run Everywhere), this enables the driver to remain portable across different kernel versions.
That being said, the modern BPF driver still produces an object file, which you can create using the target below. Nevertheless, we ultimately include it in `scap` regardless. Hence, when modern BPF is enabled, building `scap` will already cover this step for you.
The modern eBPF driver build process produces an eBPF header skeleton file using `bpftool`. The skeleton file is a C header file that embeds the compiled eBPF program as bytecode.
```bash
cmake \
@ -207,13 +205,15 @@ cmake \
-DBUILD_LIBSCAP_MODERN_BPF=ON ../;
make ProbeSkeleton
# Verify the modern eBPF object code / final composed header file including all `.o` modern_bpf files was created, uses `.h` extension.
# Verify the modern eBPF bytecode / final composed header file including all `.o` modern_ebpf files was created, uses `.h` extension.
ls -l skel_dir/bpf_probe.skel.h;
# Now includes skel_dir/bpf_probe.skel.h in `scap` during the linking process.
make scap
```
Initial guidance for CI and building within containers: The Falco Project, for instance, compiles the final Falco userspace binary within older centos7 [falco-builder](https://falco.org/docs/install-operate/source/#build-using-falco-builder-container) containers with bundled dependencies. This ensures compatibility across supported systems, mainly due to GLIBC versions and other intricacies. However, you won't be able to compile the modern BPF driver on such old systems or builder containers. One solution is to build `skel_dir/bpf_probe.skel.h` in a more recent builder container. For example, you can refer to this [container](test/vm/containers/ubuntu2310.Dockerfile) as a guide. Subsequently, you can provide the modern BPF header file as an artifact to `scap` during building in an older builder container. As an illustrative example, we use `/tmp/skel-dir` containing the `bpf_probe.skel.h` file.
Since modern eBPF is included in `scap`, running `make scap` automatically covers the `make ProbeSkeleton` build step.
You can also split the build process and specify the directory containing the `bpf_probe.skel.h` file.
```bash
cmake \
@ -243,7 +243,7 @@ This repository includes convenient test example binaries for both `scap` and `s
When developing new features, you would run either one depending on what you're working on, in order to test and validate your changes.
> __NOTE:__ When you're working on driver development, it can be quite useful to make use of the kernel's built-in `printk` functionality. However, for the traditional bpf driver, you'll need to uncomment a line in the [bpf Makefile](driver/bpf/Makefile) first and use a dedicated build flag `BPF_DEBUG`. For modern BPF, use the build flag `MODERN_BPF_DEBUG_MODE`. Any logs generated by `bpf_printk()` will be written to `/sys/kernel/debug/tracing/trace_pipe`. Just make sure you have the right permissions set up for this.
> __NOTE:__ When you're working on driver development, it can be quite useful to make use of the kernel's built-in `printk` functionality. However, for the traditional bpf driver, you'll need to uncomment a line in the [bpf Makefile](driver/bpf/Makefile) first and use a dedicated build flag `BPF_DEBUG`. For modern eBPF, use the build flag `MODERN_BPF_DEBUG_MODE`. Any logs generated by `bpf_printk()` will be written to `/sys/kernel/debug/tracing/trace_pipe`. Just make sure you have the right permissions set up for this.
Here's an example of a `cmake` command that will enable everything you need for all tests and components. By default, the following flags are disabled, with the exception of `USE_BUNDLED_DEPS` and `CREATE_TEST_TARGETS` (they are enabled by default).
@ -259,8 +259,7 @@ cmake \
-DCREATE_TEST_TARGETS=ON \
-DENABLE_LIBSCAP_TESTS=ON \
-DENABLE_DRIVERS_TESTS=ON \
-DENABLE_LIBSINSP_E2E_TESTS=ON \
-DENABLE_VM_TESTS=ON ../;
-DENABLE_LIBSINSP_E2E_TESTS=ON ../;
```
> __NOTE:__ The `ENABLE_LIBSINSP_E2E_TESTS` flag enables the new e2e tests for libsinsp. Please keep in mind these tests are currently in heavy development and need some extra steps (see in the section below) to run correctly.
@ -302,9 +301,10 @@ sudo ./test/drivers/drivers_test -m;
The tests mentioned below expand beyond the scope of "unit tests". In this context as well, we are dedicated to making sure they run smoothly on your `localhost` for pre-PR testing, to the best of our ability:
- [test/e2e](test/e2e) - enforced by our CI
- [test/vm](test/vm) - our CI includes comparable tests, but it employs a distinct framework. For current status reports on Falco drivers kernel testing, please visit this [page](https://falcosecurity.github.io/libs/).
As mentioned earlier, The Falco Project's `libs` repository includes numerous CI-powered checks. For the most current information, please refer to the CI definitions under the [workflows](.github/workflows/) directory.
For current status reports on the CI powered Falco drivers kernel testing, please visit this [page](https://falcosecurity.github.io/libs/).
In general, The Falco Project's `libs` repository includes numerous CI-powered checks. For the most current information, please refer to the CI definitions under the [workflows](.github/workflows/) directory.
### [EXPERIMENTAL] Run libsinsp e2e tests

View File

@ -22,13 +22,13 @@ set(CONTAINER_LIBRARY
)
if(NOT CONTAINER_VERSION)
set(CONTAINER_VERSION "0.2.2")
set(CONTAINER_VERSION "0.3.4")
endif()
if(NOT CONTAINER_HASH)
if(${CMAKE_HOST_SYSTEM_PROCESSOR} STREQUAL "x86_64")
set(CONTAINER_HASH "e770975d06bad6c593ea43dd56364afdb9314a47924f29198ba3ab184e6aca5d")
set(CONTAINER_HASH "658f96c4b4a56d1bf945a788d60571076f808ae1bcc877c4ba3625b0fd752d8d")
else() # arm64
set(CONTAINER_HASH "52fa2687152eb89c7e54a7b96bd1b08e78fdef15b98c989322f8eab7debcbf35")
set(CONTAINER_HASH "34a153aca0164843a169193aba092a3063b24bca9ef80fd4f1d1f1919aba3bde")
endif()
endif()
if(NOT TARGET container_plugin)

View File

@ -58,9 +58,9 @@ else()
if(NOT TARGET tbb)
message(STATUS "Using bundled tbb in '${TBB_SRC}'")
set(TBB_SRC_URL "https://github.com/oneapi-src/oneTBB/archive/refs/tags/v2022.0.0.tar.gz")
set(TBB_SRC_URL "https://github.com/oneapi-src/oneTBB/archive/refs/tags/v2022.1.0.tar.gz")
set(TBB_SRC_URL_HASH
"SHA256=e8e89c9c345415b17b30a2db3095ba9d47647611662073f7fbf54ad48b7f3c2a"
"SHA256=ed067603ece0dc832d2881ba5c516625ac2522c665d95f767ef6304e34f961b5"
)
set(TBB_FLAGS "")
if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
@ -89,6 +89,8 @@ else()
-DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}
-DCMAKE_C_COMPILER=${CMAKE_C_COMPILER}
-DEMSCRIPTEN=${TBB_EMSCRIPTEN}
-DTBB_FILE_TRIM=Off
-DTBB_INSTALL=Off
BUILD_BYPRODUCTS ${TBB_LIB}
INSTALL_COMMAND ""
)
@ -110,6 +112,8 @@ else()
-DTBB_OUTPUT_DIR_BASE=lib
-DCMAKE_CXX_FLAGS="${TBB_FLAGS}"
-DCMAKE_POSITION_INDEPENDENT_CODE=${ENABLE_PIC}
-DTBB_FILE_TRIM=Off
-DTBB_INSTALL=Off
BUILD_BYPRODUCTS ${TBB_LIB}
INSTALL_COMMAND ""
)
@ -129,6 +133,8 @@ else()
-DTBB_OUTPUT_DIR_BASE=lib
-DCMAKE_CXX_FLAGS="${TBB_FLAGS}"
-DCMAKE_POSITION_INDEPENDENT_CODE=${ENABLE_PIC}
-DTBB_FILE_TRIM=Off
-DTBB_INSTALL=Off
BUILD_BYPRODUCTS ${TBB_LIB}
INSTALL_COMMAND ""
)

View File

@ -1 +1 @@
8.0.3
8.0.4

View File

@ -1 +1 @@
3.6.1
3.69.0

View File

@ -1407,3 +1407,15 @@ static __always_inline pid_t bpf_push_pgid(struct filler_data *data, struct task
}
#endif
/* Legacy-probe-specific replacement for `socket_family_to_scap` helper. As encoding the socket
* family using the `socket_family_to_scap` helper breaks the verifier on old kernel versions, just
* send `PPM_AF_UNSPEC` if the user-provided socket family is negative, and leave it as is
* otherwise. This solution relies on the fact that `AF_*` and corresponding `PPM_AF_*` macros map
* to the same values. */
static __always_inline uint8_t bpf_socket_family_to_scap(int8_t family) {
if(family < 0) {
family = PPM_AF_UNSPEC;
}
return (uint8_t)family;
}

File diff suppressed because it is too large Load Diff

View File

@ -143,6 +143,16 @@ struct sys_stash_args {
#ifdef CAPTURE_SCHED_PROC_EXEC
#ifndef BPF_SUPPORTS_RAW_TRACEPOINTS
struct sched_process_exec_args {
unsigned short common_type;
unsigned char common_flags;
unsigned char common_preempt_count;
int common_pid;
__u32 filename; // This is actually defined as "__data_loc char[] filename;".
pid_t pid;
pid_t old_pid;
};
#else
/* TP_PROTO(struct task_struct *p, pid_t old_pid, struct linux_binprm *bprm)
* Taken from `/include/trace/events/sched.h`
*/
@ -151,16 +161,6 @@ struct sched_process_exec_args {
pid_t old_pid;
struct linux_binprm *bprm;
};
#else
struct sched_process_exec_args {
unsigned short common_type;
unsigned char common_flags;
unsigned char common_preempt_count;
int common_pid;
int filename;
pid_t pid;
pid_t old_pid;
};
#endif /* BPF_SUPPORTS_RAW_TRACEPOINTS */
#endif /* CAPTURE_SCHED_PROC_EXEC */

File diff suppressed because it is too large Load Diff

View File

@ -45,13 +45,13 @@ const struct ppm_event_entry g_ppm_events[PPM_EVENT_MAX] = {
[PPME_SOCKET_SEND_E] = {FILLER_REF(sys_send_e)},
[PPME_SOCKET_SEND_X] = {FILLER_REF(sys_send_x)},
[PPME_SOCKET_SENDTO_E] = {FILLER_REF(sys_sendto_e)},
[PPME_SOCKET_SENDTO_X] = {FILLER_REF(sys_send_x)},
[PPME_SOCKET_SENDTO_X] = {FILLER_REF(sys_sendto_x)},
[PPME_SOCKET_RECV_E] = {FILLER_REF(sys_autofill), 2, APT_SOCK, {{0}, {2}}},
[PPME_SOCKET_RECV_X] = {FILLER_REF(sys_recv_x)},
[PPME_SOCKET_RECVFROM_E] = {FILLER_REF(sys_recvfrom_e)},
[PPME_SOCKET_RECVFROM_X] = {FILLER_REF(sys_recvfrom_x)},
[PPME_SOCKET_SHUTDOWN_E] = {FILLER_REF(sys_shutdown_e)},
[PPME_SOCKET_SHUTDOWN_X] = {FILLER_REF(sys_single_x)},
[PPME_SOCKET_SHUTDOWN_X] = {FILLER_REF(sys_shutdown_x)},
[PPME_SOCKET_GETSOCKNAME_E] = {FILLER_REF(sys_empty)},
[PPME_SOCKET_GETSOCKNAME_X] = {FILLER_REF(sys_empty)},
[PPME_SOCKET_GETPEERNAME_E] = {FILLER_REF(sys_empty)},
@ -75,15 +75,15 @@ const struct ppm_event_entry g_ppm_events[PPM_EVENT_MAX] = {
[PPME_SYSCALL_PIPE_E] = {FILLER_REF(sys_empty)},
[PPME_SYSCALL_PIPE_X] = {FILLER_REF(sys_pipe_x)},
[PPME_SYSCALL_EVENTFD_E] = {FILLER_REF(sys_eventfd_e)},
[PPME_SYSCALL_EVENTFD_X] = {FILLER_REF(sys_single_x)},
[PPME_SYSCALL_EVENTFD_X] = {FILLER_REF(sys_eventfd_x)},
[PPME_SYSCALL_FUTEX_E] = {FILLER_REF(sys_futex_e)},
[PPME_SYSCALL_FUTEX_X] = {FILLER_REF(sys_single_x)},
[PPME_SYSCALL_FUTEX_X] = {FILLER_REF(sys_futex_x)},
[PPME_SYSCALL_STAT_E] = {FILLER_REF(sys_empty)},
[PPME_SYSCALL_STAT_X] = {FILLER_REF(sys_autofill), 2, APT_REG, {{AF_ID_RETVAL}, {0}}},
[PPME_SYSCALL_LSTAT_E] = {FILLER_REF(sys_empty)},
[PPME_SYSCALL_LSTAT_X] = {FILLER_REF(sys_autofill), 2, APT_REG, {{AF_ID_RETVAL}, {0}}},
[PPME_SYSCALL_FSTAT_E] = {FILLER_REF(sys_fstat_e)},
[PPME_SYSCALL_FSTAT_X] = {FILLER_REF(sys_single_x)},
[PPME_SYSCALL_FSTAT_X] = {FILLER_REF(sys_fstat_x)},
[PPME_SYSCALL_STAT64_E] = {FILLER_REF(sys_empty)},
[PPME_SYSCALL_STAT64_X] = {FILLER_REF(sys_autofill), 2, APT_REG, {{AF_ID_RETVAL}, {0}}},
[PPME_SYSCALL_LSTAT64_E] = {FILLER_REF(sys_empty)},
@ -91,7 +91,7 @@ const struct ppm_event_entry g_ppm_events[PPM_EVENT_MAX] = {
[PPME_SYSCALL_FSTAT64_E] = {FILLER_REF(sys_single)},
[PPME_SYSCALL_FSTAT64_X] = {FILLER_REF(sys_single_x)},
[PPME_SYSCALL_EPOLLWAIT_E] = {FILLER_REF(sys_autofill), 1, APT_REG, {{2}}},
[PPME_SYSCALL_EPOLLWAIT_X] = {FILLER_REF(sys_single_x)},
[PPME_SYSCALL_EPOLLWAIT_X] = {FILLER_REF(sys_epoll_wait_x)},
[PPME_SYSCALL_POLL_E] = {FILLER_REF(sys_poll_e)},
[PPME_SYSCALL_POLL_X] = {FILLER_REF(sys_poll_x)},
[PPME_SYSCALL_SELECT_E] = {FILLER_REF(sys_empty)},
@ -99,7 +99,7 @@ const struct ppm_event_entry g_ppm_events[PPM_EVENT_MAX] = {
[PPME_SYSCALL_NEWSELECT_E] = {FILLER_REF(sys_empty)},
[PPME_SYSCALL_NEWSELECT_X] = {FILLER_REF(sys_single_x)},
[PPME_SYSCALL_LSEEK_E] = {FILLER_REF(sys_lseek_e)},
[PPME_SYSCALL_LSEEK_X] = {FILLER_REF(sys_single_x)},
[PPME_SYSCALL_LSEEK_X] = {FILLER_REF(sys_lseek_x)},
[PPME_SYSCALL_LLSEEK_E] = {FILLER_REF(sys_llseek_e)},
[PPME_SYSCALL_LLSEEK_X] = {FILLER_REF(sys_single_x)},
[PPME_SYSCALL_GETCWD_E] = {FILLER_REF(sys_empty)},
@ -117,13 +117,13 @@ const struct ppm_event_entry g_ppm_events[PPM_EVENT_MAX] = {
[PPME_SYSCALL_PWRITE_E] = {FILLER_REF(sys_pwrite64_e)},
[PPME_SYSCALL_PWRITE_X] = {FILLER_REF(sys_pwrite64_x)},
[PPME_SYSCALL_READV_E] = {FILLER_REF(sys_readv_e)},
[PPME_SYSCALL_READV_X] = {FILLER_REF(sys_readv_preadv_x)},
[PPME_SYSCALL_READV_X] = {FILLER_REF(sys_readv_x)},
[PPME_SYSCALL_WRITEV_E] = {FILLER_REF(sys_writev_e)},
[PPME_SYSCALL_WRITEV_X] = {FILLER_REF(sys_writev_pwritev_x)},
[PPME_SYSCALL_WRITEV_X] = {FILLER_REF(sys_writev_x)},
[PPME_SYSCALL_PREADV_E] = {FILLER_REF(sys_preadv_e)},
[PPME_SYSCALL_PREADV_X] = {FILLER_REF(sys_readv_preadv_x)},
[PPME_SYSCALL_PREADV_X] = {FILLER_REF(sys_preadv_x)},
[PPME_SYSCALL_PWRITEV_E] = {FILLER_REF(sys_pwritev_e)},
[PPME_SYSCALL_PWRITEV_X] = {FILLER_REF(sys_writev_pwritev_x)},
[PPME_SYSCALL_PWRITEV_X] = {FILLER_REF(sys_pwritev_x)},
[PPME_SYSCALL_DUP_1_E] = {FILLER_REF(sys_dup_e)},
[PPME_SYSCALL_DUP_1_X] = {FILLER_REF(sys_dup_x)},
[PPME_SYSCALL_DUP2_E] = {FILLER_REF(sys_dup2_e)},
@ -131,22 +131,22 @@ const struct ppm_event_entry g_ppm_events[PPM_EVENT_MAX] = {
[PPME_SYSCALL_DUP3_E] = {FILLER_REF(sys_dup3_e)},
[PPME_SYSCALL_DUP3_X] = {FILLER_REF(sys_dup3_x)},
[PPME_SYSCALL_SIGNALFD_E] = {FILLER_REF(sys_signalfd_e)},
[PPME_SYSCALL_SIGNALFD_X] = {FILLER_REF(sys_single_x)},
[PPME_SYSCALL_SIGNALFD_X] = {FILLER_REF(sys_signalfd_x)},
[PPME_SYSCALL_KILL_E] = {FILLER_REF(sys_autofill), 2, APT_REG, {{0}, {1}}},
[PPME_SYSCALL_KILL_X] = {FILLER_REF(sys_single_x)},
[PPME_SYSCALL_KILL_X] = {FILLER_REF(sys_kill_x)},
[PPME_SYSCALL_TKILL_E] = {FILLER_REF(sys_autofill), 2, APT_REG, {{0}, {1}}},
[PPME_SYSCALL_TKILL_X] = {FILLER_REF(sys_single_x)},
[PPME_SYSCALL_TKILL_X] = {FILLER_REF(sys_tkill_x)},
[PPME_SYSCALL_TGKILL_E] = {FILLER_REF(sys_autofill), 3, APT_REG, {{0}, {1}, {2}}},
[PPME_SYSCALL_TGKILL_X] = {FILLER_REF(sys_single_x)},
[PPME_SYSCALL_TGKILL_X] = {FILLER_REF(sys_tgkill_x)},
[PPME_SYSCALL_NANOSLEEP_E] = {FILLER_REF(sys_nanosleep_e)},
[PPME_SYSCALL_NANOSLEEP_X] = {FILLER_REF(sys_single_x)},
[PPME_SYSCALL_NANOSLEEP_X] = {FILLER_REF(sys_nanosleep_x)},
[PPME_SYSCALL_TIMERFD_CREATE_E] = {FILLER_REF(sys_autofill),
2,
APT_REG,
{{AF_ID_USEDEFAULT, 0}, {AF_ID_USEDEFAULT, 0}}},
[PPME_SYSCALL_TIMERFD_CREATE_X] = {FILLER_REF(sys_single_x)},
[PPME_SYSCALL_TIMERFD_CREATE_X] = {FILLER_REF(sys_timerfd_create_x)},
[PPME_SYSCALL_INOTIFY_INIT_E] = {FILLER_REF(sys_inotify_init_e)},
[PPME_SYSCALL_INOTIFY_INIT_X] = {FILLER_REF(sys_single_x)},
[PPME_SYSCALL_INOTIFY_INIT_X] = {FILLER_REF(sys_inotify_init_x)},
[PPME_SYSCALL_GETRLIMIT_E] = {FILLER_REF(sys_getrlimit_setrlimit_e)},
[PPME_SYSCALL_GETRLIMIT_X] = {FILLER_REF(sys_getrlimit_x)},
[PPME_SYSCALL_SETRLIMIT_E] = {FILLER_REF(sys_getrlimit_setrlimit_e)},
@ -161,19 +161,19 @@ const struct ppm_event_entry g_ppm_events[PPM_EVENT_MAX] = {
[PPME_SCHEDSWITCH_6_E] = {FILLER_REF(sched_switch_e)},
#endif
[PPME_SYSCALL_BRK_4_E] = {FILLER_REF(sys_autofill), 1, APT_REG, {{0}}},
[PPME_SYSCALL_BRK_4_X] = {FILLER_REF(sys_brk_munmap_mmap_x)},
[PPME_SYSCALL_BRK_4_X] = {FILLER_REF(sys_brk_x)},
[PPME_SYSCALL_MMAP_E] = {FILLER_REF(sys_mmap_e)},
[PPME_SYSCALL_MMAP_X] = {FILLER_REF(sys_brk_munmap_mmap_x)},
[PPME_SYSCALL_MMAP_X] = {FILLER_REF(sys_mmap_x)},
[PPME_SYSCALL_MMAP2_E] = {FILLER_REF(sys_mmap_e)},
[PPME_SYSCALL_MMAP2_X] = {FILLER_REF(sys_brk_munmap_mmap_x)},
[PPME_SYSCALL_MMAP2_X] = {FILLER_REF(sys_mmap2_x)},
[PPME_SYSCALL_MUNMAP_E] = {FILLER_REF(sys_autofill), 2, APT_REG, {{0}, {1}}},
[PPME_SYSCALL_MUNMAP_X] = {FILLER_REF(sys_brk_munmap_mmap_x)},
[PPME_SYSCALL_MUNMAP_X] = {FILLER_REF(sys_munmap_x)},
[PPME_SYSCALL_SPLICE_E] = {FILLER_REF(sys_splice_e)},
[PPME_SYSCALL_SPLICE_X] = {FILLER_REF(sys_autofill), 1, APT_REG, {{AF_ID_RETVAL}}},
[PPME_SYSCALL_SPLICE_X] = {FILLER_REF(sys_splice_x)},
[PPME_SYSCALL_PTRACE_E] = {FILLER_REF(sys_ptrace_e)},
[PPME_SYSCALL_PTRACE_X] = {FILLER_REF(sys_ptrace_x)},
[PPME_SYSCALL_IOCTL_3_E] = {FILLER_REF(sys_ioctl_e)},
[PPME_SYSCALL_IOCTL_3_X] = {FILLER_REF(sys_single_x)},
[PPME_SYSCALL_IOCTL_3_X] = {FILLER_REF(sys_ioctl_x)},
[PPME_SYSCALL_RENAME_E] = {FILLER_REF(sys_empty)},
[PPME_SYSCALL_RENAME_X] = {FILLER_REF(sys_autofill),
3,
@ -193,14 +193,14 @@ const struct ppm_event_entry g_ppm_events[PPM_EVENT_MAX] = {
[PPME_SYSCALL_QUOTACTL_E] = {FILLER_REF(sys_quotactl_e)},
[PPME_SYSCALL_QUOTACTL_X] = {FILLER_REF(sys_quotactl_x)},
[PPME_SYSCALL_SETRESUID_E] = {FILLER_REF(sys_autofill), 3, APT_REG, {{0}, {1}, {2}}},
[PPME_SYSCALL_SETRESUID_X] = {FILLER_REF(sys_autofill), 1, APT_REG, {{AF_ID_RETVAL}}},
[PPME_SYSCALL_SETRESUID_X] = {FILLER_REF(sys_setresuid_x)},
[PPME_SYSCALL_SETRESGID_E] = {FILLER_REF(sys_autofill), 3, APT_REG, {{0}, {1}, {2}}},
[PPME_SYSCALL_SETRESGID_X] = {FILLER_REF(sys_autofill), 1, APT_REG, {{AF_ID_RETVAL}}},
[PPME_SYSCALL_SETRESGID_X] = {FILLER_REF(sys_setresgid_x)},
[PPME_SCAPEVENT_E] = {FILLER_REF(sys_scapevent_e)},
[PPME_SYSCALL_SETUID_E] = {FILLER_REF(sys_autofill), 1, APT_REG, {{0}}},
[PPME_SYSCALL_SETUID_X] = {FILLER_REF(sys_autofill), 1, APT_REG, {{AF_ID_RETVAL}}},
[PPME_SYSCALL_SETUID_X] = {FILLER_REF(sys_setuid_x)},
[PPME_SYSCALL_SETGID_E] = {FILLER_REF(sys_autofill), 1, APT_REG, {{0}}},
[PPME_SYSCALL_SETGID_X] = {FILLER_REF(sys_autofill), 1, APT_REG, {{AF_ID_RETVAL}}},
[PPME_SYSCALL_SETGID_X] = {FILLER_REF(sys_setgid_x)},
[PPME_SYSCALL_GETUID_E] = {FILLER_REF(sys_empty)},
[PPME_SYSCALL_GETUID_X] = {FILLER_REF(sys_autofill), 1, APT_REG, {{AF_ID_RETVAL}}},
[PPME_SYSCALL_GETEUID_E] = {FILLER_REF(sys_empty)},
@ -223,43 +223,43 @@ const struct ppm_event_entry g_ppm_events[PPM_EVENT_MAX] = {
[PPME_SIGNALDELIVER_E] = {FILLER_REF(sys_signaldeliver_e)},
#endif
[PPME_SYSCALL_GETDENTS_E] = {FILLER_REF(sys_getdents_e)},
[PPME_SYSCALL_GETDENTS_X] = {FILLER_REF(sys_single_x)},
[PPME_SYSCALL_GETDENTS_X] = {FILLER_REF(sys_getdents_x)},
[PPME_SYSCALL_GETDENTS64_E] = {FILLER_REF(sys_getdents64_e)},
[PPME_SYSCALL_GETDENTS64_X] = {FILLER_REF(sys_single_x)},
[PPME_SYSCALL_GETDENTS64_X] = {FILLER_REF(sys_getdents64_x)},
[PPME_SYSCALL_SETNS_E] = {FILLER_REF(sys_setns_e)},
[PPME_SYSCALL_SETNS_X] = {FILLER_REF(sys_autofill), 1, APT_REG, {{AF_ID_RETVAL}}},
[PPME_SYSCALL_SETNS_X] = {FILLER_REF(sys_setns_x)},
[PPME_SYSCALL_FLOCK_E] = {FILLER_REF(sys_flock_e)},
[PPME_SYSCALL_FLOCK_X] = {FILLER_REF(sys_autofill), 1, APT_REG, {{AF_ID_RETVAL}}},
[PPME_SYSCALL_FLOCK_X] = {FILLER_REF(sys_flock_x)},
[PPME_CPU_HOTPLUG_E] = {FILLER_REF(cpu_hotplug_e)},
[PPME_SOCKET_ACCEPT_5_E] = {FILLER_REF(sys_empty)},
[PPME_SOCKET_ACCEPT_5_X] = {FILLER_REF(sys_accept_x)},
[PPME_SYSCALL_SEMOP_E] = {FILLER_REF(sys_single)},
[PPME_SYSCALL_SEMOP_X] = {FILLER_REF(sys_semop_x)},
[PPME_SYSCALL_SEMCTL_E] = {FILLER_REF(sys_semctl_e)},
[PPME_SYSCALL_SEMCTL_X] = {FILLER_REF(sys_single_x)},
[PPME_SYSCALL_SEMCTL_X] = {FILLER_REF(sys_semctl_x)},
[PPME_SYSCALL_PPOLL_E] = {FILLER_REF(sys_ppoll_e)},
[PPME_SYSCALL_PPOLL_X] = {FILLER_REF(sys_poll_x)}, /* exit same for poll() and ppoll() */
[PPME_SYSCALL_PPOLL_X] = {FILLER_REF(sys_ppoll_x)},
[PPME_SYSCALL_MOUNT_E] = {FILLER_REF(sys_mount_e)},
[PPME_SYSCALL_MOUNT_X] = {FILLER_REF(sys_autofill),
[PPME_SYSCALL_MOUNT_X] = {FILLER_REF(sys_mount_x),
4,
APT_REG,
{{AF_ID_RETVAL}, {0}, {1}, {2}}},
[PPME_SYSCALL_SEMGET_E] = {FILLER_REF(sys_semget_e)},
[PPME_SYSCALL_SEMGET_X] = {FILLER_REF(sys_single_x)},
[PPME_SYSCALL_SEMGET_X] = {FILLER_REF(sys_semget_x)},
[PPME_SYSCALL_ACCESS_E] = {FILLER_REF(sys_access_e)},
[PPME_SYSCALL_ACCESS_X] = {FILLER_REF(sys_autofill), 2, APT_REG, {{AF_ID_RETVAL}, {0}}},
[PPME_SYSCALL_ACCESS_X] = {FILLER_REF(sys_access_x)},
[PPME_SYSCALL_CHROOT_E] = {FILLER_REF(sys_empty)},
[PPME_SYSCALL_CHROOT_X] = {FILLER_REF(sys_autofill), 2, APT_REG, {{AF_ID_RETVAL}, {0}}},
[PPME_SYSCALL_SETSID_E] = {FILLER_REF(sys_empty)},
[PPME_SYSCALL_SETSID_X] = {FILLER_REF(sys_autofill), 1, APT_REG, {{AF_ID_RETVAL}}},
[PPME_SYSCALL_SETPGID_E] = {FILLER_REF(sys_setpgid_e)},
[PPME_SYSCALL_SETPGID_X] = {FILLER_REF(sys_autofill), 1, APT_REG, {{AF_ID_RETVAL}}},
[PPME_SYSCALL_SETPGID_X] = {FILLER_REF(sys_setpgid_x)},
[PPME_SYSCALL_MKDIR_2_E] = {FILLER_REF(sys_mkdir_e)},
[PPME_SYSCALL_MKDIR_2_X] = {FILLER_REF(sys_autofill), 2, APT_REG, {{AF_ID_RETVAL}, {0}}},
[PPME_SYSCALL_MKDIR_2_X] = {FILLER_REF(sys_mkdir_x)},
[PPME_SYSCALL_RMDIR_2_E] = {FILLER_REF(sys_empty)},
[PPME_SYSCALL_RMDIR_2_X] = {FILLER_REF(sys_autofill), 2, APT_REG, {{AF_ID_RETVAL}, {0}}},
[PPME_SYSCALL_UNSHARE_E] = {FILLER_REF(sys_unshare_e)},
[PPME_SYSCALL_UNSHARE_X] = {FILLER_REF(sys_autofill), 1, APT_REG, {{AF_ID_RETVAL}}},
[PPME_SYSCALL_UNSHARE_X] = {FILLER_REF(sys_unshare_x)},
[PPME_SYSCALL_EXECVE_19_E] = {FILLER_REF(sys_execve_e)},
[PPME_SYSCALL_EXECVE_19_X] = {FILLER_REF(proc_startupdate)},
#ifdef CAPTURE_PAGE_FAULTS
@ -268,7 +268,7 @@ const struct ppm_event_entry g_ppm_events[PPM_EVENT_MAX] = {
[PPME_SYSCALL_BPF_2_E] = {FILLER_REF(sys_bpf_e)},
[PPME_SYSCALL_BPF_2_X] = {FILLER_REF(sys_bpf_x)},
[PPME_SYSCALL_SECCOMP_E] = {FILLER_REF(sys_autofill), 2, APT_REG, {{0}, {1}}},
[PPME_SYSCALL_SECCOMP_X] = {FILLER_REF(sys_autofill), 1, APT_REG, {{AF_ID_RETVAL}}},
[PPME_SYSCALL_SECCOMP_X] = {FILLER_REF(sys_seccomp_x)},
[PPME_SYSCALL_UNLINK_2_E] = {FILLER_REF(sys_empty)},
[PPME_SYSCALL_UNLINK_2_X] = {FILLER_REF(sys_autofill), 2, APT_REG, {{AF_ID_RETVAL}, {0}}},
[PPME_SYSCALL_UNLINKAT_2_E] = {FILLER_REF(sys_empty)},
@ -344,7 +344,7 @@ const struct ppm_event_entry g_ppm_events[PPM_EVENT_MAX] = {
[PPME_SYSCALL_UMOUNT_1_E] = {FILLER_REF(sys_empty)},
[PPME_SYSCALL_UMOUNT_1_X] = {FILLER_REF(sys_umount_x)},
[PPME_SOCKET_ACCEPT4_6_E] = {FILLER_REF(sys_accept4_e)},
[PPME_SOCKET_ACCEPT4_6_X] = {FILLER_REF(sys_accept_x)},
[PPME_SOCKET_ACCEPT4_6_X] = {FILLER_REF(sys_accept4_x)},
[PPME_SYSCALL_UMOUNT2_E] = {FILLER_REF(sys_umount2_e)},
[PPME_SYSCALL_UMOUNT2_X] = {FILLER_REF(sys_umount2_x)},
[PPME_SYSCALL_PIPE2_E] = {FILLER_REF(sys_empty)},

View File

@ -0,0 +1,8 @@
parallel: 2
kernel_versions:
- v5.10.237
- v5.15.184
- v6.1.140
- v6.6.92
- v6.12.30
- v6.15

View File

@ -24,7 +24,7 @@
#define SYSCALL_E_SIZE HEADER_LEN + sizeof(uint16_t) * 2 + PARAM_LEN * 2
#define SYSCALL_X_SIZE HEADER_LEN + sizeof(uint16_t) + PARAM_LEN
#define CLOSE_E_SIZE HEADER_LEN + sizeof(int64_t) + PARAM_LEN
#define CLOSE_X_SIZE HEADER_LEN + sizeof(int64_t) + PARAM_LEN
#define CLOSE_X_SIZE HEADER_LEN + sizeof(int64_t) * 2 + PARAM_LEN * 2
#define READ_E_SIZE HEADER_LEN + sizeof(int64_t) + sizeof(uint32_t) + PARAM_LEN * 2
#define WRITE_E_SIZE HEADER_LEN + sizeof(int64_t) + sizeof(uint32_t) + PARAM_LEN * 2
#define SOCKET_E_SIZE HEADER_LEN + sizeof(uint32_t) * 3 + PARAM_LEN * 3
@ -36,13 +36,13 @@
#define RECV_E_SIZE HEADER_LEN + sizeof(int64_t) + sizeof(uint32_t) + PARAM_LEN * 2
#define RECVFROM_E_SIZE HEADER_LEN + sizeof(int64_t) + sizeof(uint32_t) + PARAM_LEN * 2
#define SHUTDOWN_E_SIZE HEADER_LEN + sizeof(int64_t) + sizeof(uint8_t) + PARAM_LEN * 2
#define SHUTDOWN_X_SIZE HEADER_LEN + sizeof(int64_t) + PARAM_LEN
#define SHUTDOWN_X_SIZE HEADER_LEN + sizeof(int64_t) * 2 + sizeof(uint8_t) + PARAM_LEN * 3
#define GETSOCKNAME_E_SIZE HEADER_LEN
#define GETSOCKNAME_X_SIZE HEADER_LEN
#define GETPEERNAME_E_SIZE HEADER_LEN
#define GETPEERNAME_X_SIZE HEADER_LEN
#define SOCKETPAIR_E_SIZE HEADER_LEN + sizeof(uint32_t) * 3 + PARAM_LEN * 3
#define SOCKETPAIR_X_SIZE HEADER_LEN + sizeof(int64_t) * 3 + sizeof(uint64_t) * 2 + PARAM_LEN * 5
#define SOCKETPAIR_X_SIZE HEADER_LEN + sizeof(int64_t) * 3 + sizeof(uint32_t) * 3 + sizeof(uint64_t) * 2 + PARAM_LEN * 8
#define SETSOCKOPT_E_SIZE HEADER_LEN
#define GETSOCKOPT_E_SIZE HEADER_LEN
#define SENDMMSG_E_SIZE HEADER_LEN
@ -51,29 +51,29 @@
#define PIPE_E_SIZE HEADER_LEN
#define PIPE_X_SIZE HEADER_LEN + sizeof(int64_t) * 3 + sizeof(uint64_t) + PARAM_LEN * 4
#define EVENTFD_E_SIZE HEADER_LEN + sizeof(uint32_t) + sizeof(uint64_t) + PARAM_LEN * 2
#define EVENTFD_X_SIZE HEADER_LEN + sizeof(int64_t) + PARAM_LEN
#define EVENTFD_X_SIZE HEADER_LEN + sizeof(int64_t) + sizeof(uint32_t) + sizeof(uint64_t) + PARAM_LEN * 3
#define FUTEX_E_SIZE HEADER_LEN + sizeof(uint16_t) + sizeof(uint64_t) * 2 + PARAM_LEN * 3
#define FUTEX_X_SIZE HEADER_LEN + sizeof(int64_t) + PARAM_LEN
#define FUTEX_X_SIZE HEADER_LEN + sizeof(int64_t) + sizeof(uint16_t) + sizeof(uint64_t) * 2 + PARAM_LEN * 4
#define STAT_E_SIZE HEADER_LEN
#define LSTAT_E_SIZE HEADER_LEN
#define FSTAT_E_SIZE HEADER_LEN + sizeof(int64_t) + PARAM_LEN
#define FSTAT_X_SIZE HEADER_LEN + sizeof(int64_t) + PARAM_LEN
#define FSTAT_X_SIZE HEADER_LEN + sizeof(int64_t) * 2 + PARAM_LEN * 2
#define STAT64_E_SIZE HEADER_LEN
#define LSTAT64_E_SIZE HEADER_LEN
#define FSTAT64_E_SIZE HEADER_LEN + sizeof(int64_t) + PARAM_LEN
#define FSTAT64_X_SIZE HEADER_LEN + sizeof(int64_t) + PARAM_LEN
#define EPOLL_WAIT_E_SIZE HEADER_LEN + sizeof(int64_t) + PARAM_LEN
#define EPOLL_WAIT_X_SIZE HEADER_LEN + sizeof(int64_t) + PARAM_LEN
#define EPOLL_WAIT_X_SIZE HEADER_LEN + sizeof(int64_t) * 2 + PARAM_LEN * 2
#define SELECT_E_SIZE HEADER_LEN
#define SELECT_X_SIZE HEADER_LEN + sizeof(int64_t) + PARAM_LEN
#define LSEEK_E_SIZE HEADER_LEN + sizeof(int64_t) + sizeof(uint64_t) + sizeof(uint8_t) + PARAM_LEN * 3
#define LSEEK_X_SIZE HEADER_LEN + sizeof(int64_t) + PARAM_LEN
#define LSEEK_X_SIZE HEADER_LEN + sizeof(int64_t) * 2 + sizeof(uint64_t) + sizeof(uint8_t) + PARAM_LEN * 4
#define LLSEEK_E_SIZE HEADER_LEN + sizeof(int64_t) + sizeof(uint64_t) + sizeof(uint8_t) + PARAM_LEN * 3
#define LLSEEK_X_SIZE HEADER_LEN + sizeof(int64_t) + PARAM_LEN
#define LLSEEK_X_SIZE HEADER_LEN + sizeof(int64_t) * 2 + sizeof(uint64_t) + sizeof(uint8_t) + PARAM_LEN * 4
#define GETCWD_E_SIZE HEADER_LEN
#define CHDIR_E_SIZE HEADER_LEN
#define FCHDIR_E_SIZE HEADER_LEN + sizeof(int64_t) + PARAM_LEN
#define FCHDIR_X_SIZE HEADER_LEN + sizeof(int64_t) + PARAM_LEN
#define FCHDIR_X_SIZE HEADER_LEN + sizeof(int64_t) * 2 + PARAM_LEN * 2
#define PREAD_E_SIZE HEADER_LEN + sizeof(int64_t) + sizeof(uint32_t) + sizeof(uint64_t) + PARAM_LEN * 3
#define PWRITE_E_SIZE HEADER_LEN + sizeof(int64_t) + sizeof(uint32_t) + sizeof(uint64_t) + PARAM_LEN * 3
#define READV_E_SIZE HEADER_LEN + sizeof(int64_t) + PARAM_LEN
@ -81,21 +81,21 @@
#define PREADV_E_SIZE HEADER_LEN + sizeof(int64_t) + sizeof(uint64_t) + PARAM_LEN * 2
#define PWRITEV_E_SIZE HEADER_LEN + sizeof(int64_t) + sizeof(uint32_t) + sizeof(uint64_t) + PARAM_LEN * 3
#define SIGNALFD_E_SIZE HEADER_LEN + sizeof(int64_t) + sizeof(uint32_t) + sizeof(uint8_t) + PARAM_LEN * 3
#define SIGNALFD_X_SIZE HEADER_LEN + sizeof(int64_t) + PARAM_LEN
#define SIGNALFD_X_SIZE HEADER_LEN + sizeof(int64_t) * 2 + sizeof(uint32_t) + sizeof(uint8_t) + PARAM_LEN * 4
#define KILL_E_SIZE HEADER_LEN + sizeof(int64_t) + sizeof(uint8_t) + PARAM_LEN * 2
#define KILL_X_SIZE HEADER_LEN + sizeof(int64_t) + PARAM_LEN
#define KILL_X_SIZE HEADER_LEN + sizeof(int64_t) * 2 + sizeof(uint8_t) + PARAM_LEN * 3
#define TKILL_E_SIZE HEADER_LEN + sizeof(int64_t) + sizeof(uint8_t) + PARAM_LEN * 2
#define TKILL_X_SIZE HEADER_LEN + sizeof(int64_t) + PARAM_LEN
#define TKILL_X_SIZE HEADER_LEN + sizeof(int64_t) * 2 + sizeof(uint8_t) + PARAM_LEN * 3
#define TGKILL_E_SIZE HEADER_LEN + sizeof(int64_t) * 2 + sizeof(uint8_t) + PARAM_LEN * 3
#define TGKILL_X_SIZE HEADER_LEN + sizeof(int64_t) + PARAM_LEN
#define TGKILL_X_SIZE HEADER_LEN + sizeof(int64_t) * 3 + sizeof(uint8_t) + PARAM_LEN * 4
#define NANOSLEEP_E_SIZE HEADER_LEN + sizeof(uint64_t) + PARAM_LEN
#define NANOSLEEP_X_SIZE HEADER_LEN + sizeof(int64_t) + PARAM_LEN
#define NANOSLEEP_X_SIZE HEADER_LEN + sizeof(int64_t) + sizeof(uint64_t) + PARAM_LEN * 2
#define TIMERFD_CREATE_E_SIZE HEADER_LEN + sizeof(uint8_t) * 2 + PARAM_LEN * 2
#define TIMERFD_CREATE_X_SIZE HEADER_LEN + sizeof(int64_t) + PARAM_LEN
#define TIMERFD_CREATE_X_SIZE HEADER_LEN + sizeof(int64_t) + sizeof(uint8_t) * 2 + PARAM_LEN * 3
#define INOTIFY_INIT_E_SIZE HEADER_LEN + sizeof(uint8_t) + PARAM_LEN
#define INOTIFY_INIT_X_SIZE HEADER_LEN + sizeof(int64_t) + PARAM_LEN
#define INOTIFY_INIT_X_SIZE HEADER_LEN + sizeof(int64_t) + sizeof(uint8_t) + PARAM_LEN * 2
#define GETRLIMIT_E_SIZE HEADER_LEN + sizeof(uint8_t) + PARAM_LEN
#define GETRLIMIT_X_SIZE HEADER_LEN + sizeof(int64_t) * 3 + PARAM_LEN * 3
#define GETRLIMIT_X_SIZE HEADER_LEN + sizeof(int64_t) * 3 + sizeof(uint8_t) + PARAM_LEN * 4
#define SETRLIMIT_E_SIZE HEADER_LEN + sizeof(uint8_t) + PARAM_LEN
#define SETRLIMIT_X_SIZE HEADER_LEN + sizeof(int64_t) * 3 + sizeof(uint8_t) + PARAM_LEN * 4
#define PRLIMIT_E_SIZE HEADER_LEN + sizeof(int64_t) + sizeof(uint8_t) + PARAM_LEN * 2
@ -106,36 +106,36 @@
#define FCNTL_X_SIZE HEADER_LEN + sizeof(int64_t) * 2 + sizeof(uint8_t) + PARAM_LEN * 3
#define SWITCH_SIZE HEADER_LEN + sizeof(int64_t) + sizeof(uint32_t) * 3 + sizeof(uint64_t) * 2 + PARAM_LEN * 6
#define BRK_E_SIZE HEADER_LEN + sizeof(uint64_t) + PARAM_LEN
#define BRK_X_SIZE HEADER_LEN + sizeof(uint32_t) * 3 + sizeof(uint64_t) + PARAM_LEN * 4
#define BRK_X_SIZE HEADER_LEN + sizeof(uint32_t) * 3 + sizeof(uint64_t) * 2 + PARAM_LEN * 5
#define MMAP_E_SIZE HEADER_LEN + sizeof(int64_t) + sizeof(uint32_t) * 2 + sizeof(uint64_t) * 3 + PARAM_LEN * 6
#define MMAP_X_SIZE HEADER_LEN + sizeof(int64_t) + sizeof(uint32_t) * 3 + PARAM_LEN * 4
#define MMAP_X_SIZE HEADER_LEN + sizeof(int64_t) * 2 + sizeof(uint32_t) * 5 + sizeof(uint64_t) * 3 + PARAM_LEN * 10
#define MMAP2_E_SIZE HEADER_LEN + sizeof(int64_t) + sizeof(uint32_t) * 2 + sizeof(uint64_t) * 3 + PARAM_LEN * 6
#define MMAP2_X_SIZE HEADER_LEN + sizeof(int64_t) + sizeof(uint32_t) * 3 + PARAM_LEN * 4
#define MMAP2_X_SIZE HEADER_LEN + sizeof(int64_t) * 2 + sizeof(uint32_t) * 5 + sizeof(uint64_t) * 3 + PARAM_LEN * 10
#define MUNMAP_E_SIZE HEADER_LEN + sizeof(uint64_t) * 2 + PARAM_LEN * 2
#define MUNMAP_X_SIZE HEADER_LEN + sizeof(int64_t) + sizeof(uint32_t) * 3 + PARAM_LEN * 4
#define MUNMAP_X_SIZE HEADER_LEN + sizeof(int64_t) + sizeof(uint32_t) * 3 + sizeof(uint64_t) * 2 + PARAM_LEN * 6
#define SPLICE_E_SIZE HEADER_LEN + sizeof(int64_t) * 2 + sizeof(uint32_t) + sizeof(uint64_t) + PARAM_LEN * 4
#define SPLICE_X_SIZE HEADER_LEN + sizeof(int64_t) + PARAM_LEN
#define SPLICE_X_SIZE HEADER_LEN + sizeof(int64_t) * 3 + sizeof(uint32_t) + sizeof(uint64_t) + PARAM_LEN * 5
#define PTRACE_E_SIZE HEADER_LEN + sizeof(int64_t) + sizeof(uint16_t) + PARAM_LEN * 2
#define IOCTL_E_SIZE HEADER_LEN + sizeof(int64_t) + sizeof(uint64_t) * 2 + PARAM_LEN * 3
#define IOCTL_X_SIZE HEADER_LEN + sizeof(int64_t) + PARAM_LEN
#define IOCTL_X_SIZE HEADER_LEN + sizeof(int64_t) * 2 + sizeof(uint64_t) * 2 + PARAM_LEN * 4
#define RENAME_E_SIZE HEADER_LEN
#define RENAMEAT_E_SIZE HEADER_LEN
#define SYMLINK_E_SIZE HEADER_LEN
#define SYMLINKAT_E_SIZE HEADER_LEN
#define PROCEXIT_SIZE HEADER_LEN + sizeof(int64_t) * 3 + sizeof(uint8_t) * 2 + PARAM_LEN * 5
#define SENDFILE_E_SIZE HEADER_LEN + sizeof(int64_t) * 2 + sizeof(uint64_t) * 2 + PARAM_LEN * 4
#define SENDFILE_X_SIZE HEADER_LEN + sizeof(int64_t) + sizeof(uint64_t) + PARAM_LEN * 2
#define SENDFILE_X_SIZE HEADER_LEN + sizeof(int64_t) * 3 + sizeof(uint64_t) * 2 + PARAM_LEN * 5
#define QUOTACTL_E_SIZE HEADER_LEN + sizeof(uint16_t) + sizeof(uint32_t) + sizeof(uint8_t) * 2 + PARAM_LEN * 4
#define SETRESUID_E_SIZE HEADER_LEN + sizeof(uint32_t) * 3 + PARAM_LEN * 3
#define SETRESUID_X_SIZE HEADER_LEN + sizeof(int64_t) + PARAM_LEN
#define SETRESUID_X_SIZE HEADER_LEN + sizeof(int64_t) + sizeof(uint32_t) * 3 + PARAM_LEN * 4
#define SETRESGID_E_SIZE HEADER_LEN + sizeof(uint32_t) * 3 + PARAM_LEN * 3
#define SETRESGID_X_SIZE HEADER_LEN + sizeof(int64_t) + PARAM_LEN
#define SETRESGID_X_SIZE HEADER_LEN + sizeof(int64_t) + sizeof(uint32_t) * 3 + PARAM_LEN * 4
#define SCAPEVENT_E_SIZE HEADER_LEN + sizeof(uint32_t) + sizeof(uint64_t) + PARAM_LEN * 2
#define SCAPEVENT_X_SIZE HEADER_LEN
#define SETUID_E_SIZE HEADER_LEN + sizeof(uint32_t) + PARAM_LEN
#define SETUID_X_SIZE HEADER_LEN + sizeof(int64_t) + PARAM_LEN
#define SETUID_X_SIZE HEADER_LEN + sizeof(int64_t) + sizeof(uint32_t) + PARAM_LEN * 2
#define SETGID_E_SIZE HEADER_LEN + sizeof(uint32_t) + PARAM_LEN
#define SETGID_X_SIZE HEADER_LEN + sizeof(int64_t) + PARAM_LEN
#define SETGID_X_SIZE HEADER_LEN + sizeof(int64_t) + sizeof(uint32_t) + PARAM_LEN * 2
#define GETUID_E_SIZE HEADER_LEN
#define GETUID_X_SIZE HEADER_LEN + sizeof(uint32_t) + PARAM_LEN
#define GETEUID_E_SIZE HEADER_LEN
@ -154,22 +154,22 @@
#define SIGNALDELIVER_SIZE HEADER_LEN + sizeof(int64_t) * 2 + sizeof(uint8_t) + PARAM_LEN * 3
#define PROCINFO_E_SIZE HEADER_LEN + sizeof(uint64_t) * 2 + PARAM_LEN * 2
#define GETDENTS_E_SIZE HEADER_LEN + sizeof(int64_t) + PARAM_LEN
#define GETDENTS_X_SIZE HEADER_LEN + sizeof(int64_t) + PARAM_LEN
#define GETDENTS_X_SIZE HEADER_LEN + sizeof(int64_t) * 2 + PARAM_LEN * 2
#define GETDENTS64_E_SIZE HEADER_LEN + sizeof(int64_t) + PARAM_LEN
#define GETDENTS64_X_SIZE HEADER_LEN + sizeof(int64_t) + PARAM_LEN
#define GETDENTS64_X_SIZE HEADER_LEN + sizeof(int64_t) * 2 + PARAM_LEN * 2
#define SETNS_E_SIZE HEADER_LEN + sizeof(int64_t) + sizeof(uint32_t) + PARAM_LEN * 2
#define SETNS_X_SIZE HEADER_LEN + sizeof(int64_t) + PARAM_LEN
#define SETNS_X_SIZE HEADER_LEN + sizeof(int64_t) * 2 + sizeof(uint32_t) + PARAM_LEN * 3
#define FLOCK_E_SIZE HEADER_LEN + sizeof(int64_t) + sizeof(uint32_t) + PARAM_LEN * 2
#define FLOCK_X_SIZE HEADER_LEN + sizeof(int64_t) + PARAM_LEN
#define FLOCK_X_SIZE HEADER_LEN + sizeof(int64_t) * 2 + sizeof(uint32_t) + PARAM_LEN * 3
#define CPU_HOTPLUG_E_SIZE HEADER_LEN + sizeof(uint32_t) * 2 + PARAM_LEN * 2
#define ACCEPT_E_SIZE HEADER_LEN
#define SEMOP_E_SIZE HEADER_LEN + sizeof(int32_t) + PARAM_LEN
#define SEMOP_X_SIZE HEADER_LEN + sizeof(int16_t) * 2 + sizeof(int64_t) + sizeof(uint16_t) * 4 + sizeof(uint32_t) + PARAM_LEN * 8
#define SEMOP_X_SIZE HEADER_LEN + sizeof(int16_t) * 2 + sizeof(int32_t) + sizeof(int64_t) + sizeof(uint16_t) * 4 + sizeof(uint32_t) + PARAM_LEN * 9
#define SEMCTL_E_SIZE HEADER_LEN + sizeof(int32_t) * 3 + sizeof(uint16_t) + PARAM_LEN * 4
#define SEMCTL_X_SIZE HEADER_LEN + sizeof(int64_t) + PARAM_LEN
#define SEMCTL_X_SIZE HEADER_LEN + sizeof(int32_t) * 3 + sizeof(int64_t) + sizeof(uint16_t) + PARAM_LEN * 5
#define MOUNT_E_SIZE HEADER_LEN + sizeof(uint32_t) + PARAM_LEN
#define SEMGET_E_SIZE HEADER_LEN + sizeof(int32_t) * 2 + sizeof(uint32_t) + PARAM_LEN * 3
#define SEMGET_X_SIZE HEADER_LEN + sizeof(int64_t) + PARAM_LEN
#define SEMGET_X_SIZE HEADER_LEN + sizeof(int32_t) * 2 + sizeof(int64_t) + sizeof(uint32_t) + PARAM_LEN * 4
#define ACCESS_E_SIZE HEADER_LEN + sizeof(uint32_t) + PARAM_LEN
#define CHROOT_E_SIZE HEADER_LEN
#define SETSID_E_SIZE HEADER_LEN
@ -177,12 +177,12 @@
#define MKDIR_E_SIZE HEADER_LEN + sizeof(uint32_t) + PARAM_LEN
#define RMDIR_E_SIZE HEADER_LEN
#define UNSHARE_E_SIZE HEADER_LEN + sizeof(uint32_t) + PARAM_LEN
#define UNSHARE_X_SIZE HEADER_LEN + sizeof(int64_t) + PARAM_LEN
#define UNSHARE_X_SIZE HEADER_LEN + sizeof(int64_t) + sizeof(uint32_t) + PARAM_LEN * 2
#define PAGE_FAULT_SIZE HEADER_LEN + sizeof(uint32_t) + sizeof(uint64_t) * 2 + PARAM_LEN * 3
#define SETPGID_E_SIZE HEADER_LEN + sizeof(int64_t) * 2 + PARAM_LEN * 2
#define SETPGID_X_SIZE HEADER_LEN + sizeof(int64_t) + PARAM_LEN
#define SETPGID_X_SIZE HEADER_LEN + sizeof(int64_t) * 3 + PARAM_LEN * 3
#define SECCOMP_E_SIZE HEADER_LEN + sizeof(uint64_t) * 2 + PARAM_LEN * 2
#define SECCOMP_X_SIZE HEADER_LEN + sizeof(int64_t) + PARAM_LEN
#define SECCOMP_X_SIZE HEADER_LEN + sizeof(int64_t) + sizeof(uint64_t) * 2 + PARAM_LEN * 3
#define UNLINK_E_SIZE HEADER_LEN
#define UNLINKAT_E_SIZE HEADER_LEN
#define MKDIRAT_E_SIZE HEADER_LEN
@ -196,9 +196,9 @@
#define USERFAULTFD_E_SIZE HEADER_LEN
#define USERFAULTFD_X_SIZE HEADER_LEN + sizeof(int64_t) + sizeof(uint32_t) + PARAM_LEN * 2
#define MPROTECT_E_SIZE HEADER_LEN + sizeof(uint32_t) + sizeof(uint64_t) * 2 + PARAM_LEN * 3
#define MPROTECT_X_SIZE HEADER_LEN + sizeof(int64_t) + PARAM_LEN
#define MPROTECT_X_SIZE HEADER_LEN + sizeof(int64_t) + sizeof(uint32_t) + sizeof(uint64_t) * 2 + PARAM_LEN * 4
#define COPY_FILE_RANGE_E_SIZE HEADER_LEN + sizeof(int64_t) + sizeof(uint64_t) * 2 + PARAM_LEN * 3
#define COPY_FILE_RANGE_X_SIZE HEADER_LEN + sizeof(int64_t) * 2 + sizeof(uint64_t) + PARAM_LEN * 3
#define COPY_FILE_RANGE_X_SIZE HEADER_LEN + sizeof(int64_t) * 3 + sizeof(uint64_t) * 3 + PARAM_LEN * 6
#define CLONE3_E_SIZE HEADER_LEN
#define OPEN_BY_HANDLE_AT_E_SIZE HEADER_LEN
#define IO_URING_SETUP_E_SIZE HEADER_LEN
@ -229,9 +229,9 @@
#define MLOCK2_X_SIZE HEADER_LEN + sizeof(int64_t) + sizeof(uint32_t) + sizeof(uint64_t) * 2 + PARAM_LEN * 4
#define FSCONFIG_E_SIZE HEADER_LEN
#define EPOLL_CREATE_E_SIZE HEADER_LEN + sizeof(int32_t) + PARAM_LEN
#define EPOLL_CREATE_X_SIZE HEADER_LEN + sizeof(int64_t) + PARAM_LEN
#define EPOLL_CREATE_X_SIZE HEADER_LEN + sizeof(int32_t) + sizeof(int64_t) + PARAM_LEN * 2
#define EPOLL_CREATE1_E_SIZE HEADER_LEN + sizeof(uint32_t) + PARAM_LEN
#define EPOLL_CREATE1_X_SIZE HEADER_LEN + sizeof(int64_t) + PARAM_LEN
#define EPOLL_CREATE1_X_SIZE HEADER_LEN + sizeof(int64_t) + sizeof(uint32_t) + PARAM_LEN * 2
#define CHOWN_E_SIZE HEADER_LEN
#define LCHOWN_E_SIZE HEADER_LEN
#define FCHOWN_E_SIZE HEADER_LEN
@ -245,9 +245,9 @@
#define INOTIFY_INIT1_E_SIZE HEADER_LEN
#define INOTIFY_INIT1_X_SIZE HEADER_LEN + sizeof(int64_t) + sizeof(uint16_t) + PARAM_LEN * 2
#define EVENTFD2_E_SIZE HEADER_LEN + sizeof(uint64_t) + PARAM_LEN
#define EVENTFD2_X_SIZE HEADER_LEN + sizeof(int64_t) + sizeof(uint16_t) + PARAM_LEN * 2
#define EVENTFD2_X_SIZE HEADER_LEN + sizeof(int64_t) + sizeof(uint16_t) + sizeof(uint64_t) + PARAM_LEN * 3
#define SIGNALFD4_E_SIZE HEADER_LEN + sizeof(int64_t) + sizeof(uint32_t) + PARAM_LEN * 2
#define SIGNALFD4_X_SIZE HEADER_LEN + sizeof(int64_t) + sizeof(uint16_t) + PARAM_LEN * 2
#define SIGNALFD4_X_SIZE HEADER_LEN + sizeof(int64_t) * 2 + sizeof(uint16_t) + sizeof(uint32_t) + PARAM_LEN * 4
#define PRCTL_E_SIZE HEADER_LEN
#define MEMFD_CREATE_E_SIZE HEADER_LEN
#define PIDFD_GETFD_E_SIZE HEADER_LEN

View File

@ -17,44 +17,99 @@
/*=============================== SETTINGS ===========================*/
static __always_inline struct capture_settings *maps__get_capture_settings() {
uint32_t key = 0;
return bpf_map_lookup_elem(&capture_settings, &key);
}
static __always_inline uint64_t maps__get_boot_time() {
return g_settings.boot_time;
struct capture_settings *settings = maps__get_capture_settings();
if(settings == NULL) {
return 0;
}
return settings->boot_time;
}
static __always_inline uint32_t maps__get_snaplen() {
return g_settings.snaplen;
struct capture_settings *settings = maps__get_capture_settings();
if(settings == NULL) {
return 0;
}
return settings->snaplen;
}
static __always_inline bool maps__get_dropping_mode() {
return g_settings.dropping_mode;
struct capture_settings *settings = maps__get_capture_settings();
if(settings == NULL) {
return 0;
}
return settings->dropping_mode;
}
static __always_inline uint32_t maps__get_sampling_ratio() {
return g_settings.sampling_ratio;
struct capture_settings *settings = maps__get_capture_settings();
if(settings == NULL) {
return 0;
}
return settings->sampling_ratio;
}
static __always_inline bool maps__get_drop_failed() {
return g_settings.drop_failed;
struct capture_settings *settings = maps__get_capture_settings();
if(settings == NULL) {
return 0;
}
return settings->drop_failed;
}
static __always_inline bool maps__get_do_dynamic_snaplen() {
return g_settings.do_dynamic_snaplen;
struct capture_settings *settings = maps__get_capture_settings();
if(settings == NULL) {
return 0;
}
return settings->do_dynamic_snaplen;
}
static __always_inline uint16_t maps__get_fullcapture_port_range_start() {
return g_settings.fullcapture_port_range_start;
struct capture_settings *settings = maps__get_capture_settings();
if(settings == NULL) {
return 0;
}
return settings->fullcapture_port_range_start;
}
static __always_inline uint16_t maps__get_fullcapture_port_range_end() {
return g_settings.fullcapture_port_range_end;
struct capture_settings *settings = maps__get_capture_settings();
if(settings == NULL) {
return 0;
}
return settings->fullcapture_port_range_end;
}
static __always_inline uint16_t maps__get_statsd_port() {
return g_settings.statsd_port;
struct capture_settings *settings = maps__get_capture_settings();
if(settings == NULL) {
return 0;
}
return settings->statsd_port;
}
static __always_inline int32_t maps__get_scap_tid() {
return g_settings.scap_tid;
struct capture_settings *settings = maps__get_capture_settings();
if(settings == NULL) {
return 0;
}
return settings->scap_tid;
}
/*=============================== SETTINGS ===========================*/
@ -89,8 +144,12 @@ static __always_inline uint8_t maps__64bit_sampling_syscall_table(uint32_t sysca
/*=============================== SYSCALL-64 INTERESTING TABLE ===========================*/
static __always_inline bool maps__64bit_interesting_syscall(uint32_t syscall_id) {
return g_64bit_interesting_syscalls_table[syscall_id & (SYSCALL_TABLE_SIZE - 1)];
static __always_inline bool maps__interesting_syscall_64bit(uint32_t syscall_id) {
bool *ret = bpf_map_lookup_elem(&interesting_syscalls_table_64bit, &syscall_id);
if(ret == NULL) {
return false;
}
return *ret;
}
/*=============================== SYSCALL-64 INTERESTING TABLE ===========================*/

View File

@ -26,6 +26,9 @@
/* Maximum number of `iovec` structures that we can analyze. */
#define MAX_IOVCNT 32
/* Maximum number of supported sendmmsg/recvmmsg loops with bpf_loop helper */
#define MAX_SENDMMSG_RECVMMSG_SIZE 16
/* Maximum number of `pollfd` structures that we can analyze. */
#define MAX_POLLFD 16

View File

@ -10,6 +10,7 @@
#include <helpers/base/maps_getters.h>
#include <helpers/base/read_from_task.h>
#include <helpers/base/shared_size.h>
#include <driver/ppm_flag_helpers.h>
#if __has_include(<sys/syscall.h>)
@ -1031,3 +1032,47 @@ static __always_inline struct socket *get_sock_from_file(struct file *file) {
}
return (struct socket *)BPF_CORE_READ(file, private_data);
}
///////////////////////////
// EXTRACT FROM MSGHDR
///////////////////////////
/**
* @brief Read the msghdr pointed by `msghdr_pointer` and store it in `msghdr` location.
* @param msghdr pointer to the user_msghdr struct used to store the read msghdr.
* @param msghdr_pointer pointer to the msghdr to be read.
* @return 0 on success, or a negative error in case of failure.
*/
static __always_inline long extract__msghdr(struct user_msghdr *msghdr,
unsigned long msghdr_pointer) {
return bpf_probe_read_user((void *)msghdr,
bpf_core_type_size(struct user_msghdr),
(void *)msghdr_pointer);
}
/**
* @brief Extract the size of a message extracted from an `iovec` struct array.
* @param scratch_space pointer the scratch space on which iovecs are read.
* @param scratch_space_size scratch space total size.
* @param iov_pointer pointer to `iovec` struct array.
* @param iov_cnt number of `iovec` structs.
* @return the size of the message on success, or 0 in case of failure.
*/
static __always_inline uint32_t extract__iovec_size(void *scratch_space,
uint32_t scratch_space_size,
unsigned long iov_pointer,
unsigned long iov_cnt) {
if(bpf_probe_read_user(scratch_space, scratch_space_size, (void *)iov_pointer)) {
return 0;
}
uint32_t total_size_to_read = 0;
const struct iovec *iovec = (const struct iovec *)scratch_space;
for(int i = 0; i < MAX_IOVCNT; i++) {
if(i == iov_cnt) {
break;
}
total_size_to_read += iovec[i].iov_len;
}
return total_size_to_read;
}

View File

@ -14,7 +14,7 @@
#include <helpers/extract/extract_from_kernel.h>
static __always_inline bool syscalls_dispatcher__64bit_interesting_syscall(uint32_t syscall_id) {
return maps__64bit_interesting_syscall(syscall_id);
return maps__interesting_syscall_64bit(syscall_id);
}
static __always_inline long convert_network_syscalls(struct pt_regs *regs) {

View File

@ -1121,9 +1121,7 @@ static __always_inline void auxmap__store_msghdr_size_param(struct auxiliary_map
* we return 0.
*/
struct user_msghdr msghdr = {0};
if(bpf_probe_read_user((void *)&msghdr,
bpf_core_type_size(struct user_msghdr),
(void *)msghdr_pointer)) {
if(extract__msghdr(&msghdr, msghdr_pointer)) {
auxmap__store_u32_param(auxmap, 0);
return;
}
@ -1148,9 +1146,7 @@ static __always_inline struct user_msghdr auxmap__store_msghdr_data_param(
* we return an empty param.
*/
struct user_msghdr msghdr = {0};
if(bpf_probe_read_user((void *)&msghdr,
bpf_core_type_size(struct user_msghdr),
(void *)msghdr_pointer)) {
if(extract__msghdr(&msghdr, msghdr_pointer)) {
/* in case of NULL msghdr we return an empty param */
push__param_len(auxmap->data, &auxmap->lengths_pos, 0);
return msghdr;
@ -1589,9 +1585,7 @@ static __always_inline void apply_dynamic_snaplen(struct pt_regs *regs,
// in any case we break the switch.
break;
}
if(bpf_probe_read_user(&msg_mh.mh,
bpf_core_type_size(struct user_msghdr),
(void *)args[1]) == 0) {
if(extract__msghdr(&msg_mh.mh, args[1]) == 0) {
sockaddr = (struct sockaddr *)msg_mh.mh.msg_name;
}
} break;

View File

@ -47,35 +47,23 @@ __weak const volatile uint64_t probe_api_ver = PPM_API_CURRENT_VERSION;
*/
__weak const volatile uint64_t probe_schema_var = PPM_SCHEMA_CURRENT_VERSION;
/*=============================== BPF READ-ONLY GLOBAL VARIABLES ===============================*/
/*=============================== BPF GLOBAL VARIABLES ===============================*/
/**
* @brief Given the syscall id on 64-bit-architectures returns if
* the syscall must be filtered out according to the simple consumer logic.
*/
__weak bool g_64bit_interesting_syscalls_table[SYSCALL_TABLE_SIZE];
/**
* @brief Given the syscall id on 64-bit-architectures returns:
* - `UF_NEVER_DROP` if the syscall must not be dropped in the sampling logic.
* - `UF_ALWAYS_DROP` if the syscall must always be dropped in the sampling logic.
* - `UF_NONE` if we drop the syscall depends on the sampling ratio.
*/
__weak uint8_t g_64bit_sampling_syscall_table[SYSCALL_TABLE_SIZE];
__weak const volatile uint8_t g_64bit_sampling_syscall_table[SYSCALL_TABLE_SIZE];
/**
* @brief Given the syscall id on 32-bit x86 arch returns
* its x64 value. Used to support ia32 syscall emulation.
*/
__weak uint32_t g_ia32_to_64_table[SYSCALL_TABLE_SIZE];
__weak const volatile uint32_t g_ia32_to_64_table[SYSCALL_TABLE_SIZE];
/**
* @brief Global capture settings shared between userspace and
* bpf programs.
*/
__weak struct capture_settings g_settings;
/*=============================== BPF READ-ONLY GLOBAL VARIABLES ===============================*/
/*=============================== BPF GLOBAL VARIABLES ===============================*/
/**
* @brief Variable used only kernel side to understand when we need to send
@ -133,6 +121,28 @@ struct {
/*=============================== BPF_MAP_TYPE_ARRAY ===============================*/
/**
* @brief This table is used to keep track of which syscalls must be filtered out
* according to the simple consumer logic.
*/
struct {
__uint(type, BPF_MAP_TYPE_ARRAY);
__uint(max_entries, SYSCALL_TABLE_SIZE);
__type(key, uint32_t);
__type(value, bool);
} interesting_syscalls_table_64bit __weak SEC(".maps");
/**
* @brief Global capture settings shared between userspace and
* bpf programs.
*/
struct {
__uint(type, BPF_MAP_TYPE_ARRAY);
__uint(max_entries, 1);
__type(key, uint32_t);
__type(value, struct capture_settings);
} capture_settings __weak SEC(".maps");
/* These maps have one entry for each CPU.
*
* PLEASE NOTE:

View File

@ -179,9 +179,9 @@ int BPF_PROG(t1_sched_p_exec, struct task_struct *p, pid_t old_pid, struct linux
uint32_t tty = exctract__tty(task);
auxmap__store_u32_param(auxmap, (uint32_t)tty);
/* Parameter 18: pgid (type: PT_PID) */
pid_t pgid = extract__task_xid_vnr(task, PIDTYPE_PGID);
auxmap__store_s64_param(auxmap, (int64_t)pgid);
/* Parameter 18: vpgid (type: PT_PID) */
pid_t vpgid = extract__task_xid_vnr(task, PIDTYPE_PGID);
auxmap__store_s64_param(auxmap, (int64_t)vpgid);
/* Parameter 19: loginuid (type: PT_UID) */
uint32_t loginuid;

View File

@ -105,6 +105,12 @@ int BPF_PROG(accept4_x, struct pt_regs *regs, long ret) {
/* Parameter 5: queuemax (type: PT_UINT32) */
auxmap__store_u32_param(auxmap, queuemax);
/* Parameter 6: flags (type: PT_FLAGS32) */
/// TODO: we don't support flags yet and so we just return zero.
/// If implemented, special handling for SYS_ACCEPT socketcall is needed.
uint32_t flags = 0;
auxmap__store_u32_param(auxmap, flags);
/*=============================== COLLECT PARAMETERS ===========================*/
auxmap__finalize_event_header(auxmap);

View File

@ -51,10 +51,14 @@ int BPF_PROG(access_x, struct pt_regs *regs, long ret) {
/* Parameter 1: res (type: PT_ERRNO) */
auxmap__store_s64_param(auxmap, ret);
/* Parameter 2: pathname (type: PT_FSPATH) */
/* Parameter 2: name (type: PT_FSPATH) */
unsigned long path_pointer = extract__syscall_argument(regs, 0);
auxmap__store_charbuf_param(auxmap, path_pointer, MAX_PATH, USER);
/* Parameter 3: mode (type: PT_UINT32) */
int mode = (int)extract__syscall_argument(regs, 1);
auxmap__store_u32_param(auxmap, (uint32_t)access_flags_to_scap(mode));
/*=============================== COLLECT PARAMETERS ===========================*/
auxmap__finalize_event_header(auxmap);

View File

@ -22,7 +22,7 @@ int BPF_PROG(brk_e, struct pt_regs *regs, long id) {
/*=============================== COLLECT PARAMETERS ===========================*/
/* Parameter 1: addr (type: PT_UINT64) */
unsigned long addr = extract__syscall_argument(regs, 0);
uint64_t addr = extract__syscall_argument(regs, 0);
ringbuf__store_u64(&ringbuf, addr);
/*=============================== COLLECT PARAMETERS ===========================*/
@ -68,6 +68,10 @@ int BPF_PROG(brk_x, struct pt_regs *regs, long ret) {
/* Parameter 4: vm_swap (type: PT_UINT32) */
ringbuf__store_u32(&ringbuf, swap_size);
/* Parameter 5: addr (type: PT_UINT64) */
uint64_t addr = extract__syscall_argument(regs, 0);
ringbuf__store_u64(&ringbuf, addr);
/*=============================== COLLECT PARAMETERS ===========================*/
ringbuf__submit_event(&ringbuf);

View File

@ -50,9 +50,9 @@ int BPF_PROG(close_e, struct pt_regs *regs, long id) {
/*=============================== COLLECT PARAMETERS ===========================*/
/* Parameter 1: fd (type: PT_FD)*/
int32_t fd = (int32_t)extract__syscall_argument(regs, 0);
ringbuf__store_s64(&ringbuf, (int64_t)fd);
/* Parameter 1: fd (type: PT_FD) */
int64_t fd = (int64_t)(int32_t)extract__syscall_argument(regs, 0);
ringbuf__store_s64(&ringbuf, fd);
/*=============================== COLLECT PARAMETERS ===========================*/
@ -80,9 +80,13 @@ int BPF_PROG(close_x, struct pt_regs *regs, long ret) {
/*=============================== COLLECT PARAMETERS ===========================*/
/* Parameter 1: res (type: PT_ERRNO)*/
/* Parameter 1: res (type: PT_ERRNO) */
ringbuf__store_s64(&ringbuf, ret);
/* Parameter 2: fd (type: PT_FD) */
int64_t fd = (int64_t)(int32_t)extract__syscall_argument(regs, 0);
ringbuf__store_s64(&ringbuf, fd);
/*=============================== COLLECT PARAMETERS ===========================*/
ringbuf__submit_event(&ringbuf);

View File

@ -24,14 +24,14 @@ int BPF_PROG(connect_e, struct pt_regs *regs, long id) {
unsigned long args[3] = {0};
extract__network_args(args, 3, regs);
/* Parameter 1: fd (type: PT_FD)*/
int32_t socket_fd = (int32_t)args[0];
auxmap__store_s64_param(auxmap, (int64_t)socket_fd);
/* Parameter 1: fd (type: PT_FD) */
int64_t socket_fd = (int64_t)(int32_t)args[0];
auxmap__store_s64_param(auxmap, socket_fd);
/* Parameter 2: addr (type: PT_SOCKADDR)*/
unsigned long sockaddr_ptr = args[1];
uint16_t addrlen = (uint16_t)args[2];
auxmap__store_sockaddr_param(auxmap, sockaddr_ptr, addrlen);
/* Parameter 2: addr (type: PT_SOCKADDR) */
unsigned long usrsockaddr = args[1];
uint16_t usrsockaddr_len = (uint16_t)args[2];
auxmap__store_sockaddr_param(auxmap, usrsockaddr, usrsockaddr_len);
/*=============================== COLLECT PARAMETERS ===========================*/
@ -57,25 +57,30 @@ int BPF_PROG(connect_x, struct pt_regs *regs, long ret) {
/*=============================== COLLECT PARAMETERS ===========================*/
unsigned long socket_fd = 0;
extract__network_args(&socket_fd, 1, regs);
unsigned long args[3] = {0};
extract__network_args(args, 3, regs);
int64_t socket_fd = (int64_t)(int32_t)args[0];
/* Parameter 1: res (type: PT_ERRNO) */
auxmap__store_s64_param(auxmap, ret);
struct sockaddr *usrsockaddr = (struct sockaddr *)args[1];
/* Parameter 2: tuple (type: PT_SOCKTUPLE) */
/* We need a valid sockfd to extract source data.*/
if(ret == 0 || ret == -EINPROGRESS) {
auxmap__store_socktuple_param(auxmap, (int32_t)socket_fd, OUTBOUND, NULL);
/* Notice: the following will push an empty parameter if
* something goes wrong (e.g.: fd not valid). */
auxmap__store_socktuple_param(auxmap, (int32_t)socket_fd, OUTBOUND, usrsockaddr);
} else {
auxmap__store_empty_param(auxmap);
}
/* Parameter 3: fd (type: PT_FD)*/
/* We need the double cast to extract the first 4 bytes and then
* convert them to a signed integer on 64-bit
*/
auxmap__store_s64_param(auxmap, (int64_t)(int32_t)socket_fd);
/* Parameter 3: fd (type: PT_FD) */
auxmap__store_s64_param(auxmap, socket_fd);
/* Parameter 4: addr (type: PT_SOCKADDR) */
uint16_t usrsockaddr_len = (uint16_t)args[2];
auxmap__store_sockaddr_param(auxmap, (unsigned long)usrsockaddr, usrsockaddr_len);
/*=============================== COLLECT PARAMETERS ===========================*/

View File

@ -25,8 +25,8 @@ int BPF_PROG(copy_file_range_e, struct pt_regs *regs, long id) {
/*=============================== COLLECT PARAMETERS ===========================*/
/* Parameter 1: fdin (type: PT_FD) */
int32_t fdin = (int32_t)extract__syscall_argument(regs, 0);
ringbuf__store_s64(&ringbuf, (int64_t)fdin);
int64_t fdin = (int64_t)(int32_t)extract__syscall_argument(regs, 0);
ringbuf__store_s64(&ringbuf, fdin);
/* Parameter 2: offin (type: PT_UINT64) */
uint64_t offin = extract__syscall_argument(regs, 1);
@ -58,17 +58,29 @@ int BPF_PROG(copy_file_range_x, struct pt_regs *regs, long ret) {
/*=============================== COLLECT PARAMETERS ===========================*/
/* Parameter 1: res (type: PT_ERRNO)*/
/* Parameter 1: res (type: PT_ERRNO) */
ringbuf__store_s64(&ringbuf, ret);
/* Parameter 2: fdout (type: PT_FD) */
int32_t fdout = (int32_t)extract__syscall_argument(regs, 2);
ringbuf__store_s64(&ringbuf, (int64_t)fdout);
int64_t fdout = (int64_t)(int32_t)extract__syscall_argument(regs, 2);
ringbuf__store_s64(&ringbuf, fdout);
/* Parameter 3: offout (type: PT_UINT64) */
uint64_t offout = extract__syscall_argument(regs, 3);
ringbuf__store_u64(&ringbuf, offout);
/* Parameter 4: fdin (type: PT_FD) */
int64_t fdin = (int64_t)(int32_t)extract__syscall_argument(regs, 0);
ringbuf__store_s64(&ringbuf, fdin);
/* Parameter 5: offin (type: PT_UINT64) */
uint64_t offin = extract__syscall_argument(regs, 1);
ringbuf__store_u64(&ringbuf, offin);
/* Parameter 6: len (type: PT_UINT64) */
uint64_t len = extract__syscall_argument(regs, 4);
ringbuf__store_u64(&ringbuf, len);
/*=============================== COLLECT PARAMETERS ===========================*/
ringbuf__submit_event(&ringbuf);

View File

@ -21,9 +21,9 @@ int BPF_PROG(dup_e, struct pt_regs *regs, long id) {
/*=============================== COLLECT PARAMETERS ===========================*/
/* Parameter 1: oldfd (type: PT_FD) */
int32_t oldfd = (int32_t)extract__syscall_argument(regs, 0);
ringbuf__store_s64(&ringbuf, (int64_t)oldfd);
/* Parameter 1: fd (type: PT_FD) */
int64_t oldfd = (int64_t)(int32_t)extract__syscall_argument(regs, 0);
ringbuf__store_s64(&ringbuf, oldfd);
/*=============================== COLLECT PARAMETERS ===========================*/
@ -47,12 +47,12 @@ int BPF_PROG(dup_x, struct pt_regs *regs, long ret) {
/*=============================== COLLECT PARAMETERS ===========================*/
/* Parameter 1: res (type: PT_FD)*/
ringbuf__store_s64(&ringbuf, ret);
/* Parameter 1: res (type: PT_FD) */
ringbuf__store_s64(&ringbuf, (int64_t)(int32_t)ret);
/* Parameter 2: oldfd (type: PT_FD) */
int32_t oldfd = (int32_t)extract__syscall_argument(regs, 0);
ringbuf__store_s64(&ringbuf, (int64_t)oldfd);
int64_t oldfd = (int64_t)(int32_t)extract__syscall_argument(regs, 0);
ringbuf__store_s64(&ringbuf, oldfd);
/*=============================== COLLECT PARAMETERS ===========================*/

View File

@ -21,9 +21,9 @@ int BPF_PROG(dup2_e, struct pt_regs *regs, long id) {
/*=============================== COLLECT PARAMETERS ===========================*/
/* Parameter 1: oldfd (type: PT_FD) */
int32_t oldfd = (int32_t)extract__syscall_argument(regs, 0);
ringbuf__store_s64(&ringbuf, (int64_t)oldfd);
/* Parameter 1: fd (type: PT_FD) */
int64_t oldfd = (int64_t)(int32_t)extract__syscall_argument(regs, 0);
ringbuf__store_s64(&ringbuf, oldfd);
/*=============================== COLLECT PARAMETERS ===========================*/
@ -47,16 +47,16 @@ int BPF_PROG(dup2_x, struct pt_regs *regs, long ret) {
/*=============================== COLLECT PARAMETERS ===========================*/
/* Parameter 1: res (type: PT_FD)*/
ringbuf__store_s64(&ringbuf, ret);
/* Parameter 1: res (type: PT_FD) */
ringbuf__store_s64(&ringbuf, (int64_t)(int32_t)ret);
/* Parameter 2: oldfd (type: PT_FD) */
int32_t oldfd = (int32_t)extract__syscall_argument(regs, 0);
ringbuf__store_s64(&ringbuf, (int64_t)oldfd);
int64_t oldfd = (int64_t)(int32_t)extract__syscall_argument(regs, 0);
ringbuf__store_s64(&ringbuf, oldfd);
/* Parameter 3: newfd (type: PT_FD) */
int32_t newfd = (int32_t)extract__syscall_argument(regs, 1);
ringbuf__store_s64(&ringbuf, (int64_t)newfd);
int64_t newfd = (int64_t)(int32_t)extract__syscall_argument(regs, 1);
ringbuf__store_s64(&ringbuf, newfd);
/*=============================== COLLECT PARAMETERS ===========================*/

View File

@ -21,9 +21,9 @@ int BPF_PROG(dup3_e, struct pt_regs *regs, long id) {
/*=============================== COLLECT PARAMETERS ===========================*/
/* Parameter 1: oldfd (type: PT_FD) */
int32_t oldfd = (int32_t)extract__syscall_argument(regs, 0);
ringbuf__store_s64(&ringbuf, (int64_t)oldfd);
/* Parameter 1: fd (type: PT_FD) */
int64_t oldfd = (int64_t)(int32_t)extract__syscall_argument(regs, 0);
ringbuf__store_s64(&ringbuf, oldfd);
/*=============================== COLLECT PARAMETERS ===========================*/
@ -47,16 +47,16 @@ int BPF_PROG(dup3_x, struct pt_regs *regs, long ret) {
/*=============================== COLLECT PARAMETERS ===========================*/
/* Parameter 1: res (type: PT_FD)*/
ringbuf__store_s64(&ringbuf, ret);
/* Parameter 1: res (type: PT_FD) */
ringbuf__store_s64(&ringbuf, (int64_t)(int32_t)ret);
/* Parameter 2: oldfd (type: PT_FD) */
int32_t oldfd = (int32_t)extract__syscall_argument(regs, 0);
ringbuf__store_s64(&ringbuf, (int64_t)oldfd);
int64_t oldfd = (int64_t)(int32_t)extract__syscall_argument(regs, 0);
ringbuf__store_s64(&ringbuf, oldfd);
/* Parameter 3: newfd (type: PT_FD) */
int32_t newfd = (int32_t)extract__syscall_argument(regs, 1);
ringbuf__store_s64(&ringbuf, (int64_t)newfd);
int64_t newfd = (int64_t)(int32_t)extract__syscall_argument(regs, 1);
ringbuf__store_s64(&ringbuf, newfd);
/* Parameter 4: flags (type: PT_FLAGS32) */
int32_t flags = extract__syscall_argument(regs, 2);

View File

@ -47,9 +47,13 @@ int BPF_PROG(epoll_create_x, struct pt_regs *regs, long ret) {
/*=============================== COLLECT PARAMETERS ===========================*/
/* Parameter 1: res (type: PT_ERRNO)*/
/* Parameter 1: res (type: PT_ERRNO) */
ringbuf__store_s64(&ringbuf, ret);
/* Parameter 2: size (type: PT_INT32) */
int32_t size = (int32_t)extract__syscall_argument(regs, 0);
ringbuf__store_s32(&ringbuf, size);
/*=============================== COLLECT PARAMETERS ===========================*/
ringbuf__submit_event(&ringbuf);

View File

@ -47,9 +47,13 @@ int BPF_PROG(epoll_create1_x, struct pt_regs *regs, long ret) {
/*=============================== COLLECT PARAMETERS ===========================*/
/* Parameter 1: res (type: PT_ERRNO)*/
/* Parameter 1: res (type: PT_ERRNO) */
ringbuf__store_s64(&ringbuf, ret);
/* Parameter 2: flags (type: PT_FLAGS32) */
int32_t flags = (int32_t)extract__syscall_argument(regs, 0);
ringbuf__store_u32(&ringbuf, epoll_create1_flags_to_scap(flags));
/*=============================== COLLECT PARAMETERS ===========================*/
ringbuf__submit_event(&ringbuf);

View File

@ -50,6 +50,10 @@ int BPF_PROG(epoll_wait_x, struct pt_regs *regs, long ret) {
/* Parameter 1: res (type: PT_ERRNO) */
ringbuf__store_s64(&ringbuf, ret);
/* Parameter 2: maxevents (type: PT_ERRNO) */
int maxevents = (int)extract__syscall_argument(regs, 2);
ringbuf__store_s64(&ringbuf, (int64_t)maxevents);
/*=============================== COLLECT PARAMETERS ===========================*/
ringbuf__submit_event(&ringbuf);

View File

@ -22,8 +22,8 @@ int BPF_PROG(eventfd_e, struct pt_regs *regs, long id) {
/*=============================== COLLECT PARAMETERS ===========================*/
/* Parameter 1: initval (type: PT_UINT64) */
uint32_t initval = (uint32_t)extract__syscall_argument(regs, 0);
ringbuf__store_u64(&ringbuf, (uint64_t)initval);
uint64_t initval = (uint64_t)extract__syscall_argument(regs, 0);
ringbuf__store_u64(&ringbuf, initval);
/* Parameter 2: flags (type: PT_UINT32) */
/* The syscall eventfd has no flags! only `eventfd2` has the `flags` param.
@ -53,9 +53,19 @@ int BPF_PROG(eventfd_x, struct pt_regs *regs, long ret) {
/*=============================== COLLECT PARAMETERS ===========================*/
/* Parameter 1: res (type: PT_FD)*/
/* Parameter 1: res (type: PT_FD) */
ringbuf__store_s64(&ringbuf, ret);
/* Parameter 2: initval (type: PT_UINT64) */
uint64_t initval = (uint64_t)extract__syscall_argument(regs, 0);
ringbuf__store_u64(&ringbuf, initval);
/* Parameter 3: flags (type: PT_UINT32) */
/* The syscall eventfd has no flags! only `eventfd2` has the `flags` param.
* For compatibility with the event definition here we send `0` as flags.
*/
ringbuf__store_u32(&ringbuf, 0);
/*=============================== COLLECT PARAMETERS ===========================*/
ringbuf__submit_event(&ringbuf);

View File

@ -47,13 +47,17 @@ int BPF_PROG(eventfd2_x, struct pt_regs *regs, long ret) {
/*=============================== COLLECT PARAMETERS ===========================*/
/* Parameter 1: res (type: PT_FD)*/
/* Parameter 1: res (type: PT_FD) */
ringbuf__store_s64(&ringbuf, ret);
/* Parameter 2: flags (type: PT_FLAGS16) */
int32_t flags = (int32_t)extract__syscall_argument(regs, 1);
ringbuf__store_u16(&ringbuf, eventfd2_flags_to_scap(flags));
/* Parameter 3: initval (type: PT_UINT64) */
uint32_t initval = (uint32_t)extract__syscall_argument(regs, 0);
ringbuf__store_u64(&ringbuf, (uint64_t)initval);
/*=============================== COLLECT PARAMETERS ===========================*/
ringbuf__submit_event(&ringbuf);

View File

@ -198,9 +198,9 @@ int BPF_PROG(t1_execve_x, struct pt_regs *regs, long ret) {
uint32_t tty = exctract__tty(task);
auxmap__store_u32_param(auxmap, (uint32_t)tty);
/* Parameter 18: pgid (type: PT_PID) */
pid_t pgid = extract__task_xid_vnr(task, PIDTYPE_PGID);
auxmap__store_s64_param(auxmap, (int64_t)pgid);
/* Parameter 18: vpgid (type: PT_PID) */
pid_t vpgid = extract__task_xid_vnr(task, PIDTYPE_PGID);
auxmap__store_s64_param(auxmap, (int64_t)vpgid);
/* Parameter 19: loginuid (type: PT_UID) */
uint32_t loginuid;

View File

@ -50,6 +50,10 @@ int BPF_PROG(fchdir_x, struct pt_regs *regs, long ret) {
/* Parameter 1: res (type: PT_ERRNO)*/
ringbuf__store_s64(&ringbuf, ret);
/* Parameter 2: fd (type: PT_FD) */
int32_t fd = (int32_t)extract__syscall_argument(regs, 0);
ringbuf__store_s64(&ringbuf, (int64_t)fd);
/*=============================== COLLECT PARAMETERS ===========================*/
ringbuf__submit_event(&ringbuf);

View File

@ -22,8 +22,8 @@ int BPF_PROG(flock_e, struct pt_regs *regs, long id) {
/*=============================== COLLECT PARAMETERS ===========================*/
/* Parameter 1: fd (type: PT_FD) */
int32_t fd = (int32_t)extract__syscall_argument(regs, 0);
ringbuf__store_s64(&ringbuf, (int64_t)fd);
int64_t fd = (int64_t)(int32_t)extract__syscall_argument(regs, 0);
ringbuf__store_s64(&ringbuf, fd);
/* Parameter 2: operation (type: PT_FLAGS32) */
unsigned long operation = extract__syscall_argument(regs, 1);
@ -51,9 +51,17 @@ int BPF_PROG(flock_x, struct pt_regs *regs, long ret) {
/*=============================== COLLECT PARAMETERS ===========================*/
/* Parameter 1: res (type: PT_ERRNO)*/
/* Parameter 1: res (type: PT_ERRNO) */
ringbuf__store_s64(&ringbuf, ret);
/* Parameter 2: fd (type: PT_FD) */
int64_t fd = (int64_t)(int32_t)extract__syscall_argument(regs, 0);
ringbuf__store_s64(&ringbuf, fd);
/* Parameter 3: operation (type: PT_FLAGS32) */
unsigned long operation = extract__syscall_argument(regs, 1);
ringbuf__store_u32(&ringbuf, flock_flags_to_scap((int)operation));
/*=============================== COLLECT PARAMETERS ===========================*/
ringbuf__submit_event(&ringbuf);

View File

@ -50,6 +50,10 @@ int BPF_PROG(fstat_x, struct pt_regs *regs, long ret) {
/* Parameter 1: res (type: PT_ERRNO) */
ringbuf__store_s64(&ringbuf, ret);
/* Parameter 2: fd (type: PT_FD) */
int32_t fd = (int32_t)extract__syscall_argument(regs, 0);
ringbuf__store_s64(&ringbuf, (int64_t)fd);
/*=============================== COLLECT PARAMETERS ===========================*/
ringbuf__submit_event(&ringbuf);

View File

@ -58,6 +58,18 @@ int BPF_PROG(futex_x, struct pt_regs *regs, long ret) {
/* Parameter 1: res (type: PT_ERRNO) */
ringbuf__store_s64(&ringbuf, (int64_t)ret);
/* Parameter 2: addr (type: PT_UINT64) */
uint64_t addr = extract__syscall_argument(regs, 0);
ringbuf__store_u64(&ringbuf, addr);
/* Parameter 3: op (type: PT_ENUMFLAGS16) */
int32_t op = (int32_t)extract__syscall_argument(regs, 1);
ringbuf__store_u16(&ringbuf, futex_op_to_scap((unsigned long)op));
/* Parameter 4: val (type: PT_UINT64) */
uint64_t val = extract__syscall_argument(regs, 2);
ringbuf__store_u64(&ringbuf, val);
/*=============================== COLLECT PARAMETERS ===========================*/
ringbuf__submit_event(&ringbuf);

View File

@ -21,9 +21,9 @@ int BPF_PROG(getdents_e, struct pt_regs *regs, long id) {
/*=============================== COLLECT PARAMETERS ===========================*/
/* Parameter 1: fd (type: PT_FD)*/
int32_t fd = (int32_t)extract__syscall_argument(regs, 0);
ringbuf__store_s64(&ringbuf, (int64_t)fd);
/* Parameter 1: fd (type: PT_FD) */
int64_t fd = (int64_t)(int32_t)extract__syscall_argument(regs, 0);
ringbuf__store_s64(&ringbuf, fd);
/*=============================== COLLECT PARAMETERS ===========================*/
@ -47,9 +47,13 @@ int BPF_PROG(getdents_x, struct pt_regs *regs, long ret) {
/*=============================== COLLECT PARAMETERS ===========================*/
/* Parameter 1: res (type: PT_ERRNO)*/
/* Parameter 1: res (type: PT_ERRNO) */
ringbuf__store_s64(&ringbuf, ret);
/* Parameter 2: fd (type: PT_FD) */
int64_t fd = (int64_t)(int32_t)extract__syscall_argument(regs, 0);
ringbuf__store_s64(&ringbuf, fd);
/*=============================== COLLECT PARAMETERS ===========================*/
ringbuf__submit_event(&ringbuf);

View File

@ -21,9 +21,9 @@ int BPF_PROG(getdents64_e, struct pt_regs *regs, long id) {
/*=============================== COLLECT PARAMETERS ===========================*/
/* Parameter 1: fd (type: PT_FD)*/
int32_t fd = (int32_t)extract__syscall_argument(regs, 0);
ringbuf__store_s64(&ringbuf, (int64_t)fd);
/* Parameter 1: fd (type: PT_FD) */
int64_t fd = (int64_t)(int32_t)extract__syscall_argument(regs, 0);
ringbuf__store_s64(&ringbuf, fd);
/*=============================== COLLECT PARAMETERS ===========================*/
@ -47,9 +47,13 @@ int BPF_PROG(getdents64_x, struct pt_regs *regs, long ret) {
/*=============================== COLLECT PARAMETERS ===========================*/
/* Parameter 1: res (type: PT_ERRNO)*/
/* Parameter 1: res (type: PT_ERRNO) */
ringbuf__store_s64(&ringbuf, ret);
/* Parameter 2: fd (type: PT_FD) */
int64_t fd = (int64_t)(int32_t)extract__syscall_argument(regs, 0);
ringbuf__store_s64(&ringbuf, fd);
/*=============================== COLLECT PARAMETERS ===========================*/
ringbuf__submit_event(&ringbuf);

View File

@ -71,6 +71,10 @@ int BPF_PROG(getrlimit_x, struct pt_regs *regs, long ret) {
ringbuf__store_s64(&ringbuf, -1);
}
/* Parameter 4: resource (type: PT_ENUMFLAGS8) */
unsigned long resource = extract__syscall_argument(regs, 0);
ringbuf__store_u8(&ringbuf, rlimit_resource_to_scap(resource));
/*=============================== COLLECT PARAMETERS ===========================*/
ringbuf__submit_event(&ringbuf);

View File

@ -53,6 +53,11 @@ int BPF_PROG(inotify_init_x, struct pt_regs *regs, long ret) {
/* Parameter 1: res (type: PT_FD) */
ringbuf__store_s64(&ringbuf, ret);
/* Parameter 2: flags (type: PT_UINT8) */
/* Send `0` to unify handling with inotify_init1. */
uint8_t flags = 0;
ringbuf__store_u8(&ringbuf, flags);
/*=============================== COLLECT PARAMETERS ===========================*/
ringbuf__submit_event(&ringbuf);

View File

@ -55,9 +55,21 @@ int BPF_PROG(ioctl_x, struct pt_regs *regs, long ret) {
/*=============================== COLLECT PARAMETERS ===========================*/
/* Parameter 1: res (type: PT_ERRNO)*/
/* Parameter 1: res (type: PT_ERRNO) */
ringbuf__store_s64(&ringbuf, ret);
/* Parameter 2: fd (type: PT_FD) */
int32_t fd = (int32_t)extract__syscall_argument(regs, 0);
ringbuf__store_s64(&ringbuf, (int64_t)fd);
/* Parameter 3: request (type: PT_UINT64) */
uint64_t request = extract__syscall_argument(regs, 1);
ringbuf__store_u64(&ringbuf, request);
/* Parameter 4: argument (type: PT_UINT64) */
uint64_t argument = extract__syscall_argument(regs, 2);
ringbuf__store_u64(&ringbuf, argument);
/*=============================== COLLECT PARAMETERS ===========================*/
ringbuf__submit_event(&ringbuf);

View File

@ -51,9 +51,17 @@ int BPF_PROG(kill_x, struct pt_regs *regs, long ret) {
/*=============================== COLLECT PARAMETERS ===========================*/
/* Parameter 1: res (type: PT_ERRNO)*/
/* Parameter 1: res (type: PT_ERRNO) */
ringbuf__store_s64(&ringbuf, ret);
/* Parameter 2: pid (type: PT_PID) */
pid_t pid = (int32_t)extract__syscall_argument(regs, 0);
ringbuf__store_s64(&ringbuf, (int64_t)pid);
/* Parameter 3: sig (type: PT_SIGTYPE) */
uint8_t sig = (uint8_t)extract__syscall_argument(regs, 1);
ringbuf__store_u8(&ringbuf, sig);
/*=============================== COLLECT PARAMETERS ===========================*/
ringbuf__submit_event(&ringbuf);

View File

@ -58,6 +58,20 @@ int BPF_PROG(llseek_x, struct pt_regs *regs, long ret) {
/* Parameter 1: res (type: PT_ERRNO) */
ringbuf__store_s64(&ringbuf, (int64_t)ret);
/* Parameter 2: fd (type: PT_FD) */
int32_t fd = (int32_t)extract__syscall_argument(regs, 0);
ringbuf__store_s64(&ringbuf, (int64_t)fd);
/* Parameter 3: offset (type: PT_UINT64) */
unsigned long oh = extract__syscall_argument(regs, 1);
unsigned long ol = extract__syscall_argument(regs, 2);
unsigned long offset = (oh << 32) + ol;
ringbuf__store_u64(&ringbuf, offset);
/* Parameter 4: whence (type: PT_ENUMFLAGS8) */
unsigned long whence = extract__syscall_argument(regs, 3);
ringbuf__store_u8(&ringbuf, lseek_whence_to_scap(whence));
/*=============================== COLLECT PARAMETERS ===========================*/
ringbuf__submit_event(&ringbuf);

View File

@ -22,8 +22,8 @@ int BPF_PROG(lseek_e, struct pt_regs *regs, long id) {
/*=============================== COLLECT PARAMETERS ===========================*/
/* Parameter 1: fd (type: PT_FD) */
int32_t fd = (int32_t)extract__syscall_argument(regs, 0);
ringbuf__store_s64(&ringbuf, (int64_t)fd);
int64_t fd = (int64_t)(int32_t)extract__syscall_argument(regs, 0);
ringbuf__store_s64(&ringbuf, fd);
/* Parameter 2: offset (type: PT_UINT64) */
unsigned long offset = extract__syscall_argument(regs, 1);
@ -56,6 +56,18 @@ int BPF_PROG(lseek_x, struct pt_regs *regs, long ret) {
/* Parameter 1: res (type: PT_ERRNO) */
ringbuf__store_s64(&ringbuf, (int64_t)ret);
/* Parameter 2: fd (type: PT_FD) */
int64_t fd = (int64_t)(int32_t)extract__syscall_argument(regs, 0);
ringbuf__store_s64(&ringbuf, fd);
/* Parameter 3: offset (type: PT_UINT64) */
unsigned long offset = extract__syscall_argument(regs, 1);
ringbuf__store_u64(&ringbuf, offset);
/* Parameter 4: whence (type: PT_ENUMFLAGS8) */
unsigned long whence = extract__syscall_argument(regs, 2);
ringbuf__store_u8(&ringbuf, lseek_whence_to_scap(whence));
/*=============================== COLLECT PARAMETERS ===========================*/
ringbuf__submit_event(&ringbuf);

View File

@ -55,6 +55,10 @@ int BPF_PROG(mkdir_x, struct pt_regs *regs, long ret) {
unsigned long path_pointer = extract__syscall_argument(regs, 0);
auxmap__store_charbuf_param(auxmap, path_pointer, MAX_PATH, USER);
/* Parameter 3: mode (type: PT_UINT32) */
uint32_t mode = (uint32_t)extract__syscall_argument(regs, 1);
auxmap__store_u32_param(auxmap, mode);
/*=============================== COLLECT PARAMETERS ===========================*/
auxmap__finalize_event_header(auxmap);

View File

@ -87,6 +87,30 @@ int BPF_PROG(mmap_x, struct pt_regs *regs, long ret) {
/* Parameter 4: vm_swap (type: PT_UINT32) */
ringbuf__store_u32(&ringbuf, swap_size);
/* Parameter 5: addr (type: PT_UINT64) */
unsigned long addr = extract__syscall_argument(regs, 0);
ringbuf__store_u64(&ringbuf, addr);
/* Parameter 6: length (type: PT_UINT64) */
unsigned long length = extract__syscall_argument(regs, 1);
ringbuf__store_u64(&ringbuf, length);
/* Parameter 7: prot (type: PT_FLAGS32) */
unsigned long prot = extract__syscall_argument(regs, 2);
ringbuf__store_u32(&ringbuf, prot_flags_to_scap(prot));
/* Parameter 8: flags (type: PT_FLAGS32) */
unsigned long flags = extract__syscall_argument(regs, 3);
ringbuf__store_u32(&ringbuf, mmap_flags_to_scap(flags));
/* Paremeter 9: fd (type: PT_FD) */
int32_t fd = (int32_t)extract__syscall_argument(regs, 4);
ringbuf__store_s64(&ringbuf, (int64_t)fd);
/* Parameter 10: offset (type: PT_UINT64) */
unsigned long offset = extract__syscall_argument(regs, 5);
ringbuf__store_u64(&ringbuf, offset);
/*=============================== COLLECT PARAMETERS ===========================*/
ringbuf__submit_event(&ringbuf);

View File

@ -87,6 +87,30 @@ int BPF_PROG(mmap2_x, struct pt_regs *regs, long ret) {
/* Parameter 4: vm_swap (type: PT_UINT32) */
ringbuf__store_u32(&ringbuf, swap_size);
/* Parameter 5: addr (type: PT_UINT64) */
unsigned long addr = extract__syscall_argument(regs, 0);
ringbuf__store_u64(&ringbuf, addr);
/* Parameter 6: length (type: PT_UINT64) */
unsigned long length = extract__syscall_argument(regs, 1);
ringbuf__store_u64(&ringbuf, length);
/* Parameter 7: prot (type: PT_FLAGS32) */
unsigned long prot = extract__syscall_argument(regs, 2);
ringbuf__store_u32(&ringbuf, prot_flags_to_scap(prot));
/* Parameter 8: flags (type: PT_FLAGS32) */
unsigned long flags = extract__syscall_argument(regs, 3);
ringbuf__store_u32(&ringbuf, mmap_flags_to_scap(flags));
/* Paremeter 9: fd (type: PT_FD) */
int32_t fd = (int32_t)extract__syscall_argument(regs, 4);
ringbuf__store_s64(&ringbuf, (int64_t)fd);
/* Parameter 10: pgoffset (type: PT_UINT64) */
unsigned long offset = extract__syscall_argument(regs, 5);
ringbuf__store_u64(&ringbuf, offset);
/*=============================== COLLECT PARAMETERS ===========================*/
ringbuf__submit_event(&ringbuf);

View File

@ -75,6 +75,22 @@ int BPF_PROG(mount_x, struct pt_regs *regs, long ret) {
unsigned long fstype_pointer = extract__syscall_argument(regs, 2);
auxmap__store_charbuf_param(auxmap, fstype_pointer, MAX_PARAM_SIZE, USER);
/* Parameter 5: flags (type: PT_FLAGS32) */
uint32_t flags = (uint32_t)extract__syscall_argument(regs, 3);
/* The `mountflags` argument may have the magic number 0xC0ED
* (MS_MGC_VAL) in the top 16 bits. (All of the other flags
* occupy the low order 16 bits of `mountflags`.)
* Specifying MS_MGC_VAL was required in kernel
* versions prior to 2.4, but since Linux 2.4 is no longer required
* and is ignored if specified.
*/
/* Check the magic number 0xC0ED in the top 16 bits and ignore it if specified. */
if((flags & PPM_MS_MGC_MSK) == PPM_MS_MGC_VAL) {
flags &= ~PPM_MS_MGC_MSK;
}
auxmap__store_u32_param(auxmap, flags);
/*=============================== COLLECT PARAMETERS ===========================*/
auxmap__finalize_event_header(auxmap);

View File

@ -58,6 +58,18 @@ int BPF_PROG(mprotect_x, struct pt_regs *regs, long ret) {
/* Parameter 1: res (type: PT_ERRNO) */
ringbuf__store_s64(&ringbuf, ret);
/* Parameter 2: addr (type: PT_UINT64) */
uint64_t addr = extract__syscall_argument(regs, 0);
ringbuf__store_u64(&ringbuf, addr);
/* Parameter 3: length (type: PT_UINT64) */
uint64_t length = extract__syscall_argument(regs, 1);
ringbuf__store_u64(&ringbuf, length);
/* Parameter 4: prot (type: PT_FLAGS32) */
uint32_t flags = extract__syscall_argument(regs, 2);
ringbuf__store_u32(&ringbuf, prot_flags_to_scap(flags));
/*=============================== COLLECT PARAMETERS ===========================*/
ringbuf__submit_event(&ringbuf);

View File

@ -71,6 +71,14 @@ int BPF_PROG(munmap_x, struct pt_regs *regs, long ret) {
/* Parameter 4: vm_swap (type: PT_UINT32) */
ringbuf__store_u32(&ringbuf, swap_size);
/* Parameter 5: addr (type: PT_UINT64) */
unsigned long val = extract__syscall_argument(regs, 0);
ringbuf__store_u64(&ringbuf, val);
/* Parameter 6: length (type: PT_UINT64) */
val = extract__syscall_argument(regs, 1);
ringbuf__store_u64(&ringbuf, val);
/*=============================== COLLECT PARAMETERS ===========================*/
ringbuf__submit_event(&ringbuf);

View File

@ -21,7 +21,7 @@ int BPF_PROG(nanosleep_e, struct pt_regs *regs, long id) {
/*=============================== COLLECT PARAMETERS ===========================*/
/* Parameter 1: req (type: PT_RELTIME) */
/* Parameter 1: interval (type: PT_RELTIME) */
uint64_t nanosec = 0;
unsigned long ts_pointer = extract__syscall_argument(regs, 0);
if(bpf_core_type_exists(struct __kernel_timespec)) {
@ -60,6 +60,20 @@ int BPF_PROG(nanosleep_x, struct pt_regs *regs, long ret) {
/* Parameter 1: res (type: PT_ERRNO) */
ringbuf__store_s64(&ringbuf, ret);
/* Parameter 2: interval (type: PT_RELTIME) */
uint64_t nanosec = 0;
unsigned long ts_pointer = extract__syscall_argument(regs, 0);
if(bpf_core_type_exists(struct __kernel_timespec)) {
struct __kernel_timespec ts = {0};
bpf_probe_read_user(&ts, bpf_core_type_size(struct __kernel_timespec), (void *)ts_pointer);
nanosec = ((uint64_t)ts.tv_sec) * SECOND_TO_NS + ts.tv_nsec;
} else {
struct modern_bpf__kernel_timespec ts = {0};
bpf_probe_read_user(&ts, sizeof(ts), (void *)ts_pointer);
nanosec = ((uint64_t)ts.tv_sec) * SECOND_TO_NS + ts.tv_nsec;
}
ringbuf__store_u64(&ringbuf, nanosec);
/*=============================== COLLECT PARAMETERS ===========================*/
ringbuf__submit_event(&ringbuf);

View File

@ -70,6 +70,11 @@ int BPF_PROG(poll_x, struct pt_regs *regs, long ret) {
/* Parameter 2: fds (type: PT_FDLIST) */
auxmap__store_fdlist_param(auxmap, fds_pointer, nfds, RETURNED_EVENTS);
/* Parameter 3: timeout (type: PT_INT64) */
/* This is an `int` in the syscall signature but we push it as an `int64` */
uint32_t timeout_msecs = (int32_t)extract__syscall_argument(regs, 2);
auxmap__store_s64_param(auxmap, (int64_t)timeout_msecs);
/*=============================== COLLECT PARAMETERS ===========================*/
auxmap__finalize_event_header(auxmap);

View File

@ -87,7 +87,7 @@ int BPF_PROG(ppoll_x, struct pt_regs *regs, long ret) {
/*=============================== COLLECT PARAMETERS ===========================*/
/* Parameter 1: ret (type: PT_FD) */
/* Parameter 1: res (type: PT_ERRNO) */
auxmap__store_s64_param(auxmap, ret);
/* Get the `fds_pointer` and the number of `fds` from the syscall arguments */
@ -97,6 +97,38 @@ int BPF_PROG(ppoll_x, struct pt_regs *regs, long ret) {
/* Parameter 2: fds (type: PT_FDLIST) */
auxmap__store_fdlist_param(auxmap, fds_pointer, nfds, RETURNED_EVENTS);
/* Parameter 3: timeout (type: PT_RELTIME) */
uint64_t nanosec = 0;
unsigned long ts_pointer = extract__syscall_argument(regs, 2);
if(!bpf_in_ia32_syscall()) {
if(bpf_core_type_exists(struct __kernel_timespec)) {
struct __kernel_timespec ts = {0};
bpf_probe_read_user(&ts,
bpf_core_type_size(struct __kernel_timespec),
(void *)ts_pointer);
nanosec = ((uint64_t)ts.tv_sec) * SECOND_TO_NS + ts.tv_nsec;
} else {
struct modern_bpf__kernel_timespec ts = {0};
bpf_probe_read_user(&ts, sizeof(ts), (void *)ts_pointer);
nanosec = ((uint64_t)ts.tv_sec) * SECOND_TO_NS + ts.tv_nsec;
}
} else {
struct modern_bpf__kernel_timespec_ia32 ts = {0};
bpf_probe_read_user(&ts, sizeof(ts), (void *)ts_pointer);
nanosec = ((uint32_t)ts.tv_sec) * SECOND_TO_NS + ts.tv_nsec;
}
auxmap__store_u64_param(auxmap, nanosec);
/* Parameter 4: sigmask (type: PT_SIGSET) */
long unsigned int sigmask[1] = {0};
unsigned long sigmask_pointer = extract__syscall_argument(regs, 3);
if(bpf_probe_read_user(&sigmask, sizeof(sigmask), (void *)sigmask_pointer)) {
/* In case of invalid pointer, return 0 */
auxmap__store_u32_param(auxmap, (uint32_t)0);
} else {
auxmap__store_u32_param(auxmap, (uint32_t)sigmask[0]);
}
/*=============================== COLLECT PARAMETERS ===========================*/
auxmap__finalize_event_header(auxmap);

View File

@ -23,8 +23,8 @@ int BPF_PROG(preadv_e, struct pt_regs *regs, long id) {
/*=============================== COLLECT PARAMETERS ===========================*/
/* Parameter 1: fd (type: PT_FD) */
int32_t fd = (int32_t)extract__syscall_argument(regs, 0);
ringbuf__store_s64(&ringbuf, (int64_t)fd);
int64_t fd = (int64_t)(int32_t)extract__syscall_argument(regs, 0);
ringbuf__store_s64(&ringbuf, fd);
/* Parameter 2: pos (type: PT_UINT64) */
uint64_t pos = (uint64_t)extract__syscall_argument(regs, 3);
@ -85,6 +85,14 @@ int BPF_PROG(preadv_x, struct pt_regs *regs, long ret) {
auxmap__store_empty_param(auxmap);
}
/* Parameter 4: fd (type: PT_FD) */
int64_t fd = (int64_t)(int32_t)extract__syscall_argument(regs, 0);
auxmap__store_s64_param(auxmap, fd);
/* Parameter 5: pos (type: PT_UINT64) */
uint64_t pos = (uint64_t)extract__syscall_argument(regs, 3);
auxmap__store_u64_param(auxmap, pos);
/*=============================== COLLECT PARAMETERS ===========================*/
auxmap__finalize_event_header(auxmap);

View File

@ -67,6 +67,13 @@ int BPF_PROG(ptrace_x, struct pt_regs *regs, long ret) {
uint64_t data_pointer = (uint64_t)extract__syscall_argument(regs, 3);
auxmap__store_ptrace_data_param(auxmap, ret, scap_ptrace_request, data_pointer);
/* Parameter 4: request (type: PT_FLAGS16) */
auxmap__store_u16_param(auxmap, scap_ptrace_request);
/* Parameter 5: pid (type: PT_PID) */
pid_t pid = (int32_t)extract__syscall_argument(regs, 1);
auxmap__store_s64_param(auxmap, (int64_t)pid);
/*=============================== COLLECT PARAMETERS ===========================*/
auxmap__finalize_event_header(auxmap);

View File

@ -23,8 +23,8 @@ int BPF_PROG(pwritev_e, struct pt_regs *regs, long id) {
/*=============================== COLLECT PARAMETERS ===========================*/
/* Parameter 1: fd (type: PT_FD) */
int32_t fd = (int32_t)extract__syscall_argument(regs, 0);
ringbuf__store_s64(&ringbuf, (int64_t)fd);
int64_t fd = (int64_t)(int32_t)extract__syscall_argument(regs, 0);
ringbuf__store_s64(&ringbuf, fd);
unsigned long iov_pointer = extract__syscall_argument(regs, 1);
unsigned long iov_cnt = extract__syscall_argument(regs, 2);
@ -82,6 +82,17 @@ int BPF_PROG(pwritev_x, struct pt_regs *regs, long ret) {
/* Parameter 2: data (type: PT_BYTEBUF) */
auxmap__store_iovec_data_param(auxmap, iov_pointer, iov_cnt, snaplen);
/* Parameter 3: fd (type: PT_FD) */
int64_t fd = (int64_t)(int32_t)extract__syscall_argument(regs, 0);
auxmap__store_s64_param(auxmap, fd);
/* Parameter 4: size (type: PT_UINT32) */
auxmap__store_iovec_size_param(auxmap, iov_pointer, iov_cnt);
/* Parameter 5: pos (type: PT_UINT64) */
uint64_t pos = (uint64_t)extract__syscall_argument(regs, 3);
auxmap__store_u64_param(auxmap, pos);
/*=============================== COLLECT PARAMETERS ===========================*/
auxmap__finalize_event_header(auxmap);

View File

@ -205,6 +205,29 @@ int BPF_PROG(quotactl_x, struct pt_regs *regs, long ret) {
}
auxmap__store_u8_param(auxmap, quota_fmt_out);
/* Parameter 15: cmd (type: PT_FLAGS16) */
auxmap__store_u16_param(auxmap, scap_cmd);
/* Parameter 16: type (type: PT_FLAGS8) */
auxmap__store_u8_param(auxmap, quotactl_type_to_scap(cmd));
/* Parameter 17: id (type: PT_UINT32) */
uint32_t id = (uint32_t)extract__syscall_argument(regs, 2);
if(scap_cmd != PPM_Q_GETQUOTA && scap_cmd != PPM_Q_SETQUOTA && scap_cmd != PPM_Q_XGETQUOTA &&
scap_cmd != PPM_Q_XSETQLIM) {
/* In this case `id` don't represent a `userid` or a `groupid` */
auxmap__store_u32_param(auxmap, 0);
} else {
auxmap__store_u32_param(auxmap, id);
}
/* Parameter 18: quota_fmt (type: PT_FLAGS8) */
uint8_t quota_fmt = PPM_QFMT_NOT_USED;
if(scap_cmd == PPM_Q_QUOTAON) {
quota_fmt = quotactl_fmt_to_scap(id);
}
auxmap__store_u8_param(auxmap, quota_fmt);
/*=============================== COLLECT PARAMETERS ===========================*/
auxmap__finalize_event_header(auxmap);

View File

@ -23,8 +23,8 @@ int BPF_PROG(readv_e, struct pt_regs *regs, long id) {
/*=============================== COLLECT PARAMETERS ===========================*/
/* Parameter 1: fd (type: PT_FD) */
int32_t fd = (int32_t)extract__syscall_argument(regs, 0);
ringbuf__store_s64(&ringbuf, (int64_t)fd);
int64_t fd = (int64_t)(int32_t)extract__syscall_argument(regs, 0);
ringbuf__store_s64(&ringbuf, fd);
/*=============================== COLLECT PARAMETERS ===========================*/
@ -81,6 +81,10 @@ int BPF_PROG(readv_x, struct pt_regs *regs, long ret) {
auxmap__store_empty_param(auxmap);
}
/* Parameter 4: fd (type: PT_FD) */
int64_t fd = (int64_t)(int32_t)extract__syscall_argument(regs, 0);
auxmap__store_s64_param(auxmap, fd);
/*=============================== COLLECT PARAMETERS ===========================*/
auxmap__finalize_event_header(auxmap);

View File

@ -29,8 +29,8 @@ int BPF_PROG(recv_e, struct pt_regs *regs, long id) {
/*=============================== COLLECT PARAMETERS ===========================*/
/* Parameter 1: fd (type: PT_FD) */
int32_t fd = (int32_t)args[0];
ringbuf__store_s64(&ringbuf, (int64_t)fd);
int64_t fd = (int32_t)args[0];
ringbuf__store_s64(&ringbuf, fd);
/* Parameter 2: size (type: PT_UINT32) */
uint32_t size = (uint32_t)args[2];
@ -61,11 +61,15 @@ int BPF_PROG(recv_x, struct pt_regs *regs, long ret) {
/* Parameter 1: res (type: PT_ERRNO) */
auxmap__store_s64_param(auxmap, ret);
if(ret > 0) {
/* Collect parameters at the beginning to manage socketcalls */
unsigned long args[2] = {0};
extract__network_args(args, 2, regs);
/* Collect parameters at the beginning to manage socketcalls */
unsigned long args[5] = {0};
extract__network_args(args, 5, regs);
/* Parameter 2: data (type: PT_BYTEBUF) */
/* Send an empty parameter if the syscall failed (or the return value is zero): indeed, in this
* case, the content of the buffer provided by the user remains untouched, and is not important.
*/
if(ret > 0) {
dynamic_snaplen_args snaplen_args = {
.only_port_range = false,
.evt_type = PPME_SOCKET_RECV_X,
@ -75,12 +79,27 @@ int BPF_PROG(recv_x, struct pt_regs *regs, long ret) {
if(snaplen > ret) {
snaplen = ret;
}
/* Parameter 2: data (type: PT_BYTEBUF) */
unsigned long data_pointer = args[1];
auxmap__store_bytebuf_param(auxmap, data_pointer, snaplen, USER);
unsigned long received_data_pointer = args[1];
auxmap__store_bytebuf_param(auxmap, received_data_pointer, snaplen, USER);
} else {
auxmap__store_empty_param(auxmap);
}
/* Parameter 3: fd (type: PT_FD) */
int64_t fd = (int32_t)args[0];
auxmap__store_s64_param(auxmap, fd);
/* Parameter 4: size (type: PT_UINT32) */
uint32_t size = (uint32_t)args[2];
auxmap__store_u32_param(auxmap, size);
/* Parameter 5: tuple (type: PT_SOCKTUPLE) */
if(ret >= 0) {
struct sockaddr *usrsockaddr = (struct sockaddr *)args[4];
/* Notice: the following will push an empty parameter if
* something goes wrong (e.g.: fd not valid) */
auxmap__store_socktuple_param(auxmap, fd, INBOUND, NULL);
} else {
/* Parameter 2: data (type: PT_BYTEBUF) */
auxmap__store_empty_param(auxmap);
}

View File

@ -29,8 +29,8 @@ int BPF_PROG(recvfrom_e, struct pt_regs *regs, long id) {
/*=============================== COLLECT PARAMETERS ===========================*/
/* Parameter 1: fd (type: PT_FD) */
int32_t socket_fd = (int32_t)args[0];
ringbuf__store_s64(&ringbuf, (int64_t)socket_fd);
int64_t socket_fd = (int32_t)args[0];
ringbuf__store_s64(&ringbuf, socket_fd);
/* Parameter 2: size (type: PT_UINT32) */
uint32_t size = (uint32_t)args[2];
@ -61,6 +61,12 @@ int BPF_PROG(recvfrom_x, struct pt_regs *regs, long ret) {
/* Parameter 1: res (type: PT_ERRNO) */
auxmap__store_s64_param(auxmap, ret);
/* Collect parameters at the beginning to manage socketcalls */
unsigned long args[5] = {0};
extract__network_args(args, 5, regs);
int64_t socket_fd = (int32_t)args[0];
if(ret >= 0) {
/* We read the minimum between `snaplen` and what we really
* have in the buffer.
@ -75,17 +81,14 @@ int BPF_PROG(recvfrom_x, struct pt_regs *regs, long ret) {
snaplen = ret;
}
/* Collect parameters at the beginning to manage socketcalls */
unsigned long args[5] = {0};
extract__network_args(args, 5, regs);
/* Parameter 2: data (type: PT_BYTEBUF) */
unsigned long received_data_pointer = args[1];
auxmap__store_bytebuf_param(auxmap, received_data_pointer, snaplen, USER);
/* Parameter 3: tuple (type: PT_SOCKTUPLE) */
uint32_t socket_fd = (uint32_t)args[0];
struct sockaddr *usrsockaddr = (struct sockaddr *)args[4];
/* Notice: the following will push an empty parameter if something goes wrong (e.g.: fd not
* valid) */
auxmap__store_socktuple_param(auxmap, socket_fd, INBOUND, usrsockaddr);
} else {
/* Parameter 2: data (type: PT_BYTEBUF) */
@ -95,6 +98,13 @@ int BPF_PROG(recvfrom_x, struct pt_regs *regs, long ret) {
auxmap__store_empty_param(auxmap);
}
/* Parameter 4: fd (type: PT_FD) */
auxmap__store_s64_param(auxmap, socket_fd);
/* Parameter 5: size (type: PT_UINT32) */
uint32_t size = (uint32_t)args[2];
auxmap__store_u32_param(auxmap, size);
/*=============================== COLLECT PARAMETERS ===========================*/
auxmap__finalize_event_header(auxmap);

View File

@ -161,7 +161,7 @@ int BPF_PROG(recvmmsg_x, struct pt_regs *regs, long ret) {
.args = args,
};
uint32_t nr_loops = ret < 1024 ? ret : 1024;
uint32_t nr_loops = ret < MAX_SENDMMSG_RECVMMSG_SIZE ? ret : MAX_SENDMMSG_RECVMMSG_SIZE;
bpf_loop(nr_loops, handle_exit, &data, 0);
return 0;

View File

@ -16,8 +16,8 @@ int BPF_PROG(recvmsg_e, struct pt_regs *regs, long id) {
/* We need to keep this at the beginning of the program because otherwise we alter the state of
* the ebpf registers causing a verifier issue.
*/
unsigned long socket_fd = 0;
extract__network_args(&socket_fd, 1, regs);
unsigned long fd = 0;
extract__network_args(&fd, 1, regs);
struct ringbuf_struct ringbuf;
if(!ringbuf__reserve_space(&ringbuf, RECVMSG_E_SIZE, PPME_SOCKET_RECVMSG_E)) {
@ -29,7 +29,7 @@ int BPF_PROG(recvmsg_e, struct pt_regs *regs, long id) {
/*=============================== COLLECT PARAMETERS ===========================*/
/* Parameter 1: fd (type: PT_FD)*/
ringbuf__store_s64(&ringbuf, (int64_t)(int32_t)socket_fd);
ringbuf__store_s64(&ringbuf, (int64_t)(int32_t)fd);
/*=============================== COLLECT PARAMETERS ===========================*/
@ -56,6 +56,13 @@ int BPF_PROG(recvmsg_x, struct pt_regs *regs, long ret) {
/* Parameter 1: res (type: PT_ERRNO) */
auxmap__store_s64_param(auxmap, ret);
/* Collect parameters at the beginning to manage socketcalls. */
unsigned long args[2] = {0};
extract__network_args(args, 2, regs);
/* Get file descriptor. */
int64_t fd = (int32_t)args[0];
if(ret >= 0) {
/* Parameter 2: size (type: PT_UINT32) */
auxmap__store_u32_param(auxmap, (uint32_t)ret);
@ -73,18 +80,13 @@ int BPF_PROG(recvmsg_x, struct pt_regs *regs, long ret) {
snaplen = ret;
}
/* Collect parameters at the beginning to manage socketcalls */
unsigned long args[2] = {0};
extract__network_args(args, 2, regs);
/* Parameter 3: data (type: PT_BYTEBUF) */
unsigned long msghdr_pointer = args[1];
struct user_msghdr msghhdr =
auxmap__store_msghdr_data_param(auxmap, msghdr_pointer, snaplen);
/* Parameter 4: tuple (type: PT_SOCKTUPLE) */
uint32_t socket_fd = (uint32_t)args[0];
auxmap__store_socktuple_param(auxmap, socket_fd, INBOUND, msghhdr.msg_name);
auxmap__store_socktuple_param(auxmap, (uint32_t)fd, INBOUND, msghhdr.msg_name);
/* Parameter 5: msg_control (type: PT_BYTEBUF) */
/* We are limited to UINT16_MAX bytes of control data due to the size parameter in
@ -112,6 +114,9 @@ int BPF_PROG(recvmsg_x, struct pt_regs *regs, long ret) {
auxmap__store_empty_param(auxmap);
}
/* Parameter 6: fd (type: PT_FD) */
auxmap__store_s64_param(auxmap, fd);
/*=============================== COLLECT PARAMETERS ===========================*/
auxmap__finalize_event_header(auxmap);

View File

@ -21,10 +21,11 @@ int BPF_PROG(seccomp_e, struct pt_regs *regs, long id) {
/*=============================== COLLECT PARAMETERS ===========================*/
/* Parameter 1: operation (type: PT_UINT64)*/
/* Parameter 1: op (type: PT_UINT64) */
uint64_t operation = (uint64_t)extract__syscall_argument(regs, 0);
ringbuf__store_u64(&ringbuf, operation);
/* Parameter 2: flags (type: PT_UINT64) */
uint32_t flags = (uint32_t)extract__syscall_argument(regs, 1);
ringbuf__store_u64(&ringbuf, (uint64_t)flags);
@ -50,9 +51,17 @@ int BPF_PROG(seccomp_x, struct pt_regs *regs, long ret) {
/*=============================== COLLECT PARAMETERS ===========================*/
/* Parameter 1: res (type: PT_ERRNO)*/
/* Parameter 1: res (type: PT_ERRNO) */
ringbuf__store_s64(&ringbuf, ret);
/* Parameter 2: op (type: PT_UINT64) */
uint64_t operation = (uint64_t)extract__syscall_argument(regs, 0);
ringbuf__store_u64(&ringbuf, operation);
/* Parameter 2: flags (type: PT_UINT64) */
uint32_t flags = (uint32_t)extract__syscall_argument(regs, 1);
ringbuf__store_u64(&ringbuf, (uint64_t)flags);
/*=============================== COLLECT PARAMETERS ===========================*/
ringbuf__submit_event(&ringbuf);

View File

@ -61,6 +61,25 @@ int BPF_PROG(semctl_x, struct pt_regs *regs, long ret) {
/* Parameter 1: res (type: PT_ERRNO) */
ringbuf__store_s64(&ringbuf, (int64_t)ret);
/* Parameter 2: semid (type: PT_INT32) */
int32_t semid = (int32_t)extract__syscall_argument(regs, 0);
ringbuf__store_s32(&ringbuf, semid);
/* Parameter 3: semnum (type: PT_INT32) */
int32_t semnum = (int32_t)extract__syscall_argument(regs, 1);
ringbuf__store_s32(&ringbuf, semnum);
/* Parameter 4: cmd (type: PT_FLAGS16) */
uint16_t cmd = (uint16_t)extract__syscall_argument(regs, 2);
ringbuf__store_u16(&ringbuf, semctl_cmd_to_scap(cmd));
/* Parameter 5: val (type: PT_INT32) */
int32_t val = 0;
if(cmd == SETVAL) {
val = (int32_t)extract__syscall_argument(regs, 3);
}
ringbuf__store_s32(&ringbuf, val);
/*=============================== COLLECT PARAMETERS ===========================*/
ringbuf__submit_event(&ringbuf);

View File

@ -54,6 +54,18 @@ int BPF_PROG(semget_x, struct pt_regs *regs, long ret) {
/* Parameter 1: res (type: PT_ERRNO) */
ringbuf__store_s64(&ringbuf, (int64_t)ret);
/* Parameter 2: key (type: PT_INT32) */
int32_t key = (int32_t)extract__syscall_argument(regs, 0);
ringbuf__store_s32(&ringbuf, key);
/* Parameter 3: nsems (type: PT_INT32) */
int32_t nsems = (int32_t)extract__syscall_argument(regs, 1);
ringbuf__store_s32(&ringbuf, nsems);
/* Parameter 4: semflg (type: PT_FLAGS32) */
uint32_t semflg = (uint32_t)extract__syscall_argument(regs, 2);
ringbuf__store_u32(&ringbuf, semget_flags_to_scap(semflg));
/*=============================== COLLECT PARAMETERS ===========================*/
ringbuf__submit_event(&ringbuf);

View File

@ -21,7 +21,7 @@ int BPF_PROG(semop_e, struct pt_regs *regs, long id) {
/*=============================== COLLECT PARAMETERS ===========================*/
/* Parameter 1: semid (type: PT_INT32)*/
/* Parameter 1: semid (type: PT_INT32) */
int32_t semid = (int32_t)extract__syscall_argument(regs, 0);
ringbuf__store_s32(&ringbuf, semid);
@ -92,6 +92,10 @@ int BPF_PROG(semop_x, struct pt_regs *regs, long ret) {
/* Parameter 8: sem_flg_1 (type: PT_FLAGS16) */
ringbuf__store_u16(&ringbuf, semop_flags_to_scap(sops[1].sem_flg));
/* Parameter 9: semid (type: PT_INT32) */
int32_t semid = (int32_t)extract__syscall_argument(regs, 0);
ringbuf__store_s32(&ringbuf, semid);
/*=============================== COLLECT PARAMETERS ===========================*/
ringbuf__submit_event(&ringbuf);

View File

@ -29,8 +29,8 @@ int BPF_PROG(send_e, struct pt_regs *regs, long id) {
/*=============================== COLLECT PARAMETERS ===========================*/
/* Parameter 1: fd (type: PT_FD) */
int32_t fd = (int32_t)args[0];
ringbuf__store_s64(&ringbuf, (int64_t)fd);
int64_t fd = (int32_t)args[0];
ringbuf__store_s64(&ringbuf, fd);
/* Parameter 2: size (type: PT_UINT32) */
uint32_t size = (uint32_t)args[2];
@ -62,16 +62,23 @@ int BPF_PROG(send_x, struct pt_regs *regs, long ret) {
auxmap__store_s64_param(auxmap, ret);
/* Collect parameters at the beginning to manage socketcalls */
unsigned long args[3] = {0};
extract__network_args(args, 3, regs);
unsigned long args[5] = {0};
extract__network_args(args, 5, regs);
dynamic_snaplen_args snaplen_args = {
.only_port_range = false,
.evt_type = PPME_SOCKET_SEND_X,
};
int64_t bytes_to_read = ret > 0 ? ret : args[2];
uint16_t snaplen = maps__get_snaplen();
apply_dynamic_snaplen(regs, &snaplen, &snaplen_args);
/* Extract size syscall parameter */
uint32_t size = (uint32_t)args[2];
/* If the syscall doesn't fail we use the return value as `size`
* otherwise we need to rely on the syscall parameter provided by the user */
int64_t bytes_to_read = ret > 0 ? ret : (int64_t)size;
if((int64_t)snaplen > bytes_to_read) {
snaplen = bytes_to_read;
}
@ -80,6 +87,23 @@ int BPF_PROG(send_x, struct pt_regs *regs, long ret) {
unsigned long sent_data_pointer = args[1];
auxmap__store_bytebuf_param(auxmap, sent_data_pointer, snaplen, USER);
/* Parameter 3: fd (type: PT_FD) */
int64_t fd = (int32_t)args[0];
auxmap__store_s64_param(auxmap, fd);
/* Parameter 4: size (type: PT_UINT32) */
auxmap__store_u32_param(auxmap, size);
/* Parameter 5: tuple (type: PT_SOCKTUPLE) */
if(ret >= 0) {
struct sockaddr *usrsockaddr = (struct sockaddr *)args[4];
/* Notice: the following will push an empty parameter if
* something goes wrong (e.g.: fd not valid) */
auxmap__store_socktuple_param(auxmap, fd, OUTBOUND, NULL);
} else {
auxmap__store_empty_param(auxmap);
}
/*=============================== COLLECT PARAMETERS ===========================*/
auxmap__finalize_event_header(auxmap);

View File

@ -22,12 +22,12 @@ int BPF_PROG(sendfile_e, struct pt_regs *regs, long id) {
/*=============================== COLLECT PARAMETERS ===========================*/
/* Parameter 1: out_fd (type: PT_FD) */
int32_t out_fd = (int32_t)extract__syscall_argument(regs, 0);
ringbuf__store_s64(&ringbuf, (int64_t)out_fd);
int64_t out_fd = (int64_t)(int32_t)extract__syscall_argument(regs, 0);
ringbuf__store_s64(&ringbuf, out_fd);
/* Parameter 2: in_fd (type: PT_FD) */
int32_t in_fd = (int32_t)extract__syscall_argument(regs, 1);
ringbuf__store_s64(&ringbuf, (int64_t)in_fd);
int64_t in_fd = (int64_t)(int32_t)extract__syscall_argument(regs, 1);
ringbuf__store_s64(&ringbuf, in_fd);
/* Parameter 3: offset (type: PT_UINT64) */
unsigned long offset = 0;
@ -70,6 +70,18 @@ int BPF_PROG(sendfile_x, struct pt_regs *regs, long ret) {
bpf_probe_read_user((void *)&offset, sizeof(offset), (void *)offset_pointer);
ringbuf__store_u64(&ringbuf, offset);
/* Parameter 3: out_fd (type: PT_FD) */
int64_t out_fd = (int64_t)(int32_t)extract__syscall_argument(regs, 0);
ringbuf__store_s64(&ringbuf, out_fd);
/* Parameter 4: in_fd (type: PT_FD) */
int64_t in_fd = (int64_t)(int32_t)extract__syscall_argument(regs, 1);
ringbuf__store_s64(&ringbuf, in_fd);
/* Parameter 5: size (type: PT_UINT64) */
uint64_t size = extract__syscall_argument(regs, 3);
ringbuf__store_u64(&ringbuf, size);
/*=============================== COLLECT PARAMETERS ===========================*/
ringbuf__submit_event(&ringbuf);

View File

@ -147,7 +147,7 @@ int BPF_PROG(sendmmsg_x, struct pt_regs *regs, long ret) {
.args = args,
};
uint32_t nr_loops = ret < 1024 ? ret : 1024;
uint32_t nr_loops = ret < MAX_SENDMMSG_RECVMMSG_SIZE ? ret : MAX_SENDMMSG_RECVMMSG_SIZE;
bpf_loop(nr_loops, handle_exit, &data, 0);
return 0;

View File

@ -75,28 +75,71 @@ int BPF_PROG(sendmsg_x, struct pt_regs *regs, long ret) {
/* Parameter 1: res (type: PT_ERRNO) */
auxmap__store_s64_param(auxmap, ret);
/* Collect parameters at the beginning to manage socketcalls */
/* Collect parameters at the beginning to manage socketcalls. */
unsigned long args[2] = {0};
extract__network_args(args, 2, regs);
/* In case of failure `bytes_to_read` could be also lower than `snaplen`
* but we will discover it directly into `auxmap__store_iovec_data_param`
* otherwise we need to extract it now and it has a cost. Here we check just
* the return value if the syscall is successful.
*/
uint16_t snaplen = maps__get_snaplen();
dynamic_snaplen_args snaplen_args = {
.only_port_range = true,
.evt_type = PPME_SOCKET_SENDMSG_X,
};
apply_dynamic_snaplen(regs, &snaplen, &snaplen_args);
if(ret > 0 && snaplen > ret) {
snaplen = ret;
}
/* Parameter 2: data (type: PT_BYTEBUF) */
/* Extract socket fd and msghdr pointer syscall parameters. */
int64_t fd = (int32_t)args[0];
unsigned long msghdr_pointer = args[1];
auxmap__store_msghdr_data_param(auxmap, msghdr_pointer, snaplen);
/* Extract the content of msghdr and use it to derive the parameters. */
struct user_msghdr msghdr = {0};
if(unlikely(extract__msghdr(&msghdr, msghdr_pointer) < 0)) {
/* Parameter 2: data (type: PT_BYTEBUF) */
auxmap__store_empty_param(auxmap);
/* Parameter 3: fd (type: PT_FD) */
auxmap__store_s64_param(auxmap, fd);
/* Parameter 4: size (type: PT_UINT32) */
auxmap__store_empty_param(auxmap);
/* Parameter 5: tuple (type: PT_SOCKTUPLE) */
auxmap__store_empty_param(auxmap);
} else {
/* In case of failure `bytes_to_read` could be also lower than `snaplen`
* but we will discover it directly into `auxmap__store_iovec_data_param`
* otherwise we need to extract it now and it has a cost. Here we check just
* the return value if the syscall is successful.
*/
uint16_t snaplen = maps__get_snaplen();
dynamic_snaplen_args snaplen_args = {
.only_port_range = true,
.evt_type = PPME_SOCKET_SENDMSG_X,
};
apply_dynamic_snaplen(regs, &snaplen, &snaplen_args);
if(ret > 0 && snaplen > ret) {
snaplen = ret;
}
unsigned long iov_pointer = (unsigned long)msghdr.msg_iov;
uint32_t iov_cnt = msghdr.msg_iovlen;
/* Parameter 2: data (type: PT_BYTEBUF) */
auxmap__store_iovec_data_param(auxmap, (unsigned long)iov_pointer, iov_cnt, snaplen);
/* Parameter 3: fd (type: PT_FD) */
auxmap__store_s64_param(auxmap, fd);
/* Parameter 4: size (type: PT_UINT32) */
/* Use the second part of our auxmap as a scratch space for the `extract__iovec_size` helper
* to read the iovec structs in. */
void *scratch_space = (void *)&auxmap->data[MAX_PARAM_SIZE];
uint32_t scratch_space_size = SAFE_ACCESS(iov_cnt * bpf_core_type_size(struct iovec));
uint32_t size =
extract__iovec_size(scratch_space, scratch_space_size, iov_pointer, iov_cnt);
auxmap__store_u32_param(auxmap, size);
/* Parameter 5: tuple (type: PT_SOCKTUPLE) */
if(ret >= 0) {
struct sockaddr *usrsockaddr = (struct sockaddr *)msghdr.msg_name;
/* Notice: the following will push an empty parameter if something goes wrong. */
auxmap__store_socktuple_param(auxmap, fd, OUTBOUND, usrsockaddr);
} else {
auxmap__store_empty_param(auxmap);
}
}
/*=============================== COLLECT PARAMETERS ===========================*/

View File

@ -25,26 +25,24 @@ int BPF_PROG(sendto_e, struct pt_regs *regs, long id) {
extract__network_args(args, 5, regs);
/* Parameter 1: fd (type: PT_FD) */
int32_t socket_fd = (int32_t)args[0];
auxmap__store_s64_param(auxmap, (int64_t)socket_fd);
int64_t socket_fd = (int32_t)args[0];
auxmap__store_s64_param(auxmap, socket_fd);
/* Parameter 2: size (type: PT_UINT32) */
uint32_t size = (uint32_t)args[2];
auxmap__store_u32_param(auxmap, size);
/* Parameter 3: tuple (type: PT_SOCKTUPLE)*/
/* Parameter 3: tuple (type: PT_SOCKTUPLE) */
/* TODO: Here we don't know if this fd is a socket or not,
* since we are in the enter event and the syscall could fail.
* This shouldn't be a problem since if it is not a socket fd
* the `bpf_probe_read()` call we fail. Probably we have to move it
* in the exit event.
* since we are in the enter event and the syscall could fail.
* This shouldn't be a problem since if it is not a socket fd
* the `bpf_probe_read()` call will fail. Probably we have to move it
* in the exit event.
*/
if(socket_fd >= 0) {
struct sockaddr *usrsockaddr = (struct sockaddr *)args[4];
auxmap__store_socktuple_param(auxmap, socket_fd, OUTBOUND, usrsockaddr);
} else {
auxmap__store_empty_param(auxmap);
}
struct sockaddr *usrsockaddr = (struct sockaddr *)args[4];
/* Notice: the following will push an empty parameter if
* something goes wrong (e.g.: fd not valid) */
auxmap__store_socktuple_param(auxmap, socket_fd, OUTBOUND, usrsockaddr);
/*=============================== COLLECT PARAMETERS ===========================*/
@ -74,19 +72,23 @@ int BPF_PROG(sendto_x, struct pt_regs *regs, long ret) {
auxmap__store_s64_param(auxmap, ret);
/* Collect parameters at the beginning to manage socketcalls */
unsigned long args[3] = {0};
extract__network_args(args, 3, regs);
unsigned long args[5] = {0};
extract__network_args(args, 5, regs);
/* If the syscall doesn't fail we use the return value as `size`
* otherwise we need to rely on the syscall parameter provided by the user.
*/
dynamic_snaplen_args snaplen_args = {
.only_port_range = false,
.evt_type = PPME_SOCKET_SENDTO_X,
};
int64_t bytes_to_read = ret > 0 ? ret : args[2];
uint16_t snaplen = maps__get_snaplen();
apply_dynamic_snaplen(regs, &snaplen, &snaplen_args);
/* Extract size syscall parameter */
uint32_t size = (uint32_t)args[2];
/* If the syscall doesn't fail we use the return value as `size`
* otherwise we need to rely on the syscall parameter provided by the user. */
int64_t bytes_to_read = ret > 0 ? ret : (int64_t)size;
if((int64_t)snaplen > bytes_to_read) {
snaplen = bytes_to_read;
}
@ -95,6 +97,23 @@ int BPF_PROG(sendto_x, struct pt_regs *regs, long ret) {
unsigned long sent_data_pointer = args[1];
auxmap__store_bytebuf_param(auxmap, sent_data_pointer, snaplen, USER);
/* Parameter 3: fd (type: PT_FD) */
int64_t socket_fd = (int32_t)args[0];
auxmap__store_s64_param(auxmap, socket_fd);
/* Parameter 4: size (type: PT_UINT32) */
auxmap__store_u32_param(auxmap, size);
/* Parameter 5: tuple (type: PT_SOCKTUPLE) */
if(ret >= 0) {
struct sockaddr *usrsockaddr = (struct sockaddr *)args[4];
/* Notice: the following will push an empty parameter if
* something goes wrong (e.g.: fd not valid) */
auxmap__store_socktuple_param(auxmap, socket_fd, OUTBOUND, usrsockaddr);
} else {
auxmap__store_empty_param(auxmap);
}
/*=============================== COLLECT PARAMETERS ===========================*/
auxmap__finalize_event_header(auxmap);

View File

@ -50,6 +50,10 @@ int BPF_PROG(setgid_x, struct pt_regs *regs, long ret) {
/* Parameter 1: res (type: PT_ERRNO) */
ringbuf__store_s64(&ringbuf, ret);
/* Parameter 2: gid (type: PT_GID) */
uint32_t gid = (uint32_t)extract__syscall_argument(regs, 0);
ringbuf__store_u32(&ringbuf, gid);
/*=============================== COLLECT PARAMETERS ===========================*/
ringbuf__submit_event(&ringbuf);

View File

@ -54,6 +54,14 @@ int BPF_PROG(setns_x, struct pt_regs *regs, long ret) {
/* Parameter 1: res (type: PT_FD)*/
ringbuf__store_s64(&ringbuf, ret);
/* Parameter 2: fd (type: PT_FD) */
int32_t fd = (int32_t)extract__syscall_argument(regs, 0);
ringbuf__store_s64(&ringbuf, (int64_t)fd);
/* Parameter 3: nstype (type: PT_FLAGS32) */
unsigned long nstype = extract__syscall_argument(regs, 1);
ringbuf__store_u32(&ringbuf, clone_flags_to_scap((int)nstype));
/*=============================== COLLECT PARAMETERS ===========================*/
ringbuf__submit_event(&ringbuf);

View File

@ -51,9 +51,17 @@ int BPF_PROG(setpgid_x, struct pt_regs *regs, long ret) {
/*=============================== COLLECT PARAMETERS ===========================*/
/* Parameter 1: res (type: PT_PID)*/
/* Parameter 1: res (type: PT_ERRNO)*/
ringbuf__store_s64(&ringbuf, ret);
/* Parameter 2: pid (type: PT_FD) */
pid_t pid = (int32_t)extract__syscall_argument(regs, 0);
ringbuf__store_s64(&ringbuf, (int64_t)pid);
/* Parameter 3: pgid (type: PT_PID) */
pid_t pgid = (int32_t)extract__syscall_argument(regs, 1);
ringbuf__store_s64(&ringbuf, (int64_t)pgid);
/*=============================== COLLECT PARAMETERS ===========================*/
ringbuf__submit_event(&ringbuf);

View File

@ -58,6 +58,18 @@ int BPF_PROG(setresgid_x, struct pt_regs *regs, long ret) {
/* Parameter 1: res (type: PT_ERRNO)*/
ringbuf__store_s64(&ringbuf, ret);
/* Parameter 2: rgid (type: PT_GID) */
gid_t rgid = (uint32_t)extract__syscall_argument(regs, 0);
ringbuf__store_u32(&ringbuf, rgid);
/* Parameter 3: egid (type: PT_GID) */
gid_t egid = (uint32_t)extract__syscall_argument(regs, 1);
ringbuf__store_u32(&ringbuf, egid);
/* Parameter 4: sgid (type: PT_GID) */
gid_t sgid = (uint32_t)extract__syscall_argument(regs, 2);
ringbuf__store_u32(&ringbuf, sgid);
/*=============================== COLLECT PARAMETERS ===========================*/
ringbuf__submit_event(&ringbuf);

View File

@ -58,6 +58,18 @@ int BPF_PROG(setresuid_x, struct pt_regs *regs, long ret) {
/* Parameter 1: res (type: PT_ERRNO)*/
ringbuf__store_s64(&ringbuf, ret);
/* Parameter 2: ruid (type: PT_GID) */
uid_t ruid = (uint32_t)extract__syscall_argument(regs, 0);
ringbuf__store_u32(&ringbuf, ruid);
/* Parameter 3: euid (type: PT_GID) */
uid_t euid = (uint32_t)extract__syscall_argument(regs, 1);
ringbuf__store_u32(&ringbuf, euid);
/* Parameter 4: suid (type: PT_GID) */
uid_t suid = (uint32_t)extract__syscall_argument(regs, 2);
ringbuf__store_u32(&ringbuf, suid);
/*=============================== COLLECT PARAMETERS ===========================*/
ringbuf__submit_event(&ringbuf);

View File

@ -50,6 +50,10 @@ int BPF_PROG(setuid_x, struct pt_regs *regs, long ret) {
/* Parameter 1: res (type: PT_ERRNO) */
ringbuf__store_s64(&ringbuf, ret);
/* Parameter 2: uid (type: PT_UID) */
uid_t uid = (uint32_t)extract__syscall_argument(regs, 0);
ringbuf__store_u32(&ringbuf, uid);
/*=============================== COLLECT PARAMETERS ===========================*/
ringbuf__submit_event(&ringbuf);

View File

@ -28,8 +28,8 @@ int BPF_PROG(shutdown_e, struct pt_regs *regs, long id) {
/*=============================== COLLECT PARAMETERS ===========================*/
/* Parameter 1: fd (type: PT_FD) */
int32_t fd = (int32_t)args[0];
ringbuf__store_s64(&ringbuf, (int64_t)fd);
int64_t fd = (int32_t)args[0];
ringbuf__store_s64(&ringbuf, fd);
/* Parameter 2: how (type: PT_ENUMFLAGS8) */
int how = (int32_t)args[1];
@ -48,6 +48,12 @@ int BPF_PROG(shutdown_e, struct pt_regs *regs, long id) {
SEC("tp_btf/sys_exit")
int BPF_PROG(shutdown_x, struct pt_regs *regs, long ret) {
/* We need to keep this at the beginning of the program because otherwise we alter the state of
* the ebpf registers causing a verifier issue.
*/
unsigned long args[2] = {0};
extract__network_args(args, 2, regs);
struct ringbuf_struct ringbuf;
if(!ringbuf__reserve_space(&ringbuf, SHUTDOWN_X_SIZE, PPME_SOCKET_SHUTDOWN_X)) {
return 0;
@ -57,9 +63,17 @@ int BPF_PROG(shutdown_x, struct pt_regs *regs, long ret) {
/*=============================== COLLECT PARAMETERS ===========================*/
/* Parameter 1: res (type: PT_ERRNO)*/
/* Parameter 1: res (type: PT_ERRNO) */
ringbuf__store_s64(&ringbuf, ret);
/* Parameter 2: fd (type: PT_FD) */
int64_t fd = (int32_t)args[0];
ringbuf__store_s64(&ringbuf, fd);
/* Parameter 3: how (type: PT_ENUMFLAGS8) */
int how = (int32_t)args[1];
ringbuf__store_u8(&ringbuf, (uint8_t)shutdown_how_to_scap(how));
/*=============================== COLLECT PARAMETERS ===========================*/
ringbuf__submit_event(&ringbuf);

View File

@ -22,8 +22,8 @@ int BPF_PROG(signalfd_e, struct pt_regs *regs, long id) {
/*=============================== COLLECT PARAMETERS ===========================*/
/* Parameter 1: fd (type: PT_FD) */
int32_t fd = (int32_t)extract__syscall_argument(regs, 0);
ringbuf__store_s64(&ringbuf, (int64_t)fd);
int64_t fd = (int64_t)(int32_t)extract__syscall_argument(regs, 0);
ringbuf__store_s64(&ringbuf, fd);
/* Parameter 2: mask (type: PT_UINT32) */
/* Right now we are not interested in the `sigmask`, we can populate it if we need */
@ -57,9 +57,23 @@ int BPF_PROG(signalfd_x, struct pt_regs *regs, long ret) {
/*=============================== COLLECT PARAMETERS ===========================*/
/* Parameter 1: res (type: PT_FD)*/
/* Parameter 1: res (type: PT_FD) */
ringbuf__store_s64(&ringbuf, ret);
/* Parameter 2: fd (type: PT_FD) */
int64_t fd = (int64_t)(int32_t)extract__syscall_argument(regs, 0);
ringbuf__store_s64(&ringbuf, fd);
/* Parameter 3: mask (type: PT_UINT32) */
/* Right now we are not interested in the `sigmask`, we can populate it if we need */
ringbuf__store_u32(&ringbuf, 0);
/* Parameter 4: flags (type: PT_UINT8) */
/* The syscall `signalfd` has no flags! only `signalfd4` has the `flags` param.
* For compatibility with the event definition here we send `0` as flags.
*/
ringbuf__store_u8(&ringbuf, 0);
/*=============================== COLLECT PARAMETERS ===========================*/
ringbuf__submit_event(&ringbuf);

View File

@ -22,8 +22,8 @@ int BPF_PROG(signalfd4_e, struct pt_regs *regs, long id) {
/*=============================== COLLECT PARAMETERS ===========================*/
/* Parameter 1: fd (type: PT_FD) */
int32_t fd = (int32_t)extract__syscall_argument(regs, 0);
ringbuf__store_s64(&ringbuf, (int64_t)fd);
int64_t fd = (int64_t)(int32_t)extract__syscall_argument(regs, 0);
ringbuf__store_s64(&ringbuf, fd);
/* Parameter 2: mask (type: PT_UINT32) */
/* Right now we are not interested in the `sigmask`, we can populate it if we need */
@ -51,13 +51,21 @@ int BPF_PROG(signalfd4_x, struct pt_regs *regs, long ret) {
/*=============================== COLLECT PARAMETERS ===========================*/
/* Parameter 1: res (type: PT_FD)*/
ringbuf__store_s64(&ringbuf, ret);
/* Parameter 1: res (type: PT_FD) */
ringbuf__store_s64(&ringbuf, (int64_t)(int32_t)ret);
/* Parameter 2: flags (type: PT_FLAGS16) */
int32_t flags = (int32_t)extract__syscall_argument(regs, 3);
ringbuf__store_u16(&ringbuf, signalfd4_flags_to_scap(flags));
/* Parameter 3: fd (type: PT_FD) */
int64_t fd = (int64_t)(int32_t)extract__syscall_argument(regs, 0);
ringbuf__store_s64(&ringbuf, fd);
/* Parameter 4: mask (type: PT_UINT32) */
/* Right now we are not interested in the `sigmask`, we can populate it if we need */
ringbuf__store_u32(&ringbuf, 0);
/*=============================== COLLECT PARAMETERS ===========================*/
ringbuf__submit_event(&ringbuf);

View File

@ -76,7 +76,7 @@ int BPF_PROG(socket_x, struct pt_regs *regs, long ret) {
/* Just called once by our scap process */
if(ret >= 0 && maps__get_socket_file_ops() == NULL) {
struct task_struct *task = get_current_task();
/* Please note that in `g_settings.scap_tid` scap will put its virtual tid
/* Please note that in `settings.scap_tid` scap will put its virtual tid
* if it is running inside a container. If we want to extract the same information
* in the kernel we need to extract the virtual tid of the task.
*/

View File

@ -28,17 +28,17 @@ int BPF_PROG(socketpair_e, struct pt_regs *regs, long id) {
/*=============================== COLLECT PARAMETERS ===========================*/
/* Parameter 1: domain (type: PT_ENUMFLAGS32) */
/* why to send 32 bits if we need only 8 bits? */
/* Why to send 32 bits if we need only 8 bits? */
uint8_t domain = (uint8_t)args[0];
ringbuf__store_u32(&ringbuf, (uint32_t)socket_family_to_scap(domain));
/* Parameter 2: type (type: PT_UINT32) */
/* this should be an int, not a uint32 */
/* This should be an int, not an uint32. */
uint32_t type = (uint32_t)args[1];
ringbuf__store_u32(&ringbuf, type);
/* Parameter 3: proto (type: PT_UINT32) */
/* this should be an int, not a uint32 */
/* This should be an int, not an uint32. */
uint32_t proto = (uint32_t)args[2];
ringbuf__store_u32(&ringbuf, proto);
@ -55,6 +55,12 @@ int BPF_PROG(socketpair_e, struct pt_regs *regs, long id) {
SEC("tp_btf/sys_exit")
int BPF_PROG(socketpair_x, struct pt_regs *regs, long ret) {
/* We need to keep this at the beginning of the program because otherwise we alter the state of
* the ebpf registers causing a verifier issue.
*/
unsigned long args[4] = {0};
extract__network_args(args, 4, regs);
struct ringbuf_struct ringbuf;
if(!ringbuf__reserve_space(&ringbuf, SOCKETPAIR_X_SIZE, PPME_SOCKET_SOCKETPAIR_X)) {
return 0;
@ -68,18 +74,13 @@ int BPF_PROG(socketpair_x, struct pt_regs *regs, long ret) {
ringbuf__store_s64(&ringbuf, ret);
int32_t fds[2] = {-1, -1};
unsigned long source = 0;
unsigned long peer = 0;
unsigned long fds_pointer = 0;
uint64_t source = 0;
uint64_t peer = 0;
/* In case of success we have 0. */
if(ret == 0) {
/* Collect parameters at the beginning to manage socketcalls */
unsigned long args[4] = {0};
extract__network_args(args, 4, regs);
/* Get new sockets. */
fds_pointer = args[3];
void *fds_pointer = (void *)args[3];
bpf_probe_read_user((void *)fds, 2 * sizeof(int32_t), (void *)fds_pointer);
/* Get source and peer. */
@ -104,6 +105,21 @@ int BPF_PROG(socketpair_x, struct pt_regs *regs, long ret) {
/* Parameter 5: peer (type: PT_UINT64) */
ringbuf__store_u64(&ringbuf, peer);
/* Parameter 6: domain (type: PT_ENUMFLAGS32) */
/* Why to send 32 bits if we need only 8 bits? */
uint8_t domain = (uint8_t)args[0];
ringbuf__store_u32(&ringbuf, (uint32_t)socket_family_to_scap(domain));
/* Parameter 7: type (type: PT_UINT32) */
/* This should be an int, not an uint32. */
uint32_t type = (uint32_t)args[1];
ringbuf__store_u32(&ringbuf, type);
/* Parameter 8: proto (type: PT_UINT32) */
/* This should be an int, not an uint32. */
uint32_t proto = (uint32_t)args[2];
ringbuf__store_u32(&ringbuf, proto);
/*=============================== COLLECT PARAMETERS ===========================*/
ringbuf__submit_event(&ringbuf);

View File

@ -22,12 +22,12 @@ int BPF_PROG(splice_e, struct pt_regs *regs, long id) {
/*=============================== COLLECT PARAMETERS ===========================*/
/* Parameter 1: fd_in (type: PT_FD) */
int32_t fd_in = (int32_t)extract__syscall_argument(regs, 0);
ringbuf__store_s64(&ringbuf, (int64_t)fd_in);
int64_t fd_in = (int64_t)(int32_t)extract__syscall_argument(regs, 0);
ringbuf__store_s64(&ringbuf, fd_in);
/* Parameter 2: fd_out (type: PT_FD) */
int32_t fd_out = (int32_t)extract__syscall_argument(regs, 2);
ringbuf__store_s64(&ringbuf, (int64_t)fd_out);
int64_t fd_out = (int64_t)(int32_t)extract__syscall_argument(regs, 2);
ringbuf__store_s64(&ringbuf, fd_out);
/* Parameter 3: size (type: PT_UINT64) */
uint64_t size = extract__syscall_argument(regs, 4);
@ -62,6 +62,22 @@ int BPF_PROG(splice_x, struct pt_regs *regs, long ret) {
/* Parameter 1: res (type: PT_ERRNO) */
ringbuf__store_s64(&ringbuf, (int64_t)ret);
/* Parameter 2: fd_in (type: PT_FD) */
int64_t fd_in = (int64_t)(int32_t)extract__syscall_argument(regs, 0);
ringbuf__store_s64(&ringbuf, fd_in);
/* Parameter 3: fd_out (type: PT_FD) */
int64_t fd_out = (int64_t)(int32_t)extract__syscall_argument(regs, 2);
ringbuf__store_s64(&ringbuf, fd_out);
/* Parameter 4: size (type: PT_UINT64) */
uint64_t size = extract__syscall_argument(regs, 4);
ringbuf__store_u64(&ringbuf, size);
/* Parameter 5: flags (type: PT_FLAGS32) */
uint32_t flags = extract__syscall_argument(regs, 5);
ringbuf__store_u32(&ringbuf, splice_flags_to_scap(flags));
/*=============================== COLLECT PARAMETERS ===========================*/
ringbuf__submit_event(&ringbuf);

View File

@ -54,9 +54,21 @@ int BPF_PROG(tgkill_x, struct pt_regs *regs, long ret) {
ringbuf__store_event_header(&ringbuf);
/*=============================== COLLECT PARAMETERS ===========================*/
/* Parameter 1: res (type: PT_ERRNO)*/
/* Parameter 1: res (type: PT_ERRNO) */
ringbuf__store_s64(&ringbuf, ret);
/* Parameter 2: pid (type: PT_PID) */
pid_t pid = (int32_t)extract__syscall_argument(regs, 0);
ringbuf__store_s64(&ringbuf, (int64_t)pid);
/* Parameter 3: tid (type: PT_PID) */
pid_t tid = (int32_t)extract__syscall_argument(regs, 1);
ringbuf__store_s64(&ringbuf, (int64_t)tid);
/* Parameter 4: sig (type: PT_SIGTYPE) */
uint8_t sig = (uint8_t)extract__syscall_argument(regs, 2);
ringbuf__store_u8(&ringbuf, sig);
/*=============================== COLLECT PARAMETERS ===========================*/
ringbuf__submit_event(&ringbuf);

View File

@ -51,9 +51,17 @@ int BPF_PROG(timerfd_create_x, struct pt_regs *regs, long ret) {
/*=============================== COLLECT PARAMETERS ===========================*/
/* Parameter 1: res (type: PT_FD)*/
/* Parameter 1: res (type: PT_FD) */
ringbuf__store_s64(&ringbuf, ret);
/* Parameter 2: clockid (type: PT_UINT8) */
/* Like in the old probe we send `0` */
ringbuf__store_u8(&ringbuf, 0);
/* Parameter 3: flags (type: PT_UINT8) */
/* Like in the old probe we send `0` */
ringbuf__store_u8(&ringbuf, 0);
/*=============================== COLLECT PARAMETERS ===========================*/
ringbuf__submit_event(&ringbuf);

View File

@ -50,9 +50,17 @@ int BPF_PROG(tkill_x, struct pt_regs *regs, long ret) {
ringbuf__store_event_header(&ringbuf);
/*=============================== COLLECT PARAMETERS ===========================*/
/* Parameter 1: res (type: PT_ERRNO)*/
/* Parameter 1: res (type: PT_ERRNO) */
ringbuf__store_s64(&ringbuf, ret);
/* Parameter 2: tid (type: PT_PID) */
pid_t tid = (int32_t)extract__syscall_argument(regs, 0);
ringbuf__store_s64(&ringbuf, (int64_t)tid);
/* Parameter 3: sig (type: PT_SIGTYPE) */
uint8_t sig = (uint8_t)extract__syscall_argument(regs, 1);
ringbuf__store_u8(&ringbuf, sig);
/*=============================== COLLECT PARAMETERS ===========================*/
ringbuf__submit_event(&ringbuf);

View File

@ -55,6 +55,10 @@ int BPF_PROG(umount2_x, struct pt_regs *regs, long ret) {
unsigned long target_pointer = extract__syscall_argument(regs, 0);
auxmap__store_charbuf_param(auxmap, target_pointer, MAX_PATH, USER);
/* Parameter 3: flags (type: PT_FLAGS32) */
int flags = (int)extract__syscall_argument(regs, 1);
auxmap__store_u32_param(auxmap, umount2_flags_to_scap(flags));
/*=============================== COLLECT PARAMETERS ===========================*/
auxmap__finalize_event_header(auxmap);

View File

@ -47,9 +47,13 @@ int BPF_PROG(unshare_x, struct pt_regs *regs, long ret) {
/*=============================== COLLECT PARAMETERS ===========================*/
/* Parameter 1: res (type: PT_ERRNO)*/
/* Parameter 1: res (type: PT_ERRNO) */
ringbuf__store_s64(&ringbuf, ret);
/* Parameter 2: flags (type: PT_FLAGS32) */
unsigned long flags = extract__syscall_argument(regs, 0);
ringbuf__store_u32(&ringbuf, clone_flags_to_scap((int)flags));
/*=============================== COLLECT PARAMETERS ===========================*/
ringbuf__submit_event(&ringbuf);

View File

@ -23,8 +23,8 @@ int BPF_PROG(writev_e, struct pt_regs *regs, long id) {
/*=============================== COLLECT PARAMETERS ===========================*/
/* Parameter 1: fd (type: PT_FD) */
int32_t fd = (int32_t)extract__syscall_argument(regs, 0);
ringbuf__store_s64(&ringbuf, (int64_t)fd);
int64_t fd = (int64_t)(int32_t)extract__syscall_argument(regs, 0);
ringbuf__store_s64(&ringbuf, fd);
unsigned long iov_pointer = extract__syscall_argument(regs, 1);
unsigned long iov_cnt = extract__syscall_argument(regs, 2);
@ -78,6 +78,13 @@ int BPF_PROG(writev_x, struct pt_regs *regs, long ret) {
/* Parameter 2: data (type: PT_BYTEBUF) */
auxmap__store_iovec_data_param(auxmap, iov_pointer, iov_cnt, snaplen);
/* Parameter 3: fd (type: PT_FD) */
int64_t fd = (int64_t)(int32_t)extract__syscall_argument(regs, 0);
auxmap__store_s64_param(auxmap, fd);
/* Parameter 4: size (type: PT_UINT32) */
auxmap__store_iovec_size_param(auxmap, iov_pointer, iov_cnt);
/*=============================== COLLECT PARAMETERS ===========================*/
auxmap__finalize_event_header(auxmap);

Some files were not shown because too many files have changed in this diff Show More