From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758975AbdLRNsm (ORCPT ); Mon, 18 Dec 2017 08:48:42 -0500 Received: from merlin.infradead.org ([205.233.59.134]:40210 "EHLO merlin.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752785AbdLRNsh (ORCPT ); Mon, 18 Dec 2017 08:48:37 -0500 Date: Mon, 18 Dec 2017 14:48:03 +0100 From: Peter Zijlstra To: Thomas Gleixner Cc: LKML , x86@kernel.org, Linus Torvalds , Andy Lutomirsky , Dave Hansen , Borislav Petkov , Greg KH , keescook@google.com, hughd@google.com, Brian Gerst , Josh Poimboeuf , Denys Vlasenko , Rik van Riel , Boris Ostrovsky , Juergen Gross , David Laight , Eduardo Valentin , aliguori@amazon.com, Will Deacon , daniel.gruss@iaik.tugraz.at Subject: Re: [patch V163 51/51] x86/ldt: Make the LDT mapping RO Message-ID: <20171218134803.atjsqjygp33wa6lj@hirez.programming.kicks-ass.net> References: <20171218114215.239543034@linutronix.de> <20171218115257.843313036@linutronix.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20171218115257.843313036@linutronix.de> User-Agent: NeoMutt/20170609 (1.8.3) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Dec 18, 2017 at 12:43:06PM +0100, Thomas Gleixner wrote: > arch/x86/include/asm/desc.h | 2 ++ > arch/x86/kernel/ldt.c | 7 ++++++- > tools/testing/selftests/x86/ldt_gdt.c | 3 +-- > 3 files changed, 9 insertions(+), 3 deletions(-) > > --- a/arch/x86/include/asm/desc.h > +++ b/arch/x86/include/asm/desc.h > @@ -20,6 +20,8 @@ static inline void fill_ldt(struct desc_ > > desc->type = (info->read_exec_only ^ 1) << 1; > desc->type |= info->contents << 2; > + /* Set the ACCESS bit so it can be mapped RO */ > + desc->type |= 1; > > desc->s = 1; > desc->dpl = 0x3; --- a/arch/x86/kernel/tls.c +++ b/arch/x86/kernel/tls.c @@ -93,17 +93,10 @@ static void set_tls_desc(struct task_str cpu = get_cpu(); while (n-- > 0) { - if (LDT_empty(info) || LDT_zero(info)) { + if (LDT_empty(info) || LDT_zero(info)) memset(desc, 0, sizeof(*desc)); - } else { + else fill_ldt(desc, info); - - /* - * Always set the accessed bit so that the CPU - * doesn't try to write to the (read-only) GDT. - */ - desc->type |= 1; - } ++info; ++desc; }