public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Kees Cook <keescook@chromium.org>
To: "Gustavo A. R. Silva" <gustavoars@kernel.org>
Cc: "David S. Miller" <davem@davemloft.net>,
	sparclinux@vger.kernel.org, linux-kernel@vger.kernel.org,
	linux-hardening@vger.kernel.org
Subject: Re: [PATCH][next] sparc: openpromio: Address -Warray-bounds warning
Date: Thu, 29 Jun 2023 12:57:54 -0700	[thread overview]
Message-ID: <202306291257.FF5C86E@keescook> (raw)
In-Reply-To: <ZJTV61z4+lsKlzQG@work>

On Thu, Jun 22, 2023 at 05:14:51PM -0600, Gustavo A. R. Silva wrote:
> One-element arrays are deprecated, and we are replacing them with flexible
> array members instead. So, replace one-element array with flexible-array
> member in struct openpromio.
> 
> Address the following warning found after building (with GCC-13) sparc
> with sparc64_defconfig:
> In function 'opromgetprop',
>     inlined from 'openprom_sunos_ioctl.isra' at drivers/sbus/char/openprom.c:312:11:
> drivers/sbus/char/openprom.c:141:24: warning: array subscript 1 is above array bounds of 'char[1]' [-Warray-bounds=]
>   141 |         op->oprom_array[len] = '\0';
>       |         ~~~~~~~~~~~~~~~^~~~~
> In file included from drivers/sbus/char/openprom.c:31:
> arch/sparc/include/uapi/asm/openpromio.h: In function 'openprom_sunos_ioctl.isra':
> arch/sparc/include/uapi/asm/openpromio.h:16:17: note: while referencing 'oprom_array'
>    16 |         char    oprom_array[1];         /* Holds property names and values. */
>       |                 ^~~~~~~~~~~
> 
> This helps with the ongoing efforts to tighten the FORTIFY_SOURCE
> routines on memcpy() and help us make progress towards globally
> enabling -Warray-bounds.
> 
> This results in no differences in binary output.
> 
> Link: https://github.com/KSPP/linux/issues/79
> Link: https://github.com/KSPP/linux/issues/322
> Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org>

Reviewed-by: Kees Cook <keescook@chromium.org>

-- 
Kees Cook

      reply	other threads:[~2023-06-29 19:58 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-06-22 23:14 [PATCH][next] sparc: openpromio: Address -Warray-bounds warning Gustavo A. R. Silva
2023-06-29 19:57 ` Kees Cook [this message]

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=202306291257.FF5C86E@keescook \
    --to=keescook@chromium.org \
    --cc=davem@davemloft.net \
    --cc=gustavoars@kernel.org \
    --cc=linux-hardening@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=sparclinux@vger.kernel.org \
    /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