Skip to content

Commit fba70eb

Browse files
mhiramatgregkh
authored andcommitted
tracing/uprobe_event: Fix strncpy corner case
commit 50268a3 upstream. Fix string fetch function to terminate with NUL. It is OK to drop the rest of string. Signed-off-by: Masami Hiramatsu <mhiramat@kernel.org> Cc: Linus Torvalds <torvalds@linux-foundation.org> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Song Liu <songliubraving@fb.com> Cc: Thomas Gleixner <tglx@linutronix.de> Cc: security@kernel.org Cc: 范龙飞 <long7573@126.com> Fixes: 5baaa59 ("tracing/probes: Implement 'memory' fetch method for uprobes") Signed-off-by: Ingo Molnar <mingo@kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 5d1639d commit fba70eb

1 file changed

Lines changed: 2 additions & 0 deletions

File tree

kernel/trace/trace_uprobe.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,8 @@ static void FETCH_FUNC_NAME(memory, string)(struct pt_regs *regs,
149149
return;
150150

151151
ret = strncpy_from_user(dst, src, maxlen);
152+
if (ret == maxlen)
153+
dst[--ret] = '\0';
152154

153155
if (ret < 0) { /* Failed to fetch string */
154156
((u8 *)get_rloc_data(dest))[0] = '\0';

0 commit comments

Comments
 (0)