x86/cpu: Use pinning mask for CR4 bits needing to be 0
authorKees Cook <keescook@chromium.org>
Tue, 9 Jun 2020 03:15:09 +0000 (20:15 -0700)
committerSasha Levin <sashal@kernel.org>
Tue, 30 Jun 2020 19:37:08 +0000 (15:37 -0400)
commit3ceaf206b706c1a81ac48d76ced9028e460b27b0
tree5ae0b9aa239d746e338a362c486abf91d7c4c36a
parent96a80133559f1585814fccf110c6ca17ef17b9d7
x86/cpu: Use pinning mask for CR4 bits needing to be 0

commit a13b9d0b97211579ea63b96c606de79b963c0f47 upstream.

The X86_CR4_FSGSBASE bit of CR4 should not change after boot[1]. Older
kernels should enforce this bit to zero, and newer kernels need to
enforce it depending on boot-time configuration (e.g. "nofsgsbase").
To support a pinned bit being either 1 or 0, use an explicit mask in
combination with the expected pinned bit values.

[1] https://lore.kernel.org/lkml/20200527103147.GI325280@hirez.programming.kicks-ass.net

Signed-off-by: Kees Cook <keescook@chromium.org>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: stable@vger.kernel.org
Link: https://lkml.kernel.org/r/202006082013.71E29A42@keescook
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
arch/x86/kernel/cpu/common.c