-
Notifications
You must be signed in to change notification settings - Fork 449
Add hidden linux kernel module event #2714
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
Conversation
c95f795
to
9962514
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.
You're missing test results and a better PR description.
f332f93
to
bae4d9b
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.
hey @OriGlassman
good work here!
i've left some comments for you to consider.
please also use clang-format in the .c and .h files. and use go-fmt on the to .go files.
107756a
to
9c9bd2c
Compare
depends on: #2742 once it merges, |
9c9bd2c
to
6b575de
Compare
9c040bb
to
4b59e14
Compare
e1dcf3b
to
6b3665a
Compare
6a7af17
to
ac57319
Compare
cbabf3e
to
600a867
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.
Before doing another round of review, please document the new event
9721e3f
to
5402447
Compare
[ERROR] |
[ERROR] |
[ERROR] |
[ERROR] |
[ERROR] |
[ERROR] |
[ERROR] |
[ERROR] |
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.
Replied to few comments.
I will do a more thorough review tomorrow.
pkg/ebpf/c/common/consts.h
Outdated
@@ -18,6 +18,7 @@ | |||
#define SEND_META_SIZE 28 | |||
|
|||
#define MAX_MEM_DUMP_SIZE 127 | |||
#define MAX_NUM_MODS 600 // number of iterations - value that the verifier was seen to cope with - the higher, the better. |
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 macro name is not clear enough - does MODS imply modules?
Also - why should we put this under common? isn't it only used for your event?
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.
Changed it to MAX_NUM_MODULES.
Where do you recommend to put it?
pkg/ebpf/c/maps.h
Outdated
#define BPF_MAP_QUEUE(_name, _type, _value_type, _max_entries) \ | ||
struct { \ | ||
__uint(type, _type); \ | ||
__uint(max_entries, _max_entries); \ | ||
__type(value, _value_type); \ | ||
} _name SEC(".maps"); | ||
|
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.
key size must be zero - https://docs.kernel.org/bpf/map_queue_stack.html
pkg/ebpf/c/tracee.bpf.c
Outdated
// If we won't create these maps, the userspace needs to be kernel version aware as well, | ||
// otherwise it'll try to interact with the maps and report an error |
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.
Where does userspace try to access them?
pkg/ebpf/c/maps.h
Outdated
#define BPF_MAP_QUEUE(_name, _type, _value_type, _max_entries) \ | ||
struct { \ | ||
__uint(type, _type); \ | ||
__uint(max_entries, _max_entries); \ | ||
__type(value, _value_type); \ | ||
} _name SEC(".maps"); | ||
|
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.
No, this struct should be defined without key_type, since key is not part of the Queue concept by definition.
This macro should be kept, but let's remove the need to pass the BPF_MAP_TYPE_QUEUE argument since it will always be the same
pkg/ebpf/c/tracee.bpf.c
Outdated
// If we won't create these maps, the userspace needs to be kernel version aware as well, | ||
// otherwise it'll try to interact with the maps and report an error |
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.
Of course you need to create the maps if we access them from userspace, what I don't understand is why do we need to add a comment about that? What is special here comparing to other hash maps defined in the code? How does it relate to the kernel version? hash maps were available in older kernels as well (unlike queue maps)
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!
1. Explain what the PR does
This PR adds a "hidden_kernel_module" event, which periodically checks for a hidden kernel module in your system and emits the hidden kernel module address and name, if that is found.
2. Explain how to test it
./tracee-ebpf -t e=hidden_kernel_module
3. Other comments