Skip to content

Conversation

@nicholasberlin
Copy link
Contributor

@nicholasberlin nicholasberlin commented Jun 30, 2025

On RHEL kernels where ebpf has been back-ported but FMODE_CREATED does not yet exist, use
fsnotify_create as an indication of file creation. This requires a new probe on fsnotify to set a thread local map entry, which the current do_filp_open exit probe can then test for.

Since the fsnotify probe can be noisy and the parameters have changed over time, only
enable that probe when necessary. Ideally, we would test for the existence of FMODE_CREATED, but as far as I'm aware, there's not a way to detect #defines. There's another commit (torvalds/linux@44907d7) related
to the addition of FMODE_CREATED which is detectable by testing the parameter count of the
atomic_open function pointer within struct inode_operations.

A new function was added to use btf for detecting the parameter change, and is used to conditionally apply the fnsotify probe. Hopefully, the parameter count to atomic_open will not change back to 6.

Also, re-enabled file testing for the appropriate kernels.

Thanks @haesbaert for the feedback/review. I incorporated and squashed this and this.

On RHEL kernels where ebpf has been backported but FMODE_CREATED does not yet exist, use
fsnotify_create as an indication of file creation. This requires a new probe to set a thread
local map entry, which the current do_filp_open probe can then test for.
Since the fsnotify probe can be noisy and the parameters have changed over time, only
enable that probe when necessary. Ideally, we would test for the existence of FMODE_CREATED,
but as far as I'm aware, there's not a way to detect defines. There's another commit
(torvalds/linux@44907d7) related
to the addition of FMODE_CREATED which is detectable by testing the parameter count to the
atomic_open function pointer within struct inode_operations.

This commit adds a function to detect the commit using btf, and conditionally adds the fsnotify
probe.
@nicholasberlin nicholasberlin marked this pull request as ready for review June 30, 2025 16:57
@nicholasberlin nicholasberlin requested a review from a team as a code owner June 30, 2025 16:57
@nicholasberlin nicholasberlin changed the title Rhel8 file create RHEL-8 file create Jun 30, 2025
@haesbaert
Copy link
Collaborator

Awesome, this is great thanks!

@haesbaert haesbaert merged commit 3fb921c into main Jun 30, 2025
2 checks passed
@nicholasberlin nicholasberlin deleted the rhel8_file_create branch October 28, 2025 15:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants