From: Willy Tarreau <w@1wt.eu>
To: linux-kernel@vger.kernel.org, stable@vger.kernel.org
Cc: Linus Torvalds <torvalds@linux-foundation.org>,
"H. Peter Anvin" <hpa@linux.intel.com>,
Ben Hutchings <ben@decadent.org.uk>, Willy Tarreau <w@1wt.eu>
Subject: [ 04/25] x86-64, modify_ldt: Ban 16-bit segments on 64-bit kernels
Date: Sat, 06 Dec 2014 18:41:52 +0100 [thread overview]
Message-ID: <20141206174148.596017245@1wt.eu> (raw)
In-Reply-To: <2a26e912d2438674771c36169c190830@local>
2.6.32-longterm review patch. If anyone has any objections, please let me know.
------------------
From: "H. Peter Anvin" <hpa@linux.intel.com>
commit b3b42ac2cbae1f3cecbb6229964a4d48af31d382 upstream.
The IRET instruction, when returning to a 16-bit segment, only
restores the bottom 16 bits of the user space stack pointer. We have
a software workaround for that ("espfix") for the 32-bit kernel, but
it relies on a nonzero stack segment base which is not available in
32-bit mode.
Since 16-bit support is somewhat crippled anyway on a 64-bit kernel
(no V86 mode), and most (if not quite all) 64-bit processors support
virtualization for the users who really need it, simply reject
attempts at creating a 16-bit segment when running on top of a 64-bit
kernel.
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
Link: http://lkml.kernel.org/n/tip-kicdm89kzw9lldryb1br9od0@git.kernel.org
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
(cherry picked from 3.2 commit a862b5c4076b1ba4dd6c87aebac478853dc6db47)
Signed-off-by: Willy Tarreau <w@1wt.eu>
---
arch/x86/kernel/ldt.c | 11 +++++++++++
1 file changed, 11 insertions(+)
diff --git a/arch/x86/kernel/ldt.c b/arch/x86/kernel/ldt.c
index ec6ef60..75e356c 100644
--- a/arch/x86/kernel/ldt.c
+++ b/arch/x86/kernel/ldt.c
@@ -229,6 +229,17 @@ static int write_ldt(void __user *ptr, unsigned long bytecount, int oldmode)
}
}
+ /*
+ * On x86-64 we do not support 16-bit segments due to
+ * IRET leaking the high bits of the kernel stack address.
+ */
+#ifdef CONFIG_X86_64
+ if (!ldt_info.seg_32bit) {
+ error = -EINVAL;
+ goto out_unlock;
+ }
+#endif
+
fill_ldt(&ldt, &ldt_info);
if (oldmode)
ldt.avl = 0;
--
1.7.12.2.21.g234cd45.dirty
next prev parent reply other threads:[~2014-12-06 17:41 UTC|newest]
Thread overview: 29+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <2a26e912d2438674771c36169c190830@local>
2014-12-06 17:41 ` [ 00/25] 2.6.32.65-longterm review Willy Tarreau
2014-12-08 0:58 ` Willy Tarreau
2014-12-06 17:41 ` [ 01/25] net: sendmsg: fix failed backport of "fix NULL pointer dereference" Willy Tarreau
2014-12-06 17:41 ` [ 02/25] x86, 64-bit: Move K8 B step iret fixup to fault entry asm Willy Tarreau
2014-12-06 17:41 ` [ 03/25] x86-64: Adjust frame type at paranoid_exit: Willy Tarreau
2014-12-06 17:41 ` Willy Tarreau [this message]
2014-12-06 17:41 ` [ 05/25] x86-32, espfix: Remove filter for espfix32 due to race Willy Tarreau
2014-12-06 17:41 ` [ 06/25] x86-64, espfix: Dont leak bits 31:16 of %esp returning to 16-bit stack Willy Tarreau
2014-12-06 17:41 ` [ 07/25] x86, espfix: Move espfix definitions into a separate header file Willy Tarreau
2014-12-06 17:41 ` [ 08/25] x86, espfix: Fix broken header guard Willy Tarreau
2014-12-06 17:41 ` [ 09/25] x86, espfix: Make espfix64 a Kconfig option, fix UML Willy Tarreau
2014-12-06 17:41 ` [ 10/25] x86, espfix: Make it possible to disable 16-bit support Willy Tarreau
2014-12-08 2:58 ` Ben Hutchings
2014-12-08 7:11 ` Willy Tarreau
2014-12-06 17:41 ` [ 11/25] x86_64/entry/xen: Do not invoke espfix64 on Xen Willy Tarreau
2014-12-06 17:42 ` [ 12/25] x86/espfix/xen: Fix allocation of pages for paravirt page tables Willy Tarreau
2014-12-06 17:42 ` [ 13/25] x86_64, traps: Stop using IST for #SS Willy Tarreau
2014-12-06 17:42 ` [ 14/25] x86_64, traps: Fix the espfix64 #DF fixup and rewrite it in C Willy Tarreau
2014-12-06 17:42 ` [ 15/25] x86_64, traps: Rework bad_iret Willy Tarreau
2014-12-06 17:42 ` [ 16/25] net/l2tp: dont fall back on UDP [get|set]sockopt Willy Tarreau
2014-12-06 17:42 ` [ 17/25] ALSA: control: Dont access controls outside of protected regions Willy Tarreau
2014-12-06 17:42 ` [ 18/25] ALSA: control: Fix replacing user controls Willy Tarreau
2014-12-06 17:42 ` [ 19/25] USB: whiteheat: Added bounds checking for bulk command response Willy Tarreau
2014-12-06 17:42 ` [ 20/25] net: sctp: fix panic on duplicate ASCONF chunks Willy Tarreau
2014-12-06 17:42 ` [ 21/25] net: sctp: fix remote memory pressure from excessive queueing Willy Tarreau
2014-12-06 17:42 ` [ 22/25] udf: Avoid infinite loop when processing indirect ICBs Willy Tarreau
2014-12-06 17:42 ` [ 23/25] net: sctp: fix NULL pointer dereference in af->from_addr_param on malformed packet Willy Tarreau
2014-12-06 17:42 ` [ 24/25] mac80211: fix fragmentation code, particularly for encryption Willy Tarreau
2014-12-06 17:42 ` [ 25/25] ttusb-dec: buffer overflow in ioctl Willy Tarreau
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=20141206174148.596017245@1wt.eu \
--to=w@1wt.eu \
--cc=ben@decadent.org.uk \
--cc=hpa@linux.intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=stable@vger.kernel.org \
--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;
as well as URLs for NNTP newsgroup(s).