From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752256AbdLLTVb (ORCPT ); Tue, 12 Dec 2017 14:21:31 -0500 Received: from Galois.linutronix.de ([146.0.238.70]:34314 "EHLO Galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751554AbdLLTV2 (ORCPT ); Tue, 12 Dec 2017 14:21:28 -0500 Date: Tue, 12 Dec 2017 20:21:22 +0100 (CET) From: Thomas Gleixner To: Linus Torvalds cc: LKML , the arch/x86 maintainers , Andy Lutomirsky , Peter Zijlstra , Dave Hansen , Borislav Petkov , Greg KH , Kees Cook , Hugh Dickins , Brian Gerst , Josh Poimboeuf , Denys Vlasenko , Boris Ostrovsky , Juergen Gross , David Laight , Eduardo Valentin , "Liguori, Anthony" , Will Deacon , linux-mm Subject: Re: [patch 13/16] x86/ldt: Introduce LDT write fault handler In-Reply-To: Message-ID: References: <20171212173221.496222173@linutronix.de> <20171212173334.345422294@linutronix.de> User-Agent: Alpine 2.20 (DEB 67 2015-01-07) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII X-Linutronix-Spam-Score: -1.0 X-Linutronix-Spam-Level: - X-Linutronix-Spam-Status: No , -1.0 points, 5.0 required, ALL_TRUSTED=-1,SHORTCIRCUIT=-0.0001 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, 12 Dec 2017, Linus Torvalds wrote: > On Tue, Dec 12, 2017 at 9:32 AM, Thomas Gleixner wrote: > > From: Thomas Gleixner > > > > When the LDT is mapped RO, the CPU will write fault the first time it uses > > a segment descriptor in order to set the ACCESS bit (for some reason it > > doesn't always observe that it already preset). Catch the fault and set the > > ACCESS bit in the handler. > > This really scares me. > > We use segments in some critical code in the kernel, like the whole > percpu data etc. Stuff that definitely shouldn't fault. > > Yes, those segments should damn well be already marked accessed when > the segment is loaded, but apparently that isn't reliable. That has nothing to do with the user installed LDT. The kernel does not use and rely on LDT at all. The only critical interaction is the return to user path (user CS/SS) and we made sure with the LAR touching that these are precached in the CPU before we go into fragile exit code. Luto has some concerns vs. load_gs[_index] and we'll certainly look into that some more. Thanks, tglx