From: "H. Peter Anvin" <hpa@zytor.com>
To: Linus Torvalds <torvalds@linux-foundation.org>,
Randy Dunlap <rdunlap@xenotime.net>,
Ingo Molnar <mingo@kernel.org>,
Thomas Gleixner <tglx@linutronix.de>,
Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
Arjan van de Ven <arjan@linux.intel.com>
Subject: On the correctness of dbe3ed1c078c193be34326728d494c5c4bc115e2
Date: Sun, 01 Sep 2013 05:20:45 -0700 [thread overview]
Message-ID: <5223311D.2040608@zytor.com> (raw)
A truly ancient commit (v2.6.23), dbe3ed1c078c193be34326728d494c5c4bc115e2:
x86-64: page faults from user mode are always user faults
Randy Dunlap noticed an interesting "crashme" behaviour on his dual
Prescott Xeon setup, where he gets page faults with the error code
having a zero "user" bit, but the register state points back to user
mode.
This may be a CPU microcode buglet triggered by some strange
instruction pattern that crashme generates, and loading a microcode
update seems to possibly have fixed it.
Regardless, we really should trust the register state more than the
error code, since it's really the register state that determines
whether we can actually send a signal, or whether we're in kernel
mode and need to oops/kill the process in the case of a page fault.
... introduced the following code (since slightly modified):
+ /*
+ * User-mode registers count as a user access even for any
+ * potential system fault or CPU buglet.
+ */
+ if (user_mode_vm(regs))
+ error_code |= PF_USER;
+
This has the end result that we treat a user space instruction which
touches a privileged data structure that then page faults (e.g. a
segment load which causes #PF on the GDT) as a user-space fault.
This seems very wrong to me, since such a #PF would indicate a serious
error in the kernel.
If this was a buglet introduced by a specific processor ("Prescott Xeon"
I presume means Nocona) and then even fixed in a patch, I'm concerned
that we are putting the cart before the horse with this change.
I went through the errata sheets for the CPUs of the time, but nothing
jumped out at me as causing this kind of problem, although there is a
mention of a couple of undefined opcodes which ought to #UD being able
to generate a "load to an incorrect address". Kind of a stretch, though.
-hpa
next reply other threads:[~2013-09-01 12:21 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-09-01 12:20 H. Peter Anvin [this message]
2013-09-01 15:58 ` On the correctness of dbe3ed1c078c193be34326728d494c5c4bc115e2 Linus Torvalds
2013-09-01 16:00 ` H. Peter Anvin
2013-09-01 16:12 ` Linus Torvalds
2013-09-01 16:13 ` H. Peter Anvin
2013-09-01 16:10 ` H. Peter Anvin
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=5223311D.2040608@zytor.com \
--to=hpa@zytor.com \
--cc=arjan@linux.intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@kernel.org \
--cc=rdunlap@xenotime.net \
--cc=tglx@linutronix.de \
--cc=torvalds@linux-foundation.org \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox