* [PATCH] tracing: avoid string overflow
@ 2018-03-28 14:09 Arnd Bergmann
2018-03-28 14:32 ` Tom Zanussi
2018-04-02 15:28 ` Steven Rostedt
0 siblings, 2 replies; 3+ messages in thread
From: Arnd Bergmann @ 2018-03-28 14:09 UTC (permalink / raw)
To: Steven Rostedt, Ingo Molnar
Cc: Arnd Bergmann, Tom Zanussi, Rajvi Jingar, linux-kernel
'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.
Fixes: f404da6e1d46 ("tracing: Add 'last error' error facility for hist triggers")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
kernel/trace/trace_events_hist.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/kernel/trace/trace_events_hist.c b/kernel/trace/trace_events_hist.c
index 4f027642ceef..8357f36d7a1e 100644
--- a/kernel/trace/trace_events_hist.c
+++ b/kernel/trace/trace_events_hist.c
@@ -393,7 +393,7 @@ static void hist_err_event(char *str, char *system, char *event, char *var)
else if (system)
snprintf(err, MAX_FILTER_STR_VAL, "%s.%s", system, event);
else
- strncpy(err, var, MAX_FILTER_STR_VAL);
+ strscpy(err, var, MAX_FILTER_STR_VAL);
hist_err(str, err);
}
--
2.9.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] tracing: avoid string overflow
2018-03-28 14:09 [PATCH] tracing: avoid string overflow Arnd Bergmann
@ 2018-03-28 14:32 ` Tom Zanussi
2018-04-02 15:28 ` Steven Rostedt
1 sibling, 0 replies; 3+ messages in thread
From: Tom Zanussi @ 2018-03-28 14:32 UTC (permalink / raw)
To: Arnd Bergmann; +Cc: Steven Rostedt, Ingo Molnar, Rajvi Jingar, linux-kernel
Hi Arnd,
On Wed, 2018-03-28 at 16:09 +0200, Arnd Bergmann wrote:
> '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.
>
> Fixes: f404da6e1d46 ("tracing: Add 'last error' error facility for hist triggers")
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
> ---
> kernel/trace/trace_events_hist.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/kernel/trace/trace_events_hist.c b/kernel/trace/trace_events_hist.c
> index 4f027642ceef..8357f36d7a1e 100644
> --- a/kernel/trace/trace_events_hist.c
> +++ b/kernel/trace/trace_events_hist.c
> @@ -393,7 +393,7 @@ static void hist_err_event(char *str, char *system, char *event, char *var)
> else if (system)
> snprintf(err, MAX_FILTER_STR_VAL, "%s.%s", system, event);
> else
> - strncpy(err, var, MAX_FILTER_STR_VAL);
> + strscpy(err, var, MAX_FILTER_STR_VAL);
>
> hist_err(str, err);
> }
Yes, thanks for finding this, and for the patch!
Acked-by: Tom Zanussi <tom.zanussi@linux.intel.com>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] tracing: avoid string overflow
2018-03-28 14:09 [PATCH] tracing: avoid string overflow Arnd Bergmann
2018-03-28 14:32 ` Tom Zanussi
@ 2018-04-02 15:28 ` Steven Rostedt
1 sibling, 0 replies; 3+ messages in thread
From: Steven Rostedt @ 2018-04-02 15:28 UTC (permalink / raw)
To: Arnd Bergmann; +Cc: Ingo Molnar, Tom Zanussi, Rajvi Jingar, linux-kernel
On Wed, 28 Mar 2018 16:09:10 +0200
Arnd Bergmann <arnd@arndb.de> wrote:
> '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.
>
> Fixes: f404da6e1d46 ("tracing: Add 'last error' error facility for hist triggers")
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Thanks! I pulled this in and will push it to git after testing has
succeeded.
-- Steve
> ---
> kernel/trace/trace_events_hist.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/kernel/trace/trace_events_hist.c b/kernel/trace/trace_events_hist.c
> index 4f027642ceef..8357f36d7a1e 100644
> --- a/kernel/trace/trace_events_hist.c
> +++ b/kernel/trace/trace_events_hist.c
> @@ -393,7 +393,7 @@ static void hist_err_event(char *str, char *system, char *event, char *var)
> else if (system)
> snprintf(err, MAX_FILTER_STR_VAL, "%s.%s", system, event);
> else
> - strncpy(err, var, MAX_FILTER_STR_VAL);
> + strscpy(err, var, MAX_FILTER_STR_VAL);
>
> hist_err(str, err);
> }
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2018-04-02 15:28 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-03-28 14:09 [PATCH] tracing: avoid string overflow Arnd Bergmann
2018-03-28 14:32 ` Tom Zanussi
2018-04-02 15:28 ` Steven Rostedt
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).