mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Finn Thain <fthain@telegraphics.com.au>
To: Geert Uytterhoeven <geert@linux-m68k.org>
Cc: kbuild test robot <lkp@intel.com>,
	kbuild-all@01.org, linux-m68k <linux-m68k@lists.linux-m68k.org>,
	Arnd Bergmann <arnd@arndb.de>,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
Subject: Re: [m68k:master 1174/1174] arch/m68k/include/asm/string.h:72:25: warning: '__builtin_memcpy' forming offset 8 is out of the bounds [0, 7]
Date: Tue, 5 Mar 2019 19:58:54 +1100 (AEDT)	[thread overview]
Message-ID: <alpine.LNX.2.21.1903051948290.147@nippy.intranet> (raw)
In-Reply-To: <CAMuHMdUuwudbk15GUPPxL+-Gt4zhhSomk-wMAHeTOkoaDOCUAA@mail.gmail.com>

On Tue, 5 Mar 2019, Geert Uytterhoeven wrote:

> On Tue, Mar 5, 2019 at 3:58 AM Finn Thain <fthain@telegraphics.com.au> wrote:
> > On Tue, 5 Mar 2019, Finn Thain wrote:
> > > Looks bogus to me.
> > >
> > > If you change memcpy to __builtin_memcpy, then we avoid the macro and the
> > > warning changes to,
> > >
> > > ./include/linux/string.h:456:3: warning: '__builtin_memcpy' forming offset [7, 8] is out of the bounds [0, 6] [-Warray-bounds]
> > >    __builtin_memcpy(dest, src, dest_len);
> > >
> > > The compiler has nothing to complain about here. dest is known to be
> > > id->fr and dest_len is known to be sizeof(id->fr).
> > >
> > > The error message indicates that gcc has applied the bounds [0, 6] to dest
> > > when in fact those are the bounds for src.
> > >
> >
> > My mistake. GCC is right, it seems memcpy will read past the end of
> > "5.0.0+".
> 
> But only if the else branch is taken, which is not the case.
> 

You and I know that, because we can see what values get passed to 
memcpy_and_pad(). But how is gcc to know that?

If we replace strlen with __builtin_strlen, this problem goes away. It's 
interesting that the kernel's strlen implementation in 
include/linux/string.h can't achieve this.

-- 

> Gr{oetje,eeting}s,
> 
>                         Geert
> 
> 

  reply	other threads:[~2019-03-05  8:58 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <201903042049.npxcZzps%fengguang.wu@intel.com>
2019-03-04 13:05 ` Geert Uytterhoeven
2019-03-05  2:56   ` Finn Thain
2019-03-05  2:59     ` Finn Thain
2019-03-05  7:49       ` Geert Uytterhoeven
2019-03-05  8:58         ` Finn Thain [this message]
2019-03-05  9:03           ` Geert Uytterhoeven
2019-03-05  9:04           ` Andreas Schwab
2019-03-07  2:59             ` Finn Thain
2019-03-07  8:30               ` Geert Uytterhoeven
2019-03-07 21:43                 ` Finn Thain
2019-03-11  9:14                   ` Geert Uytterhoeven
2019-03-11  9:56                     ` Andreas Schwab
2019-03-11 10:05                       ` Geert Uytterhoeven
2019-03-11 10:13                         ` Andreas Schwab
2019-03-11 10:20                           ` Geert Uytterhoeven
2019-03-11 22:31                             ` Finn Thain
2019-03-18  2:53                               ` Finn Thain

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=alpine.LNX.2.21.1903051948290.147@nippy.intranet \
    --to=fthain@telegraphics.com.au \
    --cc=arnd@arndb.de \
    --cc=geert@linux-m68k.org \
    --cc=kbuild-all@01.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-m68k@lists.linux-m68k.org \
    --cc=lkp@intel.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 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®