From: Tom Rix <trix@redhat.com>
To: mhiramat@kernel.org, akpm@linux-foundation.org,
ndesaulniers@google.com, masahiroy@kernel.org,
paulmck@kernel.org, hannes@cmpxchg.org, ojeda@kernel.org,
thunder.leizhen@huawei.com, christophe.leroy@csgroup.eu,
vbabka@suse.cz
Cc: linux-kernel@vger.kernel.org, Tom Rix <trix@redhat.com>
Subject: [PATCH] init/Kconfig: extend -Wno-array-bounds to gcc 13
Date: Mon, 6 Mar 2023 17:09:47 -0500 [thread overview]
Message-ID: <20230306220947.1982272-1-trix@redhat.com> (raw)
With gcc 13.0.1 on x86, there are several false positives like
drivers/net/ethernet/microchip/sparx5/sparx5_psfp.c:167:31:
error: array subscript 4 is above array bounds of ‘const struct sparx5_psfp_gce[4]’ [-Werror=array-bounds=]
167 | gce = &sg->gce[i];
| ~~~~~~~^~~
In file included from drivers/net/ethernet/microchip/sparx5/sparx5_psfp.c:8:
drivers/net/ethernet/microchip/sparx5/sparx5_main.h:506:32: note: while referencing ‘gce’
506 | struct sparx5_psfp_gce gce[SPX5_PSFP_GCE_CNT];
| ^~~
The code lines for the reported problem
/* For each scheduling entry */
for (i = 0; i < sg->num_entries; i++) {
gce = &sg->gce[i];
i is bounded by num_entries, which is set in sparx5_tc_flower.c
if (act->gate.num_entries >= SPX5_PSFP_GCE_CNT) {
NL_SET_ERR_MSG_MOD(extack, "Invalid number of gate entries");
return -EINVAL;
}
..
sg->num_entries = act->gate.num_entries;
So disable array-bounds as was done on gcc 11 and 12
Signed-off-by: Tom Rix <trix@redhat.com>
---
init/Kconfig | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/init/Kconfig b/init/Kconfig
index 1fb5f313d18f..10d0a0020726 100644
--- a/init/Kconfig
+++ b/init/Kconfig
@@ -898,10 +898,14 @@ config GCC11_NO_ARRAY_BOUNDS
config GCC12_NO_ARRAY_BOUNDS
def_bool y
+config GCC13_NO_ARRAY_BOUNDS
+ def_bool y
+
config CC_NO_ARRAY_BOUNDS
bool
default y if CC_IS_GCC && GCC_VERSION >= 110000 && GCC_VERSION < 120000 && GCC11_NO_ARRAY_BOUNDS
default y if CC_IS_GCC && GCC_VERSION >= 120000 && GCC_VERSION < 130000 && GCC12_NO_ARRAY_BOUNDS
+ default y if CC_IS_GCC && GCC_VERSION >= 130000 && GCC_VERSION < 140000 && GCC13_NO_ARRAY_BOUNDS
#
# For architectures that know their GCC __int128 support is sound
--
2.27.0
next reply other threads:[~2023-03-06 22:11 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-03-06 22:09 Tom Rix [this message]
2023-03-06 22:20 ` Nick Desaulniers
2023-03-06 23:02 ` Kees Cook
2023-03-07 1:07 ` Tom Rix
2023-03-07 11:42 ` Miguel Ojeda
2023-03-07 13:28 ` Tom Rix
2024-06-17 21:02 ` Kees Cook
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=20230306220947.1982272-1-trix@redhat.com \
--to=trix@redhat.com \
--cc=akpm@linux-foundation.org \
--cc=christophe.leroy@csgroup.eu \
--cc=hannes@cmpxchg.org \
--cc=linux-kernel@vger.kernel.org \
--cc=masahiroy@kernel.org \
--cc=mhiramat@kernel.org \
--cc=ndesaulniers@google.com \
--cc=ojeda@kernel.org \
--cc=paulmck@kernel.org \
--cc=thunder.leizhen@huawei.com \
--cc=vbabka@suse.cz \
/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
all inboxes | Powered by JetHome®