Commit-ID: 50268a3d266ecfdd6c5873d62b2758d9732fc598 Gitweb: https://git.kernel.org/tip/50268a3d266ecfdd6c5873d62b2758d9732fc598 Author: Masami Hiramatsu <mhiramat@xxxxxxxxxx> AuthorDate: Tue, 10 Apr 2018 21:20:08 +0900 Committer: Ingo Molnar <mingo@xxxxxxxxxx> CommitDate: Tue, 10 Apr 2018 20:14:11 +0200 tracing/uprobe_event: Fix strncpy corner case Fix string fetch function to terminate with NUL. It is OK to drop the rest of string. Signed-off-by: Masami Hiramatsu <mhiramat@xxxxxxxxxx> Cc: Linus Torvalds <torvalds@xxxxxxxxxxxxxxxxxxxx> Cc: Peter Zijlstra <peterz@xxxxxxxxxxxxx> Cc: Song Liu <songliubraving@xxxxxx> Cc: Thomas Gleixner <tglx@xxxxxxxxxxxxx> Cc: security@xxxxxxxxxx Cc: 范龙飞 <long7573@xxxxxxx> Fixes: 5baaa59ef09e ("tracing/probes: Implement 'memory' fetch method for uprobes") Signed-off-by: Ingo Molnar <mingo@xxxxxxxxxx> --- kernel/trace/trace_uprobe.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/kernel/trace/trace_uprobe.c b/kernel/trace/trace_uprobe.c index 2014f4351ae0..0d450b40988e 100644 --- a/kernel/trace/trace_uprobe.c +++ b/kernel/trace/trace_uprobe.c @@ -151,6 +151,8 @@ static void FETCH_FUNC_NAME(memory, string)(struct pt_regs *regs, return; ret = strncpy_from_user(dst, src, maxlen); + if (ret == maxlen) + dst[--ret] = '\0'; if (ret < 0) { /* Failed to fetch string */ ((u8 *)get_rloc_data(dest))[0] = '\0'; -- To unsubscribe from this list: send the line "unsubscribe linux-tip-commits" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html
![]() |