提交 50268a3d 编写于 作者: M Masami Hiramatsu 提交者: Ingo Molnar

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: NMasami 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: 5baaa59e ("tracing/probes: Implement 'memory' fetch method for uprobes")
Signed-off-by: NIngo Molnar <mingo@kernel.org>
上级 0eadcc7a
...@@ -151,6 +151,8 @@ static void FETCH_FUNC_NAME(memory, string)(struct pt_regs *regs, ...@@ -151,6 +151,8 @@ static void FETCH_FUNC_NAME(memory, string)(struct pt_regs *regs,
return; return;
ret = strncpy_from_user(dst, src, maxlen); ret = strncpy_from_user(dst, src, maxlen);
if (ret == maxlen)
dst[--ret] = '\0';
if (ret < 0) { /* Failed to fetch string */ if (ret < 0) { /* Failed to fetch string */
((u8 *)get_rloc_data(dest))[0] = '\0'; ((u8 *)get_rloc_data(dest))[0] = '\0';
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册