]> www.infradead.org Git - users/dwmw2/linux.git/commit
x86/pkeys: Update PKRU to enable all pkeys before XSAVE
authorAruna Ramakrishna <aruna.ramakrishna@oracle.com>
Fri, 2 Aug 2024 06:13:16 +0000 (06:13 +0000)
committerThomas Gleixner <tglx@linutronix.de>
Fri, 2 Aug 2024 12:12:21 +0000 (14:12 +0200)
commit70044df250d022572e26cd301bddf75eac1fe50e
tree934493b8f1a7a062721f260a7d7e83ebd81e0c7d
parent84ee6e8d195e4af4c6c4c961bbf9266bdc8b90ac
x86/pkeys: Update PKRU to enable all pkeys before XSAVE

If the alternate signal stack is protected by a different PKEY than the
current execution stack, copying XSAVE data to the sigaltstack will fail
if its PKEY is not enabled in the PKRU register.

It's unknown which pkey was used by the application for the altstack, so
enable all PKEYS before XSAVE.

But this updated PKRU value is also pushed onto the sigframe, which
means the register value restored from sigcontext will be different from
the user-defined one, which is incorrect.

Fix that by overwriting the PKRU value on the sigframe with the original,
user-defined PKRU.

Signed-off-by: Aruna Ramakrishna <aruna.ramakrishna@oracle.com>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Link: https://lore.kernel.org/all/20240802061318.2140081-4-aruna.ramakrishna@oracle.com
arch/x86/kernel/fpu/signal.c
arch/x86/kernel/signal.c