LKML Archive on
 help / color / Atom feed
From: Kees Cook <>
Cc: Thomas Gleixner <>,
	Ingo Molnar <>, "H. Peter Anvin" <>,, Andrew Morton <>,
	"Paul E. McKenney" <>,
	Frederic Weisbecker <>,
	"Eric W. Biederman" <>,
	Dan Rosenberg <>,
	Brad Spengler <>
Subject: [PATCH] x86: do not leak kernel page mapping locations
Date: Thu, 7 Feb 2013 09:44:13 -0800
Message-ID: <> (raw)

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: Dan Rosenberg <>
Suggested-by: Brad Spengler <>
Signed-off-by: Kees Cook <>
 arch/x86/mm/fault.c |    8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/arch/x86/mm/fault.c b/arch/x86/mm/fault.c
index 027088f..fb674fd 100644
--- a/arch/x86/mm/fault.c
+++ b/arch/x86/mm/fault.c
@@ -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);

Kees Cook
Chrome OS Security

             reply index

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-02-07 17:44 Kees Cook [this message]
2013-02-07 19:26 ` H. Peter Anvin
2013-02-08 14:05 ` [tip:x86/urgent] x86: Do " tip-bot for Kees Cook

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \ \ \ \ \ \ \ \ \ \ \ \ \ \

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

LKML Archive on

Archives are clonable:
	git clone --mirror lkml/git/0.git
	git clone --mirror lkml/git/1.git
	git clone --mirror lkml/git/2.git
	git clone --mirror lkml/git/3.git
	git clone --mirror lkml/git/4.git
	git clone --mirror lkml/git/5.git
	git clone --mirror lkml/git/6.git
	git clone --mirror lkml/git/7.git
	git clone --mirror lkml/git/8.git
	git clone --mirror lkml/git/9.git
	git clone --mirror lkml/git/10.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 lkml lkml/ \
	public-inbox-index lkml

Example config snippet for mirrors

Newsgroup available over NNTP:

AGPL code for this site: git clone