]> git.baikalelectronics.ru Git - kernel.git/commit
tracing: Avoid string overflow
authorArnd Bergmann <arnd@arndb.de>
Wed, 28 Mar 2018 14:09:10 +0000 (16:09 +0200)
committerSteven Rostedt (VMware) <rostedt@goodmis.org>
Tue, 3 Jul 2018 22:14:39 +0000 (18:14 -0400)
commita9f95fb2079006ad5cc6ba734a55a0159824532d
treea4b635c35a366aee31cbb33964701ed2faaece5b
parentbd594001da828129ed149628b7cd368061398a51
tracing: Avoid string overflow

'err' is used as a NUL-terminated string, but using strncpy() with the length
equal to the buffer size may result in lack of the termination:

kernel/trace/trace_events_hist.c: In function 'hist_err_event':
kernel/trace/trace_events_hist.c:396:3: error: 'strncpy' specified bound 256 equals destination size [-Werror=stringop-truncation]
   strncpy(err, var, MAX_FILTER_STR_VAL);

This changes it to use the safer strscpy() instead.

Link: http://lkml.kernel.org/r/20180328140920.2842153-1-arnd@arndb.de
Cc: stable@vger.kernel.org
Fixes: b60fe378b081 ("tracing: Add 'last error' error facility for hist triggers")
Acked-by: Tom Zanussi <tom.zanussi@linux.intel.com>
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
kernel/trace/trace_events_hist.c