Commit e575a86f authored by Kees Cook's avatar Kees Cook Committed by Ingo Molnar
Browse files

x86: Do not leak kernel page mapping locations

Without this patch, it is trivial to determine kernel page
mappings by examining the error code reported to dmesg[1].
Instead, declare the entire kernel memory space as a violation
of a present page.

Additionally, since show_unhandled_signals is enabled by
default, switch branch hinting to the more realistic
expectation, and unobfuscate the setting of the PF_PROT bit to
improve readability.


Reported-by: default avatarDan Rosenberg <>
Suggested-by: default avatarBrad Spengler <>
Signed-off-by: default avatarKees Cook <>
Acked-by: default avatarH. Peter Anvin <>
Cc: Paul E. McKenney <>
Cc: Frederic Weisbecker <>
Cc: Eric W. Biederman <>
Cc: Linus Torvalds <>
Cc: Andrew Morton <>
Cc: Peter Zijlstra <>

Signed-off-by: default avatarIngo Molnar <>
parent bb9b1a83
......@@ -748,13 +748,15 @@ __bad_area_nosemaphore(struct pt_regs *regs, unsigned long error_code,
/* Kernel addresses are always protection faults: */
if (address >= TASK_SIZE)
error_code |= PF_PROT;
if (unlikely(show_unhandled_signals))
if (likely(show_unhandled_signals))
show_signal_msg(regs, error_code, address, tsk);
/* Kernel addresses are always protection faults: */
tsk->thread.cr2 = address;
tsk->thread.error_code = error_code | (address >= TASK_SIZE);
tsk->thread.error_code = error_code;
tsk->thread.trap_nr = X86_TRAP_PF;
force_sig_info_fault(SIGSEGV, si_code, address, tsk, 0);
Markdown is supported
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