From: Yury Norov <yury.norov@gmail.com>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: mm-commits@vger.kernel.org, yoann.congal@smile.fr,
vincent.guittot@linaro.org, rdunlap@infradead.org,
pmladek@suse.com, nphamcs@gmail.com, masahiroy@kernel.org,
gustavoars@kernel.org, davem@davemloft.net, arnd@arndb.de,
aleksander.lobakin@intel.com
Subject: Re: + gcc-disable-warray-bounds-for-gcc-9.patch added to mm-hotfixes-unstable branch
Date: Fri, 14 Jun 2024 10:16:02 -0700 [thread overview]
Message-ID: <Zmx60snJwvBsgUNX@yury-ThinkPad> (raw)
In-Reply-To: <20240524030008.78A1AC2BD10@smtp.kernel.org>
On Thu, May 23, 2024 at 08:00:07PM -0700, Andrew Morton wrote:
>
> The patch titled
> Subject: gcc: disable '-Warray-bounds' for gcc-9
> has been added to the -mm mm-hotfixes-unstable branch. Its filename is
> gcc-disable-warray-bounds-for-gcc-9.patch
Hi Andrew,
The script said you've applied it to mm-hotfixes, but the patch is
still not in mainline. Are you going to move it in this cycle, or
what are your plans on it?
Thanks,
Yury
> This patch will shortly appear at
> https://git.kernel.org/pub/scm/linux/kernel/git/akpm/25-new.git/tree/patches/gcc-disable-warray-bounds-for-gcc-9.patch
>
> This patch will later appear in the mm-hotfixes-unstable branch at
> git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm
>
> Before you just go and hit "reply", please:
> a) Consider who else should be cc'ed
> b) Prefer to cc a suitable mailing list as well
> c) Ideally: find the original patch on the mailing list and do a
> reply-to-all to that, adding suitable additional cc's
>
> *** Remember to use Documentation/process/submit-checklist.rst when testing your code ***
>
> The -mm tree is included into linux-next via the mm-everything
> branch at git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm
> and is updated there every 2-3 working days
>
> ------------------------------------------------------
> From: Yury Norov <yury.norov@gmail.com>
> Subject: gcc: disable '-Warray-bounds' for gcc-9
> Date: Wed, 22 May 2024 15:58:30 -0700
>
> '-Warray-bounds' is already disabled for gcc-10+. Now that we've merged
> bitmap_{read,write), I see the following error when building the kernel
> with gcc-9.4 (Ubuntu 20.04.4 LTS) for x86_64 allmodconfig:
>
> drivers/pinctrl/pinctrl-cy8c95x0.c: In function `cy8c95x0_read_regs_mask.isra.0':
> include/linux/bitmap.h:756:18: error: array subscript [1, 288230376151711744] is outside array bounds of `long unsigned int[1]' [-Werror=array-bounds]
> 756 | value_high = map[index + 1] & BITMAP_LAST_WORD_MASK(start + nbits);
> | ~~~^~~~~~~~~~~
>
> The immediate reason is that the commit b44759705f7d ("bitmap: make
> bitmap_{get,set}_value8() use bitmap_{read,write}()") switched the
> bitmap_get_value8() to an alias of bitmap_read(); the same for 'set'.
>
> Now; the code that triggers Warray-bounds, calls the function like this:
>
> #define MAX_BANK 8
> #define BANK_SZ 8
> #define MAX_LINE (MAX_BANK * BANK_SZ)
> DECLARE_BITMAP(tval, MAX_LINE); // 64-bit map: unsigned long tval[1]
>
> read_val |= bitmap_get_value8(tval, i * BANK_SZ) & ~bits;
>
> bitmap_read() is implemented such that it may conditionally dereference a
> pointer beyond the boundary like this:
>
> unsigned long offset = start % BITS_PER_LONG;
> unsigned long space = BITS_PER_LONG - offset;
>
> if (space >= nbits)
> return (map[index] >> offset) & BITMAP_LAST_WORD_MASK(nbits);
>
> value_low = map[index] & BITMAP_FIRST_WORD_MASK(start);
> value_high = map[index + 1] & BITMAP_LAST_WORD_MASK(start + nbits);
> return (value_low >> offset) | (value_high << space);
>
> In case of bitmap_get_value8(), it's impossible to violate the boundary
> because 'space >= nbits' is never the true for byte-aligned 8-bit access.
> So, this is clearly a false-positive.
>
> The same type of false-positives break my allmodconfig build in many
> places. gcc-8, is clear, however.
>
> Link: https://lkml.kernel.org/r/20240522225830.1201778-1-yury.norov@gmail.com
> Signed-off-by: Yury Norov <yury.norov@gmail.com>
> Cc: Alexander Lobakin <aleksander.lobakin@intel.com>
> Cc: David S. Miller <davem@davemloft.net>
> Cc: Gustavo A. R. Silva <gustavoars@kernel.org>
> Cc: Masahiro Yamada <masahiroy@kernel.org>
> Cc: Nhat Pham <nphamcs@gmail.com>
> Cc: Petr Mladek <pmladek@suse.com>
> Cc: Randy Dunlap <rdunlap@infradead.org>
> Cc: Vincent Guittot <vincent.guittot@linaro.org>
> Cc: Yoann Congal <yoann.congal@smile.fr>
> Cc: Arnd Bergmann <arnd@arndb.de>
> Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
> ---
>
> init/Kconfig | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> --- a/init/Kconfig~gcc-disable-warray-bounds-for-gcc-9
> +++ a/init/Kconfig
> @@ -883,7 +883,7 @@ config GCC10_NO_ARRAY_BOUNDS
>
> config CC_NO_ARRAY_BOUNDS
> bool
> - default y if CC_IS_GCC && GCC_VERSION >= 100000 && GCC10_NO_ARRAY_BOUNDS
> + default y if CC_IS_GCC && GCC_VERSION >= 90000 && GCC10_NO_ARRAY_BOUNDS
>
> # Currently, disable -Wstringop-overflow for GCC globally.
> config GCC_NO_STRINGOP_OVERFLOW
> _
>
> Patches currently in -mm which might be from yury.norov@gmail.com are
>
> gcc-disable-warray-bounds-for-gcc-9.patch
next prev parent reply other threads:[~2024-06-14 17:16 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-05-24 3:00 + gcc-disable-warray-bounds-for-gcc-9.patch added to mm-hotfixes-unstable branch Andrew Morton
2024-05-29 14:39 ` Arnd Bergmann
2024-05-31 1:18 ` Yury Norov
2024-05-31 13:29 ` Arnd Bergmann
2024-05-31 19:48 ` Yury Norov
2024-06-14 17:16 ` Yury Norov [this message]
2024-06-14 17:40 ` Andrew Morton
2024-06-14 17:55 ` Yury Norov
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=Zmx60snJwvBsgUNX@yury-ThinkPad \
--to=yury.norov@gmail.com \
--cc=akpm@linux-foundation.org \
--cc=aleksander.lobakin@intel.com \
--cc=arnd@arndb.de \
--cc=davem@davemloft.net \
--cc=gustavoars@kernel.org \
--cc=masahiroy@kernel.org \
--cc=mm-commits@vger.kernel.org \
--cc=nphamcs@gmail.com \
--cc=pmladek@suse.com \
--cc=rdunlap@infradead.org \
--cc=vincent.guittot@linaro.org \
--cc=yoann.congal@smile.fr \
/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.