Re: POWER: Unexpected fault when writing to brk-allocated memory

From: Nicholas Piggin
Date: Sat Nov 11 2017 - 05:31:15 EST


On Fri, 10 Nov 2017 12:08:35 +0000
David Laight <David.Laight@xxxxxxxxxx> wrote:

> From: Matthew Wilcox
> > Sent: 09 November 2017 19:44
> >
> > On Fri, Nov 10, 2017 at 04:15:26AM +1100, Nicholas Piggin wrote:
> > > So these semantics are what we're going with? Anything that does mmap() is
> > > guaranteed of getting a 47-bit pointer and it can use the top 17 bits for
> > > itself? Is intended to be cross-platform or just x86 and power specific?
> >
> > It is x86 and powerpc specific. The arm64 people have apparently stumbled
> > across apps that expect to be able to use bit 48 for their own purposes.
> > And their address space is 48 bit by default. Oops.
>
> (Do you mean 49bit?)

I think he meant bit 47, which makes sense because they were probably
ported from x86-64 with 47 bit address. That seems to be why x86-64
5-level and powerpc decided to limit to a 47 bit address space by
default.

>
> Aren't such apps just doomed to be broken?

Well they're not portable but they are not broken if virtual address
is limited.

>
> ISTR there is something on (IIRC) sparc64 that does a 'match'
> on the high address bits to make it much harder to overrun
> one area into another.

I'm not sure about that but I think the problem would be the app
masking out bits from the pointer for its own use before ever
dereferencing it.

Thanks,
Nick