Commit 06f43d66ec36388056f5c697bf1e67c0e0a1645c

Authored by Frederic Weisbecker
1 parent 459c6d15a0

ftrace: Copy ftrace_graph_filter boot param using strlcpy

We are using strncpy in the wrong way to copy the ftrace_graph_filter
boot param because we pass the buffer size instead of the max string
size it can contain (buffer size - 1). The end result might not be
NULL terminated as we are abusing the max string size.

Lets use strlcpy() instead.

Reported-by: Li Zefan <lizf@cn.fujitsu.com>
Signed-off-by: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Steven Rostedt <rostedt@goodmis.org>

Showing 1 changed file with 1 additions and 1 deletions Side-by-side Diff

kernel/trace/ftrace.c
... ... @@ -2293,7 +2293,7 @@
2293 2293 #ifdef CONFIG_FUNCTION_GRAPH_TRACER
2294 2294 static int __init set_graph_function(char *str)
2295 2295 {
2296   - strncpy(ftrace_graph_buf, str, FTRACE_FILTER_SIZE);
  2296 + strlcpy(ftrace_graph_buf, str, FTRACE_FILTER_SIZE);
2297 2297 return 1;
2298 2298 }
2299 2299 __setup("ftrace_graph_filter=", set_graph_function);