-
Notifications
You must be signed in to change notification settings - Fork 165
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Tracking] Params inconsistencies in our drivers #515
Comments
Hi Andrea, like always, good catch! :D I agree with you; i'd phrase it in a different way actually: To retain backward compatibility, i think we could:
This fixes the first 2 points; the others are different cases instead. |
🤯 🤯
Completely agree with this solution! |
Love it, big +1, great catch! |
First 2 points will be addressed by #526 |
I have slightly changed the issue format with |
Tracking down all of this is of incredible value. Thank you a lot! |
You are welcome! Many thanks @Andreagit97 for the excellent summary and tracker of all the review follow-ups! |
Optimism is awesome but let me cool it down a little bit :P 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 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. |
You are right, of course! Nonetheless, we are wasting lots of bytes that, all together, would:
I was a bit over-reacting though, agree ahah
Yep!
You gave thorough ideas! And data :D I think @Andreagit97 is working on porting current |
Issues go stale after 90d of inactivity. Mark the issue as fresh with Stale issues rot after an additional 30d of inactivity and eventually close. If this issue is safe to close now please do so with Provide feedback via https://github.com/falcosecurity/community. /lifecycle stale |
Stale issues rot after 30d of inactivity. Mark the issue as fresh with Rotten issues close after an additional 30d of inactivity. If this issue is safe to close now please do so with Provide feedback via https://github.com/falcosecurity/community. /lifecycle rotten |
/remove-lifecycle rotten |
- change the flags (param 1) from u32 to s32 - add a userspace to scap flag conversion helper routine Reported by: github issue falcosecurity#515 Signed-off-by: Ofer Heifetz <[email protected]>
bump schema version minor Reported by: github issue #515 Signed-off-by: Ofer Heifetz <[email protected]>
- change the flags (param 1) from u32 to s32 - add a userspace to scap flag conversion helper routine Reported by: github issue #515 Signed-off-by: Ofer Heifetz <[email protected]>
I've added the |
Thank you Andrea, I think this makes it much clearer 🙏 |
@Andreagit97 Please mark dup3 as completed with strikethrough. |
@incertum @Andreagit97 Can you guys also mark setns, flock, and unshare as complete? |
Issues go stale after 90d of inactivity. Mark the issue as fresh with Stale issues rot after an additional 30d of inactivity and eventually close. If this issue is safe to close now please do so with Provide feedback via https://github.com/falcosecurity/community. /lifecycle stale |
/remove-lifecycle stale |
Issues go stale after 90d of inactivity. Mark the issue as fresh with Stale issues rot after an additional 30d of inactivity and eventually close. If this issue is safe to close now please do so with Provide feedback via https://github.com/falcosecurity/community. /lifecycle stale |
/remove-lifecycle stale |
Issues go stale after 90d of inactivity. Mark the issue as fresh with Stale issues rot after an additional 30d of inactivity and eventually close. If this issue is safe to close now please do so with Provide feedback via https://github.com/falcosecurity/community. /lifecycle stale |
/remove-lifecycle stale |
Issues go stale after 90d of inactivity. Mark the issue as fresh with Stale issues rot after an additional 30d of inactivity and eventually close. If this issue is safe to close now please do so with Provide feedback via https://github.com/falcosecurity/community. /lifecycle stale |
/remove-lifecycle stale |
PLEASE NOTE
This issue is mainly for tracking purposes, some points cannot be addressed until we solve the scap-file compatibility issue -> #1381 (comment)
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
fd
to userspace, we send them asint64_t
while they are represented onint32_t
. This leads us to waste a lot of space in our ring buffers...fd
params are very common in our event, we waste4
bytes every time we send a param of this type. Considering a small/medium-size system, we can imagine that it could send also1
million offd
params per second, this would mean wasting almost4
MB of space in our ring buffers per second!pid
to userspace, we send them asint64_t
while they are represented onint32_t
. This leads us to waste a lot of space in our ring buffers as explained in the previousfd
case.int
value and we push it to userspace asuint32_t
without converting it with our internalPPM
representation.flags
/modes
with the same type (so takeuint32_t
and senduint32_t
) in some cases we don't convert these values into the scapPPM
format, so we cannot use thisflags
/modes
userspace-side even if we catch them driver side.PPM_CODE
and its event pair.update(modern_bpf): reduce the
execve
instrumentation time with new APIs #648 (comment)Syscall-specific issues
LEGENDA
PLEASE NOTE
☝️modern_bpf
probebpf
probekernel module
open_by_handle_at
➡️path_components
we need to find a workaround to manage more components!open_flags_to_scap()
method should receive anint
value and not auint32_t
.dup3
➡️dup3_flags_to_scap()
method should receive anint
value and not auint32_t
.open
open_flags_to_scap()
method should receive anint
value and not auint32_t
.openat
open_flags_to_scap()
method should receive anint
value and not auint32_t
.openat2
open_flags_to_scap()
method should receive anint
value and not auint32_t
.eventfd
⬅️2
is not necessary, there is no flag argument ineventfd
, we have it only ineventfd2
https://github.com/falcosecurity/libs/pull/516/files#r935326971. We need a new eventeventfd2
⬅️2
(flags
) is not implemented, we push0
to userspaceinotify_init
⬅️inotify_init
has no syscall arguments but we send one paramsignalfd
⬅️2
(mask
) is not implemented, we push0
to userspace. We should remove it3
(flags
)is not implemented, we push0
to 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#L314signalfd4
⬅️2
(mask
) is not implemented, we push0
to userspace. We should remove it.timerfd_create
⬅️1
(clockid
) is not implemented, we push0
to userspace. We should implement it.2
(flags
) is not implemented, we push0
to userspace. We should implement it.userfault_fd
➡️2
(flags
) miss an helper likeuserfaultfd_flags_to_scap
to convert flags to scap notation.ptrace
➡️2
(addr
) not sure we really need aPT_DYN
param, we always send the same len.3
(data
) not sure about the utlity of sending thedata_pointer
to userspace.mkdirat
➡️4
(mode
) we need to convert the mode to the scap format.pipe2
pipe2
otherwise we cannot catch theflags
. Right now we use the same event ofpipe
.renameat2
➡️6
(flags
) we need to convert the flags to the scap format with an helper likerenameat2_flags_to_scap
.execve
➡️7
(cwd
) is not implemented, we push0
to userspacelibs/driver/bpf/fillers.h
Line 2417 in a8561a7
17
(tty
) is auint32_t
not anint32_t
fix(driver, userspace): fixloginuid
,euid
andtty
types to uint32_t #119219
(loginuid
) is auint32_t
not anint32_t
, a PR is up fix(driver, userspace): fixloginuid
,euid
andtty
types to uint32_t #119220
(flags
) still to implement.execveat
➡️7
(cwd
) is not implemented, we push0
to userspacelibs/driver/bpf/fillers.h
Line 2417 in a8561a7
17
(tty
) is auint32_t
not anint32_t
fix(driver, userspace): fixloginuid
,euid
andtty
types to uint32_t #119219
(loginuid
) is auint32_t
not anint32_t
fix(driver, userspace): fixloginuid
,euid
andtty
types to uint32_t #119220
(flags
) still to implement.fork
➡️7
(cwd
) is not implemented, we push0
to userspacelibs/driver/bpf/fillers.h
Line 2417 in a8561a7
clone
➡️7
(cwd
) is not implemented, we push0
to userspacelibs/driver/bpf/fillers.h
Line 2417 in a8561a7
clone3
➡️7
(cwd
) is not implemented, we push0
to userspacelibs/driver/bpf/fillers.h
Line 2417 in a8561a7
vfork
➡️7
(cwd
) is not implemented, we push0
to userspacelibs/driver/bpf/fillers.h
Line 2417 in a8561a7
socket
⬅️1
(domain
) thesocket_family_to_scap
method should receive an int, not au8
, and we need to choose if the param should be on8
bits or32
bits. We need also to update thesocket_family_to_scap
with new socket families.connect
➡️2
(tuple
) in case of UNIX sockets, not sure about the utility of sending kernel pointers to userspacesocketpair
⬅️Same issues of socket syscall
1
(domain
) thesocket_family_to_scap
method should receive an int, not au8
, and we need to choose if the param should be on8
bits or32
bits. We need also to update thesocket_family_to_scap
with new socket families.socketpair
➡️4
(source
) not sure about the utility of sending kernel pointers to userspace5
(peer
) not sure about the utility of sending kernel pointers to userspaceaccept
➡️5
(queuemax
) using Unix sockets, the max queue length seems not related to the value set bylisten
, more on this here: new(modern_bpf): add support for somenetwork
family syscalls #544 (comment)accept4
⬅️1
(flags
) still to implement, today we send always0
. This bug is used in the socketcall wokraroundlisten
⬅️2
(backlog
) is anint
not auint32_t
, fix listen syscall backlog field size #1256bpf
⬅️1
(cmd
) is anint
not aint64_t
flock
⬅️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
⬅️1
(cmd
) we need to read it as an int and then convert it touint32_t
, while today we read it as anunsigned long
3
(id
) is anint
not aint32_t
quotactl
➡️13
(dqi_flags
) add conversion to scap formatunshare
⬅️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
⬅️1
(flags
) if we want to use this info in userspace we need to convert it intoscap
format.umount2
⬅️1
(flags
) if we want to use this info in userspace we need to convert it intoscap
format. This field should be anint
not aint32_t
, fix umount2 syscall flags type, add conversion helper function #1255PPME_SYSCALL_UMOUNT2_E
,PPME_SYSCALL_UMOUNT2_X
)linkat
➡️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
➡️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
⬅️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
⬅️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
⬅️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
⬅️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
⬅️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
⬅️3
(sigmask
) we send only the first 32 bitsppoll
⬅️3
(sigmask
) we send only the first 32 bitsppoll
⬅️3
(sigmask
) we send only the first 32 bitsrecvmmsg
:[NOT ADDRESSABLE] Empty instrumentation
sendmmsg
:[NOT ADDRESSABLE] Empty instrumentation
The text was updated successfully, but these errors were encountered: