From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755187AbbG1F3p (ORCPT ); Tue, 28 Jul 2015 01:29:45 -0400 Received: from mail.kernel.org ([198.145.29.136]:38642 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750783AbbG1F3o (ORCPT ); Tue, 28 Jul 2015 01:29:44 -0400 From: Andy Lutomirski To: Peter Zijlstra , Steven Rostedt Cc: "security@kernel.org" , X86 ML , Borislav Petkov , Sasha Levin , linux-kernel@vger.kernel.org, Konrad Rzeszutek Wilk , Boris Ostrovsky , Andrew Cooper , Jan Beulich , xen-devel , Andy Lutomirski Subject: [PATCH v5 0/4] x86: modify_ldt improvement, test, and config option Date: Mon, 27 Jul 2015 22:29:37 -0700 Message-Id: X-Mailer: git-send-email 2.4.3 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This is intended for x86/urgent. Sorry for taking so long, but it seemed nice to avoid breaking Xen. This fixes the "dazed and confused" issue which was exposed by the CVE-2015-5157 fix. It's also probably a good general attack surface reduction, and it replaces some scary code with IMO less scary code. Also, servers and embedded systems should probably turn off modify_ldt. This makes that possible. Boris, could I get a Tested-by, assuming this works for you? Willy and Kees: I left the config option alone. The -tiny people will like it, and we can always add a sysctl of some sort later. Changes from v4: - Fix Xen even better (patch 1 is new). - Reorder the patches to make a little more sense. Changes from v3: - Hopefully fixed Xen. - Fixed 32-bit test case on 32-bit native kernel. - Fix bogus vumnap for some LDT sizes. - Strengthen test case to check all LDT sizes (catches bogus vunmap). - Lots of cleanups, mostly from Borislav. - Simplify IPI code using on_each_cpu_mask. Changes from v2: - Allocate ldt_struct and the LDT entries separately. This should fix Xen. - Stop using write_ldt_entry, since I'm pretty sure it's unnecessary now that we no longer mutate an in-use LDT. (Xen people, can you check?) Changes from v1: - The config option is new. - The test case is new. - Fixed a missing allocation failure check. - Fixed a use-after-free on fork(). Andy Lutomirski (4): x86/xen: Unmap aliases in xen_alloc_ldt and xen_free_ldt x86/ldt: Make modify_ldt synchronous selftests/x86, x86/ldt: Add a selftest for modify_ldt x86/ldt: Make modify_ldt optional arch/x86/Kconfig | 17 ++ arch/x86/include/asm/desc.h | 15 - arch/x86/include/asm/mmu.h | 5 +- arch/x86/include/asm/mmu_context.h | 68 ++++- arch/x86/kernel/Makefile | 3 +- arch/x86/kernel/cpu/common.c | 4 +- arch/x86/kernel/cpu/perf_event.c | 16 +- arch/x86/kernel/ldt.c | 262 +++++++++-------- arch/x86/kernel/process_64.c | 6 +- arch/x86/kernel/step.c | 8 +- arch/x86/power/cpu.c | 3 +- arch/x86/xen/enlighten.c | 12 + kernel/sys_ni.c | 1 + tools/testing/selftests/x86/Makefile | 2 +- tools/testing/selftests/x86/ldt_gdt.c | 520 ++++++++++++++++++++++++++++++++++ 15 files changed, 787 insertions(+), 155 deletions(-) create mode 100644 tools/testing/selftests/x86/ldt_gdt.c -- 2.4.3