Commit b3b42ac2 authored by H. Peter Anvin's avatar H. Peter Anvin
Browse files

x86-64, modify_ldt: Ban 16-bit segments on 64-bit kernels

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

Cc: Linus Torvalds <>
Signed-off-by: default avatarH. Peter Anvin <>
Cc: <>
parent 3151b942
......@@ -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;
fill_ldt(&ldt, &ldt_info);
if (oldmode)
ldt.avl = 0;
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment