All of lore.kernel.org
 help / color / mirror / Atom feed
From: Sergey Senozhatsky <senozhatsky@chromium.org>
To: John Ogness <john.ogness@linutronix.de>
Cc: Petr Mladek <pmladek@suse.com>,
	Sergey Senozhatsky <senozhatsky@chromium.org>,
	Steven Rostedt <rostedt@goodmis.org>,
	Thomas Gleixner <tglx@linutronix.de>,
	linux-kernel@vger.kernel.org, kernel test robot <lkp@intel.com>
Subject: Re: [PATCH printk v1] printk: fix illegal pbufs access for !CONFIG_PRINTK
Date: Thu, 21 Sep 2023 11:18:59 +0900	[thread overview]
Message-ID: <20230921021859.GA14418@google.com> (raw)
In-Reply-To: <20230920155238.670439-1-john.ogness@linutronix.de>

On (23/09/20 17:58), John Ogness wrote:
> When CONFIG_PRINTK is not set, PRINTK_MESSAGE_MAX is 0. This
> leads to a zero-sized array @outbuf in @printk_shared_pbufs. In
> console_flush_all() a pointer to the first element of the array
> is assigned with:
> 
>    char *outbuf = &printk_shared_pbufs.outbuf[0];
> 
> For !CONFIG_PRINTK this leads to a compiler warning:
> 
>    warning: array subscript 0 is outside array bounds of
>    'char[0]' [-Warray-bounds]
> 
> This is not really dangerous because printk_get_next_message()
> always returns false for !CONFIG_PRINTK, which leads to @outbuf
> never being used. However, it makes no sense to even compile
> these functions for !CONFIG_PRINTK.

I wonder if anyone really use !PRINTK kernels. Can we get rid
of CONFIG_PRINTK?

> Extend the existing '#ifdef CONFIG_PRINTK' block to contain
> the formatting and emitting functions since these have no
> purpose in !CONFIG_PRINTK. This also allows removing several
> more !CONFIG_PRINTK dummies as well as moving
> @suppress_panic_printk into a CONFIG_PRINTK block.
> 
> Reported-by: kernel test robot <lkp@intel.com>
> Closes: https://lore.kernel.org/oe-kbuild-all/202309201724.M9BMAQIh-lkp@intel.com/
> Signed-off-by: John Ogness <john.ogness@linutronix.de>

FWIW,
Reviewed-by: Sergey Senozhatsky <senozhatsky@chromium.org>

  reply	other threads:[~2023-09-21  2:19 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-09-20 15:52 [PATCH printk v1] printk: fix illegal pbufs access for !CONFIG_PRINTK John Ogness
2023-09-21  2:18 ` Sergey Senozhatsky [this message]
2023-09-21  7:13   ` John Ogness
2023-09-21  9:44     ` Sergey Senozhatsky

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=20230921021859.GA14418@google.com \
    --to=senozhatsky@chromium.org \
    --cc=john.ogness@linutronix.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lkp@intel.com \
    --cc=pmladek@suse.com \
    --cc=rostedt@goodmis.org \
    --cc=tglx@linutronix.de \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.