diff options
author | H. Peter Anvin <hpa@linux.intel.com> | 2014-03-16 15:31:54 -0700 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2014-05-06 07:55:29 -0700 |
commit | 4bb7ebb5ec23703c542a38702e4c1a35e6863a39 (patch) | |
tree | 0bb87080c06c7599d891c291653a8eb990ac5ca3 /arch | |
parent | a42fa0bbf7260c1301a40f59e9bb9394a1d495d9 (diff) | |
download | linux-3.10-4bb7ebb5ec23703c542a38702e4c1a35e6863a39.tar.gz linux-3.10-4bb7ebb5ec23703c542a38702e4c1a35e6863a39.tar.bz2 linux-3.10-4bb7ebb5ec23703c542a38702e4c1a35e6863a39.zip |
x86-64, modify_ldt: Ban 16-bit segments on 64-bit kernels
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: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'arch')
-rw-r--r-- | arch/x86/kernel/ldt.c | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/arch/x86/kernel/ldt.c b/arch/x86/kernel/ldt.c index ebc98739892..af1d14a9ebd 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; |