Re: [RFC] Restore PKRU to user-defined value after signal handling

From: Aruna Ramakrishna
Date: Thu Nov 07 2024 - 18:56:59 EST



> On Nov 7, 2024, at 7:56 AM, Dave Hansen <dave.hansen@xxxxxxxxx> wrote:
>
> The question still stands as to whether the new XSTATE_BV value should
> be calculated by the kernel or read directly from the userspace buffer.

If it is calcuated by the kernel, is there a chance that we could inadvertently
set XINUSE[i] to 1 for more components other than just PKRU? Since it is
possible that some other component was set to its init state by XSAVE, but
we’d be overwriting it with:

xstate_bv = mask | XFEATURE_MASK_PKRU;

It seems safer to read userspace buffer and write it back, so that we do not
modify any other XSTATE_BV bits.

Apologies if I’m wildly off base.

Thanks,
Aruna