On 05/19/2018 02:52 AM, Ram Pai wrote:
The POWER semantics make it very hard for a multithreaded program to
meaningfully use protection keys to prevent accidental access to important
memory.
And you can change access rights for unallocated keys (unallocated
at thread start time, allocated later) on x86. I have extended the
misc/tst-pkeys test to verify that, and it passes on x86, but not on
POWER, where the access rights are stuck.
This is something I do not understand. How can a thread change permissions
on a key, that is not even allocated in the first place.
It was allocated by another thread, and there is synchronization so that
the allocation happens before the change in access rights.
Do you consider a key
allocated in some other thread's context, as allocated in this threads
context?
Yes, x86 does that.
If not, does that mean -- On x86, you can activate a key just
by changing its permission?
This also true on x86, but just an artifact of the implementation. You
are supposed to call pkey_alloc before changing the flag.
Thanks,
Florian