x86/fault: Correct a few user vs kernel checks wrt WRUSS
authorAndy Lutomirski <luto@kernel.org>
Wed, 10 Feb 2021 02:33:38 +0000 (18:33 -0800)
committerBorislav Petkov <bp@suse.de>
Wed, 10 Feb 2021 13:13:32 +0000 (14:13 +0100)
commit56e62cd28aaae2fcbec8af67b05843c47c6da170
treeecb551f5ca0bb3cf62f6046bdd62382cd5e3ab27
parentef2544fb3f6457b79fc73cea39dafd67ee0f2824
x86/fault: Correct a few user vs kernel checks wrt WRUSS

In general, page fault errors for WRUSS should be just like get_user(),
etc.  Fix three bugs in this area:

There is a comment that says that, if the kernel can't handle a page fault
on a user address due to OOM, the OOM-kill-and-retry logic would be
skipped.  The code checked kernel *privilege*, not kernel mode, so it
missed WRUSS.  This means that the kernel would malfunction if it got OOM
on a WRUSS fault -- this would be a kernel-mode, user-privilege fault, and
the OOM killer would be invoked and the handler would retry the faulting
instruction.

A failed user access from kernel while a fatal signal is pending should
fail even if the instruction in question was WRUSS.

do_sigbus() should not send SIGBUS for WRUSS -- it should handle it like
any other kernel mode failure.

Signed-off-by: Andy Lutomirski <luto@kernel.org>
Signed-off-by: Borislav Petkov <bp@suse.de>
Link: https://lkml.kernel.org/r/a7b7bcea730bd4069e6b7e629236bb2cf526c2fb.1612924255.git.luto@kernel.org
arch/x86/mm/fault.c