From: Segher Boessenkool <segher@kernel.crashing.org>
To: Michael Ellerman <mpe@ellerman.id.au>
Cc: Anders Roxell <anders.roxell@linaro.org>,
Arnd Bergmann <arnd@arndb.de>,
linux-kernel@vger.kernel.org, Nicholas Piggin <npiggin@gmail.com>,
Paul Mackerras <paulus@samba.org>,
Bagas Sanjaya <bagasdotme@gmail.com>,
Yang Li <yang.lee@linux.alibaba.com>,
linuxppc-dev@lists.ozlabs.org
Subject: Re: outside array bounds error on ppc64_defconfig, GCC 12.1.0
Date: Tue, 7 Jun 2022 10:04:06 -0500 [thread overview]
Message-ID: <20220607150406.GF25951@gate.crashing.org> (raw)
In-Reply-To: <87mtepns81.fsf@mpe.ellerman.id.au>
On Tue, Jun 07, 2022 at 12:05:18PM +1000, Michael Ellerman wrote:
> > arch/powerpc/lib/sstep.c:287:23: error: array subscript [3, 4] is outside array bounds of 'union <anonymous>[1]' [-Werror=array-bounds]
> > 287 | up[3] = tmp;
> > | ~~~~~~^~~~~
>
> This happens because we have a generic byte reverse function
> (do_byte_reverse()), that takes a size as a parameter. So it will
> reverse 8, 16, 32 bytes etc.
>
> In some cases the compiler can see that we're passing a pointer to
> storage that is smaller than 32 bytes, but it isn't convinced that the
> size parameter is also smaller than 32 bytes.
>
> Which I think is reasonable, the code that sets the size is separate
> from this code, so the compiler can't really deduce that it's safe.
>
> I don't see a really simple fix. I tried clamping the size parameter to
> do_byte_reverse() with max(), but that didn't work :/
-Wno-error or at least -Wno-error=array-bounds is a good, simple fix.
Segher
WARNING: multiple messages have this Message-ID (diff)
From: Segher Boessenkool <segher@kernel.crashing.org>
To: Michael Ellerman <mpe@ellerman.id.au>
Cc: Bagas Sanjaya <bagasdotme@gmail.com>,
linuxppc-dev@lists.ozlabs.org,
Anders Roxell <anders.roxell@linaro.org>,
Arnd Bergmann <arnd@arndb.de>,
linux-kernel@vger.kernel.org, Paul Mackerras <paulus@samba.org>,
Nicholas Piggin <npiggin@gmail.com>,
Yang Li <yang.lee@linux.alibaba.com>
Subject: Re: outside array bounds error on ppc64_defconfig, GCC 12.1.0
Date: Tue, 7 Jun 2022 10:04:06 -0500 [thread overview]
Message-ID: <20220607150406.GF25951@gate.crashing.org> (raw)
In-Reply-To: <87mtepns81.fsf@mpe.ellerman.id.au>
On Tue, Jun 07, 2022 at 12:05:18PM +1000, Michael Ellerman wrote:
> > arch/powerpc/lib/sstep.c:287:23: error: array subscript [3, 4] is outside array bounds of 'union <anonymous>[1]' [-Werror=array-bounds]
> > 287 | up[3] = tmp;
> > | ~~~~~~^~~~~
>
> This happens because we have a generic byte reverse function
> (do_byte_reverse()), that takes a size as a parameter. So it will
> reverse 8, 16, 32 bytes etc.
>
> In some cases the compiler can see that we're passing a pointer to
> storage that is smaller than 32 bytes, but it isn't convinced that the
> size parameter is also smaller than 32 bytes.
>
> Which I think is reasonable, the code that sets the size is separate
> from this code, so the compiler can't really deduce that it's safe.
>
> I don't see a really simple fix. I tried clamping the size parameter to
> do_byte_reverse() with max(), but that didn't work :/
-Wno-error or at least -Wno-error=array-bounds is a good, simple fix.
Segher
next prev parent reply other threads:[~2022-06-07 15:08 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-06-01 2:52 outside array bounds error on ppc64_defconfig, GCC 12.1.0 Bagas Sanjaya
2022-06-01 2:52 ` Bagas Sanjaya
2022-06-07 2:05 ` Michael Ellerman
2022-06-07 2:05 ` Michael Ellerman
2022-06-07 14:23 ` David Laight
2022-06-07 14:23 ` David Laight
2022-06-07 15:15 ` Segher Boessenkool
2022-06-07 15:15 ` Segher Boessenkool
2022-06-07 15:04 ` Segher Boessenkool [this message]
2022-06-07 15:04 ` Segher Boessenkool
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=20220607150406.GF25951@gate.crashing.org \
--to=segher@kernel.crashing.org \
--cc=anders.roxell@linaro.org \
--cc=arnd@arndb.de \
--cc=bagasdotme@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linuxppc-dev@lists.ozlabs.org \
--cc=mpe@ellerman.id.au \
--cc=npiggin@gmail.com \
--cc=paulus@samba.org \
--cc=yang.lee@linux.alibaba.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 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.