From: Segher Boessenkool <segher@kernel•crashing.org>
To: Michael Ellerman <mpe@ellerman•id.au>
Cc: linuxppc-dev@ozlabs•org, chandan@linux•ibm.com,
npiggin@gmail•com, daniel@linux•ibm.com
Subject: Re: [PATCH v2] powerpc/64: Fix memcmp reading past the end of src/dest
Date: Fri, 8 Feb 2019 09:50:09 -0600 [thread overview]
Message-ID: <20190208155008.GY14180@gate.crashing.org> (raw)
In-Reply-To: <87bm3mkdve.fsf@concordia.ellerman.id.au>
On Fri, Feb 08, 2019 at 05:12:21PM +1100, Michael Ellerman wrote:
> Segher Boessenkool <segher@kernel•crashing.org> writes:
> > On Thu, Feb 07, 2019 at 10:53:13PM +1100, Michael Ellerman wrote:
> >> Chandan reported that fstests' generic/026 test hit a crash:
> >
> >> The instruction dump decodes as:
> >> subfic r6,r5,8
> >> rlwinm r6,r6,3,0,28
> >> ldbrx r9,0,r3
> >> ldbrx r10,0,r4 <-
> >>
> >> Which shows us doing an 8 byte load from c00000062ac3fff9, which
> >> crosses the page boundary at c00000062ac40000 and faults.
> >>
> >> It's not OK for memcmp to read past the end of the source or
> >> destination buffers.
> >
> > It's not okay to access memory pages unsolicited. Reading past the end
> > is fine per se.
>
> Yeah I guess that's true.
>
> Things like KASAN/valgrind probably disagree, but KASAN at least
> overrides memcmp AIUI.
>
> I guess I feel better about it not reading past the end of the buffers,
> but maybe I'm being paranoid.
Sure, and that may be the best thing to do in the kernel. OTOH, newer GCC
will inline many mem* for powerpc, and it will access past the end of
strings and buffers (but not past 4kB boundaries).
> The other complication is we support multiple page sizes, so detecting a
> page boundary is more complicated than it could be.
Yeah.
> So I guess I'm inclined to stick with this approach, but I can update
> the change log.
Thanks! I mentioned it because this was the bug that was hit here: reading
past the end had no ill effect (as far as we know), but accessing the wrong
page did :-)
Segher
prev parent reply other threads:[~2019-02-08 15:52 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-02-07 11:53 [PATCH v2] powerpc/64: Fix memcmp reading past the end of src/dest Michael Ellerman
2019-02-07 12:52 ` Segher Boessenkool
2019-02-08 6:12 ` Michael Ellerman
2019-02-08 15:50 ` Segher Boessenkool [this message]
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=20190208155008.GY14180@gate.crashing.org \
--to=segher@kernel$(echo .)crashing.org \
--cc=chandan@linux$(echo .)ibm.com \
--cc=daniel@linux$(echo .)ibm.com \
--cc=linuxppc-dev@ozlabs$(echo .)org \
--cc=mpe@ellerman$(echo .)id.au \
--cc=npiggin@gmail$(echo .)com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
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