Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751769AbeAJHNk (ORCPT + 1 other); Wed, 10 Jan 2018 02:13:40 -0500 Received: from mail-wr0-f169.google.com ([209.85.128.169]:43584 "EHLO mail-wr0-f169.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751031AbeAJHNg (ORCPT ); Wed, 10 Jan 2018 02:13:36 -0500 X-Google-Smtp-Source: ACJfBotPEzN1CPeCODuHqraxAKVdJLkLrw6SR51FtPItZy1mSpWxVZ3EOrOitCEdGQekP/exiS7eJA== Date: Wed, 10 Jan 2018 08:13:32 +0100 From: Ingo Molnar To: Andy Lutomirski Cc: Willy Tarreau , Borislav Petkov , LKML , X86 ML , Brian Gerst , Dave Hansen , Linus Torvalds , Peter Zijlstra , Thomas Gleixner , Josh Poimboeuf , "H. Peter Anvin" , Kees Cook Subject: Re: [RFC PATCH v2 2/6] x86/arch_prctl: add ARCH_GET_NOPTI and ARCH_SET_NOPTI to enable/disable PTI Message-ID: <20180110071332.clesa7yfdnpgzmph@gmail.com> References: <1515502580-12261-1-git-send-email-w@1wt.eu> <1515502580-12261-3-git-send-email-w@1wt.eu> <20180109141713.ngqrf6weyiy2q3in@pd.tnic> <20180109143653.GA12976@1wt.eu> <20180109145157.5ltqbz4o5sqkcggb@pd.tnic> <20180109145422.GD12976@1wt.eu> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: NeoMutt/20170609 (1.8.3) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Return-Path: * Andy Lutomirski wrote: > On Tue, Jan 9, 2018 at 6:54 AM, Willy Tarreau wrote: > > On Tue, Jan 09, 2018 at 03:51:57PM +0100, Borislav Petkov wrote: > >> On Tue, Jan 09, 2018 at 03:36:53PM +0100, Willy Tarreau wrote: > >> > I see and am not particularly against this, but what use case do you > >> > have in mind precisely ? I doubt it's just saving a few tens of bytes, > >> > so probably you're more concerned about the potential risks this opens ? > >> > But given we only allow this for CAP_SYS_RAWIO and these ones already > >> > have access to /dev/mem and many other things, don't you think there > >> > are much easier ways to dump kernel memory in this case than trying to > >> > inject some meltdown code into the victim process ? Or maybe you have > >> > other cases in mind that I'm not seeing. > >> > >> I'd like this to be config-controllable so that distros can make the > >> decision whether/if they want to support the whole per-mm thing. > > > > OK. > > > >> Also, if CAP_SYS_RAWIO is going to protect, please make the > >> ARCH_GET_NOPTI variant check it too. > > > > Interestingly I removed the check consecutive to the discussions. But > > I think I'll simply remove the whole ARCH_GET_NOPTI as it has no real > > value beyond initial development. > > > > I've thought about this a bit more. Here are my thoughts: > > 1. I don't like it being per-mm. I think it should be a per-thread > control so that a program can have a thread with PTI that runs > less-trusted JavaScript and other network threads with PTI off. > Obviously we lose NX protection mm-wide if any threads have PTI off. > I think the way to implement this is: Btw., the "NX protection", the NX bit set in the PTI kernel pagetables for the user range really just matters for non-SMEP hardware, right? On SMEP a CPU in kernel privilege mode cannot execute user pages, i.e. the fact that it's user pages is already NX, guaranteed by the CPU. And note how there's a happy circumstance for users, regarding SMEP and PTI NX: - All Intel desktop/server CPUs currently sold and those built in the last ~3 years have SMEP enabled already, so are not affected. - AMD CPUs don't have PTI enabled, so they already don't have NX for their user pages - no change in behavior. I.e.: non-issue and not a real constraint on the flexibility of this ABI, AFAICS - it's "only" an implementational matter. Thanks, Ingo