From: Masami Hiramatsu Date: Tue, 10 Apr 2018 12:20:08 +0000 (+0900) Subject: tracing/uprobe_event: Fix strncpy corner case X-Git-Tag: v4.14.41~8 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=bd05324cdd3aaf5364f317d9f074b681127b2adf;p=platform%2Fkernel%2Flinux-exynos.git tracing/uprobe_event: Fix strncpy corner case commit 50268a3d266ecfdd6c5873d62b2758d9732fc598 upstream. Fix string fetch function to terminate with NUL. It is OK to drop the rest of string. Signed-off-by: Masami Hiramatsu Cc: Linus Torvalds Cc: Peter Zijlstra Cc: Song Liu Cc: Thomas Gleixner Cc: security@kernel.org Cc: 范龙飞 Fixes: 5baaa59ef09e ("tracing/probes: Implement 'memory' fetch method for uprobes") Signed-off-by: Ingo Molnar Signed-off-by: Greg Kroah-Hartman --- diff --git a/kernel/trace/trace_uprobe.c b/kernel/trace/trace_uprobe.c index 14d3af6..7197ff9 100644 --- a/kernel/trace/trace_uprobe.c +++ b/kernel/trace/trace_uprobe.c @@ -152,6 +152,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';