libs: [Tracking] Params inconsistencies in our drivers
PLEASE NOTE
This issue is mainly for tracking purposes, some points cannot be addressed until we solve the scap-file compatibility issue -> https://github.com/falcosecurity/libs/pull/1381#issuecomment-1746613905
Generic context
The aim of this issue is to track all the inconsistencies when we send event params from our drivers (modern_bpf, bpf, kernel module) to userspace. Some widespread issues that need a dedicated conversion
- Today when we send file descriptors
fdto userspace, we send them asint64_twhile they are represented onint32_t. This leads us to waste a lot of space in our ring buffers…fdparams are very common in our event, we waste4bytes every time we send a param of this type. Considering a small/medium-size system, we can imagine that it could send also1million offdparams per second, this would mean wasting almost4MB of space in our ring buffers per second! - Today when we send process identifiers
pidto userspace, we send them asint64_twhile they are represented onint32_t. This leads us to waste a lot of space in our ring buffers as explained in the previousfdcase. - In some syscalls we take the syscalls flags as an
intvalue and we push it to userspace asuint32_twithout converting it with our internalPPMrepresentation. - This is similar to the previous point, but even if we send
flags/modeswith the same type (so takeuint32_tand senduint32_t) in some cases we don’t convert these values into the scapPPMformat, so we cannot use thisflags/modesuserspace-side even if we catch them driver side. - In some events we send empty params because they are still not implemented.
- Every syscall must have its
PPM_CODEand its event pair. - Different drivers manage max boundaries in different ways we need to uniform them in some way 👇 https://github.com/falcosecurity/libs/pull/648#discussion_r996388593
Syscall-specific issues
LEGENDA
- [NOT ADDRESSABLE] -> means that the issue is not addressable at the moment, at least until we don’t solve the scap file issue, see
PLEASE NOTE☝️ - [MODERN_BPF] -> means that the issue is only related to the
modern_bpfprobe - [BPF] -> means that the issue is only related to the
bpfprobe - [KMOD] -> means that the issue is only related to the
kernel module - ⚠️ -> possible problems, fix it!
- ⬅️ -> only in the enter event
- ➡️ -> only in the exit event
open_by_handle_at ➡️
- [MODERN BPF] we can get at maximum 8
path_componentswe need to find a workaround to manage more components! -
open_flags_to_scap()method should receive anintvalue and not auint32_t.
dup3 ➡️
-
dup3_flags_to_scap()method should receive anintvalue and not auint32_t.
open
-
open_flags_to_scap()method should receive anintvalue and not auint32_t.
openat
-
open_flags_to_scap()method should receive anintvalue and not auint32_t.
openat2
-
open_flags_to_scap()method should receive anintvalue and not auint32_t.
eventfd ⬅️
- [NOT ADDRESSABLE] param
2is not necessary, there is no flag argument ineventfd, we have it only ineventfd2https://github.com/falcosecurity/libs/pull/516/files#r935326971. We need a new event
eventfd2 ⬅️
- param
2(flags) is not implemented, we push0to userspace
inotify_init ⬅️
- [NOT ADDRESSABLE]
inotify_inithas no syscall arguments but we send one param
signalfd ⬅️
- [NOT ADDRESSABLE] param
2(mask) is not implemented, we push0to userspace. We should remove it - [NOT ADDRESSABLE] param
3(flags)is not implemented, we push0to userspace. We should remove it. Moreover, this syscall has not a flag argument, please see here for more details https://elixir.bootlin.com/linux/v6.5.5/source/fs/signalfd.c#L314
signalfd4 ⬅️
- [NOT ADDRESSABLE] param
2(mask) is not implemented, we push0to userspace. We should remove it.
timerfd_create ⬅️
- param
1(clockid) is not implemented, we push0to userspace. We should implement it. - param
2(flags) is not implemented, we push0to userspace. We should implement it.
userfault_fd ➡️
- param
2(flags) miss an helper likeuserfaultfd_flags_to_scapto convert flags to scap notation.
ptrace ➡️
- [NOT ADDRESSABLE] param
2(addr) not sure we really need aPT_DYNparam, we always send the same len. - [NOT ADDRESSABLE] param
3(data) not sure about the utlity of sending thedata_pointerto userspace.
mkdirat ➡️
- param
4(mode) we need to convert the mode to the scap format.
pipe2
- we need a new event for
pipe2otherwise we cannot catch theflags. Right now we use the same event ofpipe.
renameat2 ➡️
- param
6(flags) we need to convert the flags to the scap format with an helper likerenameat2_flags_to_scap.
execve ➡️
- [NOT ADDRESSABLE] param
7(cwd) is not implemented, we push0to userspace https://github.com/falcosecurity/libs/blob/a8561a7a117374e9c454bddc91f58f0f50b873ab/driver/bpf/fillers.h#L2417 - param
17(tty) is auint32_tnot anint32_thttps://github.com/falcosecurity/libs/pull/1192 - param
19(loginuid) is auint32_tnot anint32_t, a PR is up https://github.com/falcosecurity/libs/pull/1192 - [MODERN BPF] param
20(flags) still to implement.
execveat ➡️
- [NOT ADDRESSABLE] param
7(cwd) is not implemented, we push0to userspace https://github.com/falcosecurity/libs/blob/a8561a7a117374e9c454bddc91f58f0f50b873ab/driver/bpf/fillers.h#L2417 - param
17(tty) is auint32_tnot anint32_thttps://github.com/falcosecurity/libs/pull/1192 - param
19(loginuid) is auint32_tnot anint32_thttps://github.com/falcosecurity/libs/pull/1192 - [MODERN BPF] param
20(flags) still to implement.
fork ➡️
- [NOT ADDRESSABLE] param
7(cwd) is not implemented, we push0to userspace https://github.com/falcosecurity/libs/blob/a8561a7a117374e9c454bddc91f58f0f50b873ab/driver/bpf/fillers.h#L2417
clone ➡️
- [NOT ADDRESSABLE] param
7(cwd) is not implemented, we push0to userspace https://github.com/falcosecurity/libs/blob/a8561a7a117374e9c454bddc91f58f0f50b873ab/driver/bpf/fillers.h#L2417
clone3 ➡️
- [NOT ADDRESSABLE] param
7(cwd) is not implemented, we push0to userspace https://github.com/falcosecurity/libs/blob/a8561a7a117374e9c454bddc91f58f0f50b873ab/driver/bpf/fillers.h#L2417
vfork ➡️
- [NOT ADDRESSABLE] param
7(cwd) is not implemented, we push0to userspace https://github.com/falcosecurity/libs/blob/a8561a7a117374e9c454bddc91f58f0f50b873ab/driver/bpf/fillers.h#L2417
socket ⬅️
- [NOT ADDRESSABLE] param
1(domain) thesocket_family_to_scapmethod should receive an int, not au8, and we need to choose if the param should be on8bits or32bits. We need also to update thesocket_family_to_scapwith new socket families.
connect ➡️
- [NOT ADDRESSABLE] param
2(tuple) in case of UNIX sockets, not sure about the utility of sending kernel pointers to userspace
socketpair ⬅️
Same issues of socket syscall
- [NOT ADDRESSABLE] param
1(domain) thesocket_family_to_scapmethod should receive an int, not au8, and we need to choose if the param should be on8bits or32bits. We need also to update thesocket_family_to_scapwith new socket families.
socketpair ➡️
- [NOT ADDRESSABLE] param
4(source) not sure about the utility of sending kernel pointers to userspace - [NOT ADDRESSABLE] param
5(peer) not sure about the utility of sending kernel pointers to userspace
accept ➡️
- param
5(queuemax) using Unix sockets, the max queue length seems not related to the value set bylisten, more on this here: https://github.com/falcosecurity/libs/pull/544#discussion_r942246996
accept4 ⬅️
- [NOT ADDRESSABLE] param
1(flags) still to implement, today we send always0. This bug is used in the socketcall wokraround
listen ⬅️
- param
2(backlog) is anintnot auint32_t, https://github.com/falcosecurity/libs/pull/1256
bpf ⬅️
- [NOT ADDRESSABLE] param
1(cmd) is anintnot aint64_t
flock ⬅️
- param
2(operation) we need to read it as an int and then convert it touint32_t, while today we read it as anunsigned long
quotactl ⬅️
- param
1(cmd) we need to read it as an int and then convert it touint32_t, while today we read it as anunsigned long - param
3(id) is anintnot aint32_t
quotactl ➡️
- param
13(dqi_flags) add conversion to scap format
unshare ⬅️
- param
1(flags) we need to read it as an int and then convert it touint32_t, while today we read it as anunsigned long
mount ⬅️
- param
1(flags) if we want to use this info in userspace we need to convert it intoscapformat.
umount2 ⬅️
- param
1(flags) if we want to use this info in userspace we need to convert it intoscapformat. This field should be anintnot aint32_t, https://github.com/falcosecurity/libs/pull/1255 - we need to define a new event pair (
PPME_SYSCALL_UMOUNT2_E,PPME_SYSCALL_UMOUNT2_X)
linkat ➡️
- param
6(flags) we need to read it as an int and then convert it touint32_t, while today we read it as anunsigned long
unlinkat ➡️
- param
4(flags) we need to read it as an int and then convert it touint32_t, while today we read it as anunsigned long
setns ⬅️
- param
2(nstype) we need to read it as an int and then convert it touint32_t, while today we read it as anunsigned long
setrlimit ⬅️
- param
1(resource) we need to read it as an int and then convert it touint8_t, while today we read it as anunsigned long
prlimit64 ⬅️
- param
2(resource) we need to read it as an int and then convert it touint8_t, while today we read it as anunsigned long
sendto ⬅️
- [NOT ADDRESSABLE] param
3(tuple) should be catched in the exit event when we know the outcome of the syscall otherwise there is the risk to catch something wrong.
sendmsg ⬅️
- [NOT ADDRESSABLE] param
3(tuple) should be catched in the exit event when we know the outcome of the syscall otherwise there is the risk to catch something wrong.
ppoll⬅️
- [NOT ADDRESSABLE] param
3(sigmask) we send only the first 32 bits
ppoll⬅️
- [NOT ADDRESSABLE] param
3(sigmask) we send only the first 32 bits
ppoll⬅️
- [NOT ADDRESSABLE] param
3(sigmask) we send only the first 32 bits
recvmmsg:
[NOT ADDRESSABLE] Empty instrumentation
sendmmsg:
[NOT ADDRESSABLE] Empty instrumentation
About this issue
- Original URL
- State: open
- Created 2 years ago
- Reactions: 8
- Comments: 21 (21 by maintainers)
Commits related to this issue
- fix listen syscall backlog field size Reported by: github issue #515 Signed-off-by: Ofer Heifetz <oheifetz@gmail.com> — committed to oheifetz/libs by oheifetz a year ago
- fix listen syscall backlog field size Reported by: github issue #515 Signed-off-by: Ofer Heifetz <oheifetz@gmail.com> — committed to oheifetz/libs by oheifetz a year ago
- fix listen syscall backlog field size Reported by: github issue #515 Signed-off-by: Ofer Heifetz <oheifetz@gmail.com> — committed to oheifetz/libs by oheifetz a year ago
- fix listen syscall backlog field size Reported by: github issue #515 Signed-off-by: Ofer Heifetz <oheifetz@gmail.com> — committed to oheifetz/libs by oheifetz a year ago
- fix listen syscall backlog field size Reported by: github issue #515 Signed-off-by: Ofer Heifetz <oheifetz@gmail.com> — committed to oheifetz/libs by oheifetz a year ago
- fix listen syscall backlog field size Reported by: github issue #515 Signed-off-by: Ofer Heifetz <oheifetz@gmail.com> — committed to oheifetz/libs by oheifetz a year ago
- fix listen syscall backlog field size Reported by: github issue #515 Signed-off-by: Ofer Heifetz <oheifetz@gmail.com> — committed to oheifetz/libs by oheifetz a year ago
- fix listen syscall backlog field size Reported by: github issue #515 Signed-off-by: Ofer Heifetz <oheifetz@gmail.com> — committed to oheifetz/libs by oheifetz a year ago
- fix listen syscall backlog field size Reported by: github issue #515 Signed-off-by: Ofer Heifetz <oheifetz@gmail.com> — committed to oheifetz/libs by oheifetz a year ago
- fix listen syscall backlog field size Reported by: github issue #515 Signed-off-by: Ofer Heifetz <oheifetz@gmail.com> — committed to oheifetz/libs by oheifetz a year ago
- fix umount2 syscall Reported by: github issue #515 Signed-off-by: Ofer Heifetz <oheifetz@gmail.com> — committed to oheifetz/libs by oheifetz a year ago
- fix umount2 syscall flags type, add conversion helper function - change the flags (param 1) from u32 to s32 - add a userspace to scap flag conversion helper routine Reported by: github issue #515 S... — committed to oheifetz/libs by oheifetz a year ago
- fix umount2 syscall flags type, add conversion helper function - change the flags (param 1) from u32 to s32 - add a userspace to scap flag conversion helper routine Reported by: github issue #515 S... — committed to oheifetz/libs by oheifetz a year ago
- fix umount2 syscall flags type, add conversion helper function - change the flags (param 1) from u32 to s32 - add a userspace to scap flag conversion helper routine Reported by: github issue #515 S... — committed to oheifetz/libs by oheifetz a year ago
- fix umount2 syscall flags type, add conversion helper function - change the flags (param 1) from u32 to s32 - add a userspace to scap flag conversion helper routine Reported by: github issue #515 S... — committed to oheifetz/libs by oheifetz a year ago
- fix umount2 syscall flags type, add conversion helper function - change the flags (param 1) from u32 to s32 - add a userspace to scap flag conversion helper routine Reported by: github issue #515 S... — committed to oheifetz/libs by oheifetz a year ago
- fix umount2 syscall flags type, add conversion helper function - change the flags (param 1) from u32 to s32 - add a userspace to scap flag conversion helper routine Reported by: github issue #515 S... — committed to oheifetz/libs by oheifetz a year ago
- fix umount2 syscall flags type, add conversion helper function - change the flags (param 1) from u32 to s32 - add a userspace to scap flag conversion helper routine Reported by: github issue #515 S... — committed to oheifetz/libs by oheifetz a year ago
- fix listen syscall backlog field size Reported by: github issue #515 Signed-off-by: Ofer Heifetz <oheifetz@gmail.com> — committed to oheifetz/libs by oheifetz a year ago
- fix umount2 syscall flags type, add conversion helper function - change the flags (param 1) from u32 to s32 - add a userspace to scap flag conversion helper routine Reported by: github issue #515 S... — committed to oheifetz/libs by oheifetz a year ago
First 2 points will be addressed by #526
@incertum @Andreagit97 Can you guys also mark setns, flock, and unshare as complete?
I’ve added the
[NOT ADDRESSABLE]marker to all issues that we cannot address now due to the scap-file management https://github.com/falcosecurity/libs/pull/1381#issuecomment-1746613905Optimism is awesome but let me cool it down a little bit 😛 Every event has this header, which is somewhat larger than the zero bytes it would need for that claim to be true 😉
BTW, we could probably easily change
nparamsto 16 bits. If we do expect >64k parameters, we can hack something for the (hopefully rare) events that exceed this number.We could also trim the tid to 32 bits, but then we use this struct all over userspace too (#sadpanda), and other environments may want large tids (e.g. gvisor), so we would have to decouple these two structs and copy data field by field between them.
Don’t let me distract you from tracking down the inconsistencies though, that’s an awesome job!
These two changes would cut down 6 bytes from every event, equivalent to one and a half fds with no schema changes, just a major api version bump.
I have slightly changed the issue format with
Generic event issuesandSpecific event issuesin this way it should be more maintainable, thank you to @hbrueckner @Molter73 @FedeDP for all the help in finding new issues