fix: fs_watch calls trace_file_init instead of mountsnoop_init with path argument - #112
Open
JoeSergen wants to merge 1 commit into
Open
fix: fs_watch calls trace_file_init instead of mountsnoop_init with path argument#112JoeSergen wants to merge 1 commit into
JoeSergen wants to merge 1 commit into
Conversation
…ath argument When fs_watch() is called with a non-null path, the else branch incorrectly calls trace_file_init() instead of mountsnoop_init(). This is a copy-paste error from file_watch(). The correct behavior is to initialize mountsnoop for filesystem event monitoring. Signed-off-by: JoeSergen <jxq142857@163.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fix copy-paste bug in
so/dkapture.cppwherefs_watch()calledtrace_file_init()instead ofmountsnoop_init()in its path-specific else branch.Root Cause
This is a copy-paste error from
file_watch(). The developer correctly changed the deinit and null-path branches tomountsnoop_*, but the else branch was missed.Why
mountsnoop_initis Correctfs_watchmonitors filesystem-level mount/umount events, not per-file I/O. Evidence from the BPF kernel side:mountsnoop_init — Filesystem Event Monitoring
User-space (
observe/mountsnoop.cpp): The-pargument is stored as a path prefix and written to a BPFchar[4096]array map.Kernel-space (
bpf/observe/mountsnoop.bpf.c:44-60):filter_path()performs path prefix matching against mount source/target paths:Monitored events:
sys_enter_mount,sys_enter_umount,fsopen,fsmount,move_mount, etc. — all filesystem-level syscalls.trace_file_init — Per-File I/O Monitoring
User-space (
observe/trace-file.cpp:1206-1212): The-pargument is used toopen()+fstat()the file, resolving it to an inode:Kernel-space (
bpf/observe/trace-file.bpf.c:128-146):find_file_inodematches by inode+dev:Monitored events:
vfs_open,vfs_read,vfs_write,vfs_chmod,vfs_chown,vfs_removexattr— all per-file I/O operations.Semantic Mismatch
-psemanticsfexit/vfs_*file opstracepoint/.../sys_enter_mountetc.Calling
trace_file_initfromfs_watchwould open the given path as a regular file, resolve its inode, and attach VFS-level file I/O hooks — completely unrelated to filesystem event monitoring.Changes
so/dkapture.cpp:388: Changedtrace_file_inittomountsnoop_init(1 line)Verification
int(int argc, char** argv, DKCallback cb, void* ctx)Closes #111