Skip to content
Commit 8cd1ae34 authored by Jiashuo Liang's avatar Jiashuo Liang Committed by Greg Kroah-Hartman
Browse files

x86/fault: Fix wrong signal when vsyscall fails with pkey

[ Upstream commit d4ffd5df ]

The function __bad_area_nosemaphore() calls kernelmode_fixup_or_oops()
with the parameter @signal being actually @pkey, which will send a
signal numbered with the argument in @pkey.

This bug can be triggered when the kernel fails to access user-given
memory pages that are protected by a pkey, so it can go down the
do_user_addr_fault() path and pass the !user_mode() check in
__bad_area_nosemaphore().

Most cases will simply run the kernel fixup code to make an -EFAULT. But
when another condition current->thread.sig_on_uaccess_err is met, which
is only used to emulate vsyscall, the kernel will generate the wrong
signal.

Add a new parameter @pkey to kernelmode_fixup_or_oops() to fix this.

 [ bp: Massage commit message, fix build error as reported by the 0day
   bot: https://lkml.kernel.org/r/202109202245.APvuT8BX-lkp@intel.com ]

Fixes: 5042d40a

 ("x86/fault: Bypass no_context() for implicit kernel faults from usermode")
Reported-by: default avatarkernel test robot <lkp@intel.com>
Signed-off-by: default avatarJiashuo Liang <liangjs@pku.edu.cn>
Signed-off-by: default avatarBorislav Petkov <bp@suse.de>
Acked-by: default avatarDave Hansen <dave.hansen@linux.intel.com>
Link: https://lkml.kernel.org/r/20210730030152.249106-1-liangjs@pku.edu.cn
Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
parent bfacc1de
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment