powerpc/dexcr: Reset DEXCR value across exec
authorBenjamin Gray <bgray@linux.ibm.com>
Wed, 17 Apr 2024 11:23:19 +0000 (21:23 +1000)
committerMichael Ellerman <mpe@ellerman.id.au>
Fri, 3 May 2024 10:46:51 +0000 (20:46 +1000)
commitbbd99922d0f4518518282217159666c679c6a0d1
tree6c2d20d8594157030d86f67582c38370560ccf0b
parent75171f06c4507c3b6b5a69d793879fb20d108bb1
powerpc/dexcr: Reset DEXCR value across exec

Inheriting the DEXCR across exec can have security and usability
concerns. If a program is compiled with hash instructions it generally
expects to run with NPHIE enabled. But if the parent process disables
NPHIE then if it's not careful it will be disabled for any children too
and the protection offered by hash checks is basically worthless.

This patch introduces a per-process reset value that new execs in a
particular process tree are initialized with. This enables fine grained
control over what DEXCR value child processes run with by default.
For example, containers running legacy binaries that expect hash
instructions to act as NOPs could configure the reset value of the
container root to control the default reset value for all members of
the container.

Signed-off-by: Benjamin Gray <bgray@linux.ibm.com>
[mpe: Add missing SPDX tag on dexcr.c]
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Link: https://msgid.link/20240417112325.728010-4-bgray@linux.ibm.com
arch/powerpc/include/asm/processor.h
arch/powerpc/kernel/Makefile
arch/powerpc/kernel/dexcr.c [new file with mode: 0644]
arch/powerpc/kernel/process.c