Subject: Re: [PATCH v2 2/6] powerpc/pkeys: Save the pkey registers before fork

From: Michael Ellerman <[email-masked]>
Date: Thu, 21 Jun 2018 14:13:40 +1000

Ram Pai <[email-masked]> writes:

> On Tue, Jun 19, 2018 at 10:39:56PM +1000, Michael Ellerman wrote:
>> Ram Pai <[email-masked]> writes:
>> 
>> > When a thread forks the contents of AMR, IAMR, UAMOR registers in the
>> > newly forked thread are not inherited.
>> >
>> > Save the registers before forking, for content of those
>> > registers to be automatically copied into the new thread.
>> >
>> > CC: Michael Ellerman <[email-masked]>
>> > CC: Florian Weimer <[email-masked]>
>> > CC: Andy Lutomirski <[email-masked]>
>> > CC: Thiago Jung Bauermann <[email-masked]>
>> > Signed-off-by: Ram Pai <[email-masked]>
>> 
>> Again this is an ABI change but we'll call it a bug fix I guess.
>
> yes. the same defense here too. its a behaviorial change for the better.
> Single threaded applications will not see any behaviorial change.
> Multithreaded apps, which were unable to consume, the behavior will now be
> able to do so.

Well threads is one thing, but this also affects processes.

And actually without this fix it's possible that a child process could
fault on a region protected in the parent, if the value in the AMR in
the thread struct happens to block access at the time of fork(). The
value in the thread struct would be whatever was in the AMR the last
time the parent was scheduled in. I think?

cheers