Re: [PATCH v2] x86/fpu: Allow PKRU to be (once again) written by ptrace.

From: Dave Hansen
Date: Fri Aug 05 2022 - 14:03:36 EST


On 8/5/22 10:24, Dave Hansen wrote:
> On 8/3/22 20:16, Kyle Huey wrote:
>> When management of the PKRU register was moved away from XSTATE, emulation
>> of PKRU's existence in XSTATE was added for APIs that read XSTATE, but not
>> for APIs that write XSTATE. This can be seen by running gdb and executing
>> `p $pkru`, `set $pkru = 42`, and `p $pkru`. On affected kernels (5.14+) the
>> write to the PKRU register (which gdb performs through ptrace) is ignored.
> Do you happen to have a reproducer for this sitting around? I'd love to
> get an addition to the pkeys selftest/ in place to make sure we don't
> break this again. PKRU is a very special snowflake.

Let me put this another way: I'm much more likely to quickly merge fixes
that come with a selftest that demonstrates the breakage and the fix.
An in-kernel test ensures:

1. There is a problem now
2. The patch fixes the problem
3. The problem does not recur