-
Notifications
You must be signed in to change notification settings - Fork 381
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
LSM sensor #2566
LSM sensor #2566
Conversation
✅ Deploy Preview for tetragon ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
There are things to do:
I managed to load LSM BPF programs, tail calls also work for LSM programs! The most terrifying problems are solved, I think. I managed to catch some Lsm events). |
a9f28bf
to
1f5d707
Compare
For now I managed to fix problem with args resolving. LSM BPF programs get args the way raw tracepoint programs do. So, LSM events now are looking good. It would be nice to start code review. Some open questions:
|
f17edbc
to
03cb7db
Compare
0127073
to
1cc6efb
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
Overall, this looks good to me! I've left some minor comments.
./verify/verify.sh . I made a hack for loading generic LSM programs. But I need to install llvm-objcopy in CI
Looks good to me. Yap, let's install it. I'm guessing it should be part of our clang container so we can just use that.
Tests. I think we need some tests. Maybe more than one. I'll work on it. Maybe we discuss what kind of tests it's good to have?
That's a good question. I would say start simple, and have one or two tests for the basic functionality (observability and enforcement)
Enforce mode. If LSM BPF returns the value that is not qual to zero, than operation > is not permitted. Maybe we should add an action for that? For example, if policy is > violated just return -EPERM, instead of sending SIGKILL.
Yap, I think that makes sense. We also have an override action that does something similar, but having a separate action for lsm (as you do in your PR) makes sense to me.
@olsajiri I added you to the reviewers. It would be great if you could have a look when you get a chance. Thanks! |
e0f9144
to
98e2cd3
Compare
30708a5
to
256b762
Compare
Kprobes and uprobes have the almost the same code in generic_kprobe_start_process_filter and generic_uprobe_start_process_filter it can be generic. Signed-off-by: Andrei Fedotov <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm, nice work! thanks
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thanks!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This PR is lovely and nice to review! Thanks!
Adding generic LSM bpf. It follows the kprobe/tracepoint/uprobe logic also calls same generic functions. Signed-off-by: Andrei Fedotov <[email protected]>
Set up tailcalls map for generic LSM sensor. Add LSMOpen function to override attach points collected from section names. Signed-off-by: Andrei Fedotov <[email protected]>
Use features.HaveProgramType(ebpf.LSM) and inspect /sys/kernel/security/lsm file to check LSM availability. Try to load and attach simple LSM probe. Signed-off-by: Andrei Fedotov <[email protected]>
Adding LSM message/event definition. Signed-off-by: Andrei Fedotov <[email protected]>
Signed-off-by: Andrei Fedotov <[email protected]>
Adding generic LSM sensor that reads LSM crd config and setups LSM programs. The LSM is configured with hook, like: spec: lsmhooks: - hook: "bprm_check_security" Signed-off-by: Andrei Fedotov <[email protected]>
Adding PROCESS_LSM to exportAllowList event_set values. Signed-off-by: Andrei Fedotov <[email protected]>
Adding tests for generic LSM sensor - load and apply tracing policy. Signed-off-by: Andrei Fedotov <[email protected]>
Adding test to check enforcement for generic LSM sensor. Signed-off-by: Andrei Fedotov <[email protected]>
Generic LSM BPF needs more complex userspace logic to load, so ignore it. Signed-off-by: Andrei Fedotov <[email protected]>
Adding examples of lsm tracing policies to monitor file access and process execution. Signed-off-by: Andrei Fedotov <[email protected]>
Adding section about LSM hook points. Signed-off-by: Andrei Fedotov <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Didn't have time to review all, thank you for the nice contributions ;-)
Merging this, thanks! Great work! |
There are some gaps in EventType and GetEventsResponse field numbers because some fields got removed from these events. Mark these field numbers as reserved to avoid accidentally re-using them. Move process_lsm field number from 13 to 28 since the field number 13 has already been used in the past. It's still safe to change the field number for process_lsm since we haven't released the process_lsm APIs [^1]. [^1]: #2566 Suggested-by: Lorenz Bauer <[email protected]> Signed-off-by: Michi Mutsuzaki <[email protected]>
There are some gaps in EventType and GetEventsResponse field numbers because some fields got removed from these events. Mark these field numbers as reserved to avoid accidentally re-using them. Move process_lsm field number from 13 to 28 since the field number 13 has already been used in the past. It's still safe to change the field number for process_lsm since we haven't released the process_lsm APIs [^1]. [^1]: #2566 Suggested-by: Lorenz Bauer <[email protected]> Signed-off-by: Michi Mutsuzaki <[email protected]>
LSM sensor support allows to use LSM BPF programs the way we use BPF programs for kprobes/tracepoints/uprobes.
TracingPolicy example:
Event example:
This is also necessary for #2409.