OSDN Git Service

x86/fault: Add a helper function to sanitize error code
authorSean Christopherson <sean.j.christopherson@intel.com>
Thu, 12 Nov 2020 22:01:28 +0000 (00:01 +0200)
committerBorislav Petkov <bp@suse.de>
Wed, 18 Nov 2020 17:02:50 +0000 (18:02 +0100)
commitcd072dab453a9b4a9f7927f9eddca5a156fbd87d
tree49a6ae31ca05a6a9cfc4c3d7731876219c4a0513
parent8382c668ce4f367d902f4a340a1bfa9e46096ec1
x86/fault: Add a helper function to sanitize error code

vDSO exception fixup is a replacement for signals in limited situations.
Signals and vDSO exception fixup need to provide similar information to
userspace, including the hardware error code.

That hardware error code needs to be sanitized.  For instance, if userspace
accesses a kernel address, the error code could indicate to userspace
whether the address had a Present=1 PTE.  That can leak information about
the kernel layout to userspace, which is bad.

The existing signal code does this sanitization, but fairly late in the
signal process.  The vDSO exception code runs before the sanitization
happens.

Move error code sanitization out of the signal code and into a helper.
Call the helper in the signal code.

Signed-off-by: Sean Christopherson <sean.j.christopherson@intel.com>
Signed-off-by: Jarkko Sakkinen <jarkko@kernel.org>
Signed-off-by: Borislav Petkov <bp@suse.de>
Acked-by: Jethro Beekman <jethro@fortanix.com>
Link: https://lkml.kernel.org/r/20201112220135.165028-18-jarkko@kernel.org
arch/x86/mm/fault.c