-
Notifications
You must be signed in to change notification settings - Fork 4
ROX-33198: Instrument inode tracking on file open lsm hook #391
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
base: main
Are you sure you want to change the base?
Changes from all commits
7b92eab
0d9cf75
b0113c2
2bf0f3d
1b64a72
35462c4
411c115
3b09253
f37b40b
283f50a
600d08c
1d1e383
65f53a0
950c402
a8471b0
5e145ca
0184180
2b139ff
93dd1d8
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could we unify the logic for checking if an inode is monitored in |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -33,21 +33,21 @@ __always_inline static inode_key_t inode_to_key(struct inode* inode) { | |
| return key; | ||
| } | ||
|
|
||
| unsigned long magic = inode->i_sb->s_magic; | ||
| unsigned long magic = BPF_CORE_READ(inode, i_sb, s_magic); | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| switch (magic) { | ||
| case BTRFS_SUPER_MAGIC: | ||
| if (bpf_core_type_exists(struct btrfs_inode)) { | ||
| struct btrfs_inode* btrfs_inode = container_of(inode, struct btrfs_inode, vfs_inode); | ||
| key.inode = inode->i_ino; | ||
| key.inode = BPF_CORE_READ(inode, i_ino); | ||
| key.dev = BPF_CORE_READ(btrfs_inode, root, anon_dev); | ||
| break; | ||
| } | ||
| // If the btrfs_inode does not exist, most likely it is not | ||
| // supported on the system. Fallback to the generic implementation | ||
| // just in case. | ||
| default: | ||
| key.inode = inode->i_ino; | ||
| key.dev = inode->i_sb->s_dev; | ||
| key.inode = BPF_CORE_READ(inode, i_ino); | ||
| key.dev = BPF_CORE_READ(inode, i_sb, s_dev); | ||
| break; | ||
| } | ||
|
|
||
|
|
@@ -58,13 +58,21 @@ __always_inline static inode_key_t inode_to_key(struct inode* inode) { | |
| return key; | ||
| } | ||
|
|
||
| __always_inline static inode_value_t* inode_get(struct inode_key_t* inode) { | ||
| __always_inline static inode_value_t* inode_get(const struct inode_key_t* inode) { | ||
| if (inode == NULL) { | ||
| return NULL; | ||
| } | ||
| return bpf_map_lookup_elem(&inode_map, inode); | ||
| } | ||
|
|
||
| __always_inline static long inode_add(struct inode_key_t* inode) { | ||
| if (inode == NULL) { | ||
| return -1; | ||
| } | ||
| inode_value_t value = 0; | ||
| return bpf_map_update_elem(&inode_map, inode, &value, BPF_ANY); | ||
| } | ||
|
|
||
| __always_inline static long inode_remove(struct inode_key_t* inode) { | ||
| if (inode == NULL) { | ||
| return 0; | ||
|
|
@@ -75,6 +83,7 @@ __always_inline static long inode_remove(struct inode_key_t* inode) { | |
| typedef enum inode_monitored_t { | ||
| NOT_MONITORED = 0, | ||
| MONITORED, | ||
| PARENT_MONITORED, | ||
| } inode_monitored_t; | ||
|
|
||
| /** | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.