Skip to content

Commit b7c21bc

Browse files
hansendcKAGA-KOKO
authored andcommitted
x86/pti: Disallow global kernel text with RANDSTRUCT
commit 26d35ca6c3776784f8156e1d6f80cc60d9a2a915 RANDSTRUCT derives its hardening benefits from the attacker's lack of knowledge about the layout of kernel data structures. Keep the kernel image non-global in cases where RANDSTRUCT is in use to help keep the layout a secret. Fixes: 8c06c77 (x86/pti: Leave kernel text global for !PCID) Reported-by: Kees Cook <[email protected]> Signed-off-by: Dave Hansen <[email protected]> Signed-off-by: Thomas Gleixner <[email protected]> Acked-by: Ingo Molnar <[email protected]> Cc: Andrea Arcangeli <[email protected]> Cc: Juergen Gross <[email protected]> Cc: Josh Poimboeuf <[email protected]> Cc: Greg Kroah-Hartman <[email protected]> Cc: Peter Zijlstra <[email protected]> Cc: David Woodhouse <[email protected]> Cc: Hugh Dickins <[email protected]> Cc: [email protected] Cc: Linus Torvalds <[email protected]> Cc: Borislav Petkov <[email protected]> Cc: Andy Lutomirski <[email protected]> Cc: Nadav Amit <[email protected]> Cc: Dan Williams <[email protected]> Cc: Arjan van de Ven <[email protected]> Cc: Vlastimil Babka <[email protected]> Link: https://lkml.kernel.org/r/[email protected]
1 parent a44ca8f commit b7c21bc

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

arch/x86/mm/pti.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -421,6 +421,16 @@ static inline bool pti_kernel_image_global_ok(void)
421421
if (boot_cpu_has(X86_FEATURE_K8))
422422
return false;
423423

424+
/*
425+
* RANDSTRUCT derives its hardening benefits from the
426+
* attacker's lack of knowledge about the layout of kernel
427+
* data structures. Keep the kernel image non-global in
428+
* cases where RANDSTRUCT is in use to help keep the layout a
429+
* secret.
430+
*/
431+
if (IS_ENABLED(CONFIG_GCC_PLUGIN_RANDSTRUCT))
432+
return false;
433+
424434
return true;
425435
}
426436

0 commit comments

Comments
 (0)