Skip to content

Commit d24d7db

Browse files
Jovi Zhangrostedt
authored andcommitted
tracing: Verify target file before registering a uprobe event
Without this patch, we can register a uprobe event for a directory. Enabling such a uprobe event would anyway fail. Example: $ echo 'p /bin:0x4245c0' > /sys/kernel/debug/tracing/uprobe_events However dirctories cannot be valid targets for uprobe. Hence verify if the target is a regular file during the probe registration. Link: http://lkml.kernel.org/r/[email protected] Cc: Namhyung Kim <[email protected]> Signed-off-by: Jovi Zhang <[email protected]> Acked-by: Srikar Dronamraju <[email protected]> [ cleaned up whitespace and removed redundant IS_DIR() check ] Signed-off-by: Steven Rostedt <[email protected]>
1 parent d8a0349 commit d24d7db

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

kernel/trace/trace_uprobe.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -258,6 +258,10 @@ static int create_trace_uprobe(int argc, char **argv)
258258
goto fail_address_parse;
259259

260260
inode = igrab(path.dentry->d_inode);
261+
if (!S_ISREG(inode->i_mode)) {
262+
ret = -EINVAL;
263+
goto fail_address_parse;
264+
}
261265

262266
argc -= 2;
263267
argv += 2;
@@ -356,7 +360,7 @@ static int create_trace_uprobe(int argc, char **argv)
356360
if (inode)
357361
iput(inode);
358362

359-
pr_info("Failed to parse address.\n");
363+
pr_info("Failed to parse address or file.\n");
360364

361365
return ret;
362366
}

0 commit comments

Comments
 (0)