UPSTREAM: x86/tls: Disallow unusual TLS segments

Users have no business installing custom code segments into the
GDT, and segments that are not present but are otherwise valid
are a historical source of interesting attacks.

For completeness, block attempts to set the L bit.  (Prior to
this patch, the L bit would have been silently dropped.)

This is an ABI break.  I've checked glibc, musl, and Wine, and
none of them look like they'll have any trouble.

Note to stable maintainers: this is a hardening patch that fixes
no known bugs.  Given the possibility of ABI issues, this
probably shouldn't be backported quickly.

Signed-off-by: Andy Lutomirski <luto@amacapital.net>
Acked-by: H. Peter Anvin <hpa@zytor.com>
Cc: stable@vger.kernel.org # optional
Cc: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: security@kernel.org <security@kernel.org>
Cc: Willy Tarreau <w@1wt.eu>
Signed-off-by: Ingo Molnar <mingo@kernel.org>

BUG=chromium:439158
TEST=lumpy build & boot, sigreturn PoC runs without failures

(cherry picked from commit 0e58af4e1d2166e9e33375a0f121e4867010d4f8)
Signed-off-by: Kees Cook <keescook@chromium.org>

Reviewed-on: https://chromium-review.googlesource.com/236053
Tested-by: Kees Cook <keescook@chromium.org>
Reviewed-by: Aaron Durbin <adurbin@chromium.org>

(cherry picked from ToT)
Signed-off-by: Kees Cook <keescook@chromium.org>
Change-Id: I95b8bfe86aa029fa6ee391711dc040d009e5b0ad
Reviewed-on: https://chromium-review.googlesource.com/236906
Reviewed-by: Aaron Durbin <adurbin@chromium.org>
1 file changed