• Andy Lutomirski's avatar
    x86/fault: Make error_code sanitization more robust · e49d3cbe
    Andy Lutomirski authored
    The error code in a page fault on a kernel address indicates
    whether that address is mapped, which should not be revealed in a signal.
    
    The normal code path for a page fault on a kernel address sanitizes the bit,
    but the paths for vsyscall emulation and SIGBUS do not.  Both are
    harmless, but for subtle reasons.  SIGBUS is never sent for a kernel
    address, and vsyscall emulation will never fault on a kernel address
    per se because it will fail an access_ok() check instead.
    
    Make the code more robust by adding a helper that sets the relevant
    fields and sanitizing the error code in the helper.  This also
    cleans up the code -- we had three copies of roughly the same thing.
    Signed-off-by: default avatarAndy Lutomirski <luto@kernel.org>
    Cc: Andy Lutomirski <luto@amacapital.net>
    Cc: Borislav Petkov <bp@alien8.de>
    Cc: Brian Gerst <brgerst@gmail.com>
    Cc: Dave Hansen <dave.hansen@linux.intel.com>
    Cc: Denys Vlasenko <dvlasenk@redhat.com>
    Cc: H. Peter Anvin <hpa@zytor.com>
    Cc: Linus Torvalds <torvalds@linux-foundation.org>
    Cc: Peter Zijlstra <peterz@infradead.org>
    Cc: Rik van Riel <riel@surriel.com>
    Cc: Thomas Gleixner <tglx@linutronix.de>
    Cc: Yu-cheng Yu <yu-cheng.yu@intel.com>
    Link: http://lkml.kernel.org/r/b31159bd55bd0c4fa061a20dfd6c429c094bebaa.1542667307.git.luto@kernel.orgSigned-off-by: default avatarIngo Molnar <mingo@kernel.org>
    e49d3cbe
fault.c 38.8 KB