linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Sergey Senozhatsky <sergey.senozhatsky.work@gmail.com>
To: Nathan Chancellor <natechancellor@gmail.com>
Cc: Petr Mladek <pmladek@suse.com>,
	Sergey Senozhatsky <sergey.senozhatsky@gmail.com>,
	Steven Rostedt <rostedt@goodmis.org>,
	linux-kernel@vger.kernel.org, clang-built-linux@googlegroups.com
Subject: Re: [PATCH] printk: Convert a use of sprintf to snprintf in console_unlock
Date: Fri, 31 Jan 2020 16:02:37 +0900	[thread overview]
Message-ID: <20200131070237.GB240941@google.com> (raw)
In-Reply-To: <20200130221644.2273-1-natechancellor@gmail.com>

On (20/01/30 15:16), Nathan Chancellor wrote:
> When CONFIG_PRINTK is disabled (e.g. when building allnoconfig), clang
> warns:
> 
> ../kernel/printk/printk.c:2416:10: warning: 'sprintf' will always
> overflow; destination buffer has size 0, but format string expands to at
> least 33 [-Wfortify-source]
>                         len = sprintf(text,
>                               ^
> 1 warning generated.
> 
> It is not wrong; text has a zero size when CONFIG_PRINTK is disabled
> because LOG_LINE_MAX and PREFIX_MAX are both zero. Change to snprintf so
> that this case is explicitly handled without any risk of overflow.

We probably can add a note here that for !CONFIG_PRINTK builds
logbuf overflow is very unlikely.

Otherwise,
Reviewed-by: Sergey Senozhatsky <sergey.senozhatsky@gmail.com>

	-ss

  reply	other threads:[~2020-01-31  7:02 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-01-30 22:16 [PATCH] printk: Convert a use of sprintf to snprintf in console_unlock Nathan Chancellor
2020-01-31  7:02 ` Sergey Senozhatsky [this message]
2020-02-11 13:05   ` Petr Mladek

Reply instructions:

You may reply publicly 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=20200131070237.GB240941@google.com \
    --to=sergey.senozhatsky.work@gmail.com \
    --cc=clang-built-linux@googlegroups.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=natechancellor@gmail.com \
    --cc=pmladek@suse.com \
    --cc=rostedt@goodmis.org \
    --cc=sergey.senozhatsky@gmail.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
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).