[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20200601064514.GC11054@sol.localdomain>
Date: Sun, 31 May 2020 23:45:14 -0700
From: Eric Biggers <ebiggers@...nel.org>
To: Al Viro <viro@...iv.linux.org.uk>
Cc: Matthew Wilcox <willy@...radead.org>, linux-ext4@...r.kernel.org,
linux-fsdevel@...r.kernel.org,
linux-f2fs-devel@...ts.sourceforge.net, stable@...r.kernel.org,
Daniel Rosenberg <drosen@...gle.com>,
Gabriel Krisman Bertazi <krisman@...labora.co.uk>
Subject: Re: [PATCH] ext4: avoid utf8_strncasecmp() with unstable name
On Sat, May 30, 2020 at 06:59:07PM +0100, Al Viro wrote:
> On Sat, May 30, 2020 at 10:35:47AM -0700, Eric Biggers wrote:
> > On Sat, May 30, 2020 at 10:18:14AM -0700, Matthew Wilcox wrote:
> > > On Fri, May 29, 2020 at 11:02:16PM -0700, Eric Biggers wrote:
> > > > + if (len <= DNAME_INLINE_LEN - 1) {
> > > > + unsigned int i;
> > > > +
> > > > + for (i = 0; i < len; i++)
> > > > + strbuf[i] = READ_ONCE(str[i]);
> > > > + strbuf[len] = 0;
> > >
> > > This READ_ONCE is going to force the compiler to use byte accesses.
> > > What's wrong with using a plain memcpy()?
> > >
> >
> > It's undefined behavior when the source can be concurrently modified.
> >
> > Compilers can assume that it's not, and remove the memcpy() (instead just using
> > the source data directly) if they can prove that the destination array is never
> > modified again before it goes out of scope.
> >
> > Do you have any suggestions that don't involve undefined behavior?
>
> Even memcpy(strbuf, (volatile void *)str, len)? It's been a while since I've
> looked at these parts of C99...
That doesn't make sense. memcpy() takes a non-volatile pointer, so the pointer
just gets implicitly cast back to (void *), and you get a compiler warning.
- Eric
Powered by blists - more mailing lists