8000 Add hidden linux kernel module event by OriGlassman · Pull Request #2714 · aquasecurity/tracee · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

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

Merged
merged 1 commit into from
Mar 30, 2023

Conversation

OriGlassman
Copy link
Collaborator
@OriGlassman OriGlassman commented Feb 13, 2023

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

@CLAassistant
Copy link
CLAassistant commented Feb 13, 2023

CLA assistant check
All committers have signed the CLA.

@OriGlassman OriGlassman force-pushed the lkm_finder branch 2 times, most recently from c95f795 to 9962514 Compare February 13, 2023 16:25
@yanivagman yanivagman linked an issue Feb 15, 2023 that may be closed by this pull request
Copy link
Contributor
@rafaeldtinoco rafaeldtinoco left a 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.

Copy link
Contributor
@roikol roikol left a 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.

@OriGlassman OriGlassman force-pushed the lkm_finder branch 4 times, most recently from 107756a to 9c9bd2c Compare February 19, 2023 17:31
@roikol
Copy link
Contributor
roikol commented Feb 20, 2023

depends on: #2742

once it merges, trace package should be updated in go.mod

@OriGlassman OriGlassman requested review from roikol and removed request for rafaeldtinoco February 20, 2023 13:06
@rafaeldtinoco rafaeldtinoco self-requested a review February 20, 2023 14:59
@OriGlassman OriGlassman force-pushed the lkm_finder branch 2 times, most recently from 9c040bb to 4b59e14 Compare February 20, 2023 16:17
@OriGlassman OriGlassman force-pushed the lkm_finder branch 4 times, most recently from e1dcf3b to 6b3665a Compare February 23, 2023 14:16
@OriGlassman OriGlassman force-pushed the lkm_finder branch 3 times, most recently from 6a7af17 to ac57319 Compare March 21, 2023 15:25
@OriGlassman OriGlassman force-pushed the lkm_finder branch 3 times, most recently from cbabf3e to 600a867 Compare March 22, 2023 09:11
@OriGlassman OriGlassman requested a review from yanivagman March 22, 2023 09:38
Copy link
Collaborator
@yanivagman yanivagman left a 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

@OriGlassman OriGlassman force-pushed the lkm_finder branch 2 times, most recently from 9721e3f to 5402447 Compare March 26, 2023 08:38
@OriGlassman OriGlassman requested a review from yanivagman March 26, 2023 08:40
@aqua-ci
Copy link
aqua-ci commented Mar 26, 2023

[ERROR]
GitHub self-host runner 'github-self-hosted_ami-0f12d300b01df6d27_2714-4523689996_arm64c' failed with connecting to GitHub.
Please cancel workflow and wait until infrastructure team investigation.

@aqua-ci
Copy link
aqua-ci commented Mar 26, 2023

[ERROR]
GitHub self-host runner 'github-self-hosted_ami-0ffd52e93f1a0370b_2714-4523689996_arm64c' failed with connecting to GitHub.
Please cancel workflow and wait until infrastructure team investigation.

@aqua-ci
Copy link
aqua-ci commented Mar 26, 2023

[ERROR]
GitHub self-host runner 'github-self-hosted_ami-0f14a28ff0b2d6279_2714-4523689996_x64' failed with connecting to GitHub.
Please cancel workflow and wait until infrastructure team investigation.

@aqua-ci
Copy link
aqua-ci commented Mar 26, 2023

[ERROR]
GitHub self-host runner 'github-self-hosted_ami-0f12d300b01df6d27_2714-4523689996_arm64' failed with connecting to GitHub.
Please cancel workflow and wait until infrastructure team investigation.

@aqua-ci
Copy link
aqua-ci commented Mar 26, 2023

[ERROR]
GitHub self-host runner 'github-self-hosted_ami-0d40904002284d8de_2714-4523689996_arm64c' failed with connecting to GitHub.
Please cancel workflow and wait until infrastructure team investigation.

@aqua-ci
Copy link
aqua-ci commented Mar 26, 2023

[ERROR]
GitHub self-host runner 'github-self-hosted_ami-0f14a28ff0b2d6279_2714-4523689996_x64c' failed with connecting to GitHub.
Please cancel workflow and wait until infrastructure team investigation.

@aqua-ci
Copy link
aqua-ci commented Mar 26, 2023

[ERROR]
GitHub self-host runner 'github-self-hosted_ami-0f23165db12015479_2714-4523689996_x64' failed with connecting to GitHub.
Please cancel workflow and wait until infrastructure team investigation.

@aqua-ci
Copy link
aqua-ci commented Mar 26, 2023

[ERROR]
GitHub self-host runner 'github-self-hosted_ami-0f23165db12015479_2714-4523689996_x64c' failed with connecting to GitHub.
Please cancel workflow and wait until infrastructure team investigation.

Copy link
Collaborator
@yanivagman yanivagman left a 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.

@@ -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.
Copy link
Collaborator

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?

Copy link
Collaborator Author

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?

Comment on lines 28 to 34
#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");

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment on lines 667 to 655
// 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
Copy link
Collaborator

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?

Comment on lines 28 to 34
#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");

Copy link
Collaborator

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

Comment on lines 667 to 655
// 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
Copy link
Collaborator

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)

Copy link
Collaborator
@yanivagman yanivagman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.
Nice work!

@rafaeldtinoco rafaeldtinoco merged commit b5b6a1c into aquasecurity:main Mar 30, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add hidden linux kernel rootkit detection
6 participants
0