All of lore.kernel.org
 help / color / mirror / Atom feed
From: tip-bot for Sean Christopherson <tipbot@zytor.com>
To: linux-tip-commits@vger.kernel.org
Cc: dave.hansen@linux.intel.com, riel@surriel.com,
	torvalds@linux-foundation.org, sean.j.christopherson@intel.com,
	luto@kernel.org, linux-kernel@vger.kernel.org,
	peterz@infradead.org, hpa@zytor.com, yu-cheng.yu@intel.com,
	tglx@linutronix.de, bp@alien8.de, mingo@kernel.org
Subject: [tip:x86/mm] x86/fault: Reword initial BUG message for unhandled page faults
Date: Fri, 19 Apr 2019 11:35:05 -0700	[thread overview]
Message-ID: <tip-f28b11a2abd9cf5535baa03e28fc63ad0e14f52a@git.kernel.org> (raw)
In-Reply-To: <20181221213657.27628-2-sean.j.christopherson@intel.com>

Commit-ID:  f28b11a2abd9cf5535baa03e28fc63ad0e14f52a
Gitweb:     https://git.kernel.org/tip/f28b11a2abd9cf5535baa03e28fc63ad0e14f52a
Author:     Sean Christopherson <sean.j.christopherson@intel.com>
AuthorDate: Fri, 21 Dec 2018 13:36:56 -0800
Committer:  Ingo Molnar <mingo@kernel.org>
CommitDate: Fri, 19 Apr 2019 19:31:15 +0200

x86/fault: Reword initial BUG message for unhandled page faults

Reword the NULL pointer dereference case to simply state that a NULL
pointer was dereferenced, i.e. drop "unable to handle" as that implies
that there are instances where the kernel actual does handle NULL
pointer dereferences, which is not true barring funky exception fixup.

For the non-NULL case, replace "kernel paging request" with "page fault"
as the kernel can technically oops on faults that originated in user
code.  Dropping "kernel" also allows future patches to provide detailed
information on where the fault occurred, e.g. user vs. kernel, without
conflicting with the initial BUG message.

In both cases, replace "at address=" with wording more appropriate to
the oops, as "at" may be interpreted as stating that the address is the
RIP of the instruction that faulted.

Last, and probably least, further qualify the NULL-pointer path by
checking that the fault actually originated in kernel code.  It's
technically possible for userspace to map address 0, and not printing
a super specific message is the least of our worries if the kernel does
manage to oops on an actual NULL pointer dereference from userspace.

Before:
    BUG: unable to handle kernel NULL pointer dereference at ffffbeef00000000
    BUG: unable to handle kernel paging request at ffffbeef00000000

After:
    BUG: kernel NULL pointer dereference, address = 0000000000000008
    BUG: unable to handle page fault for address = ffffbeef00000000

Suggested-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Sean Christopherson <sean.j.christopherson@intel.com>
Cc: Andy Lutomirski <luto@kernel.org>
Cc: Borislav Petkov <bp@alien8.de>
Cc: Dave Hansen <dave.hansen@linux.intel.com>
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/20181221213657.27628-2-sean.j.christopherson@intel.com
Signed-off-by: Ingo Molnar <mingo@kernel.org>
---
 arch/x86/mm/fault.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/arch/x86/mm/fault.c b/arch/x86/mm/fault.c
index 667f1da36208..df2c5cdef5c4 100644
--- a/arch/x86/mm/fault.c
+++ b/arch/x86/mm/fault.c
@@ -644,9 +644,12 @@ show_fault_oops(struct pt_regs *regs, unsigned long error_code, unsigned long ad
 				from_kuid(&init_user_ns, current_uid()));
 	}
 
-	pr_alert("BUG: unable to handle kernel %s at %px\n",
-		 address < PAGE_SIZE ? "NULL pointer dereference" : "paging request",
-		 (void *)address);
+	if (address < PAGE_SIZE && !user_mode(regs))
+		pr_alert("BUG: kernel NULL pointer dereference, address = %px\n",
+			(void *)address);
+	else
+		pr_alert("BUG: unable to handle page fault for address = %px\n",
+			(void *)address);
 
 	err_txt[0] = 0;
 

  reply	other threads:[~2019-04-19 18:35 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-12-21 21:36 [PATCH v3 0/2] x86/fault: Further improve #PF oops messages Sean Christopherson
2018-12-21 21:36 ` [PATCH v3 1/2] x86/fault: Reword initial BUG message for unhandled page faults Sean Christopherson
2019-04-19 18:35   ` tip-bot for Sean Christopherson [this message]
2018-12-21 21:36 ` [PATCH v3 2/2] x86/fault: Decode and print #PF oops in human readable form Sean Christopherson
2019-04-19 18:35   ` [tip:x86/mm] " tip-bot for Sean Christopherson
2019-04-21 18:35     ` Borislav Petkov
2019-04-21 18:52       ` [tip:x86/mm] x86/fault: Make fault messages more succinct tip-bot for Borislav Petkov
2019-04-29 13:58   ` [PATCH v3 2/2] x86/fault: Decode and print #PF oops in human readable form Dmitry Vyukov
2019-04-29 14:14     ` Borislav Petkov
2019-02-28 15:44 ` [PATCH v3 0/2] x86/fault: Further improve #PF oops messages Sean Christopherson

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:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

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

  git send-email \
    --in-reply-to=tip-f28b11a2abd9cf5535baa03e28fc63ad0e14f52a@git.kernel.org \
    --to=tipbot@zytor.com \
    --cc=bp@alien8.de \
    --cc=dave.hansen@linux.intel.com \
    --cc=hpa@zytor.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-tip-commits@vger.kernel.org \
    --cc=luto@kernel.org \
    --cc=mingo@kernel.org \
    --cc=peterz@infradead.org \
    --cc=riel@surriel.com \
    --cc=sean.j.christopherson@intel.com \
    --cc=tglx@linutronix.de \
    --cc=torvalds@linux-foundation.org \
    --cc=yu-cheng.yu@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.