]> git.baikalelectronics.ru Git - kernel.git/commit
x86/entry: Clear X86_FEATURE_SMAP when CONFIG_X86_SMAP=n
authorVegard Nossum <vegard.nossum@oracle.com>
Sun, 3 Oct 2021 22:34:23 +0000 (00:34 +0200)
committerBorislav Petkov <bp@suse.de>
Wed, 6 Oct 2021 16:46:06 +0000 (18:46 +0200)
commitbb0b6f824744b5aa07fe8fd5a89540bda67ff828
tree81d2b14e4ac7493af42e9df865c2fe32d5f08f89
parent2b3320d6088ee7afa89ba8fda8b2bf0e8a8f037e
x86/entry: Clear X86_FEATURE_SMAP when CONFIG_X86_SMAP=n

Commit

  a42c4c2609bd ("x86/entry, selftests: Further improve user entry sanity checks")

added a warning if AC is set when in the kernel.

Commit

  8183a55d805152 ("x86/entry: Fix AC assertion")

changed the warning to only fire if the CPU supports SMAP.

However, the warning can still trigger on a machine that supports SMAP
but where it's disabled in the kernel config and when running the
syscall_nt selftest, for example:

  ------------[ cut here ]------------
  WARNING: CPU: 0 PID: 49 at irqentry_enter_from_user_mode
  CPU: 0 PID: 49 Comm: init Tainted: G                T 5.15.0-rc4+ #98 e6202628ee053b4f310759978284bd8bb0ce6905
  Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.10.2-1ubuntu1 04/01/2014
  RIP: 0010:irqentry_enter_from_user_mode
  ...
  Call Trace:
   ? irqentry_enter
   ? exc_general_protection
   ? asm_exc_general_protection
   ? asm_exc_general_protectio

IS_ENABLED(CONFIG_X86_SMAP) could be added to the warning condition, but
even this would not be enough in case SMAP is disabled at boot time with
the "nosmap" parameter.

To be consistent with "nosmap" behaviour, clear X86_FEATURE_SMAP when
!CONFIG_X86_SMAP.

Found using entry-fuzz + satrandconfig.

 [ bp: Massage commit message. ]

Fixes: a42c4c2609bd ("x86/entry, selftests: Further improve user entry sanity checks")
Fixes: 8183a55d8051 ("x86/entry: Fix AC assertion")
Signed-off-by: Vegard Nossum <vegard.nossum@oracle.com>
Signed-off-by: Borislav Petkov <bp@suse.de>
Cc: stable@vger.kernel.org
Link: https://lkml.kernel.org/r/20211003223423.8666-1-vegard.nossum@oracle.com
arch/x86/kernel/cpu/common.c