LKML Archive on lore.kernel.org
 help / Atom feed
From: Steven Rostedt <rostedt@goodmis.org>
To: Arnd Bergmann <arnd@arndb.de>
Cc: Ingo Molnar <mingo@redhat.com>,
	Tom Zanussi <tom.zanussi@linux.intel.com>,
	Rajvi Jingar <rajvi.jingar@intel.com>,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH] tracing: avoid string overflow
Date: Mon, 2 Apr 2018 11:28:03 -0400
Message-ID: <20180402112803.0f1498c2@gandalf.local.home> (raw)
In-Reply-To: <20180328140920.2842153-1-arnd@arndb.de>

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);
>  }

      parent reply index

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-03-28 14:09 Arnd Bergmann
2018-03-28 14:32 ` Tom Zanussi
2018-04-02 15:28 ` Steven Rostedt [this message]

Reply instructions:

You may reply publically to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180402112803.0f1498c2@gandalf.local.home \
    --to=rostedt@goodmis.org \
    --cc=arnd@arndb.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=rajvi.jingar@intel.com \
    --cc=tom.zanussi@linux.intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

LKML Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/lkml/0 lkml/git/0.git
	git clone --mirror https://lore.kernel.org/lkml/1 lkml/git/1.git
	git clone --mirror https://lore.kernel.org/lkml/2 lkml/git/2.git
	git clone --mirror https://lore.kernel.org/lkml/3 lkml/git/3.git
	git clone --mirror https://lore.kernel.org/lkml/4 lkml/git/4.git
	git clone --mirror https://lore.kernel.org/lkml/5 lkml/git/5.git
	git clone --mirror https://lore.kernel.org/lkml/6 lkml/git/6.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 lkml lkml/ https://lore.kernel.org/lkml \
		linux-kernel@vger.kernel.org linux-kernel@archiver.kernel.org
	public-inbox-index lkml


Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.linux-kernel


AGPL code for this site: git clone https://public-inbox.org/ public-inbox