Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757289AbeAHRR3 (ORCPT + 1 other); Mon, 8 Jan 2018 12:17:29 -0500 Received: from wtarreau.pck.nerim.net ([62.212.114.60]:38954 "EHLO 1wt.eu" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752805AbeAHRR1 (ORCPT ); Mon, 8 Jan 2018 12:17:27 -0500 Date: Mon, 8 Jan 2018 18:17:07 +0100 From: Willy Tarreau To: Dave Hansen Cc: linux-kernel@vger.kernel.org, x86@kernel.org, tglx@linutronix.de, gnomes@lxorguk.ukuu.org.uk, torvalds@linux-foundation.org, Ingo Molnar , Peter Zijlstra , Borislav Petkov , Josh Poimboeuf , Andy Lutomirski Subject: Re: [PATCH RFC 3/4] x86/pti: don't mark the user PGD with _PAGE_NX. Message-ID: <20180108171707.GG10913@1wt.eu> References: <1515427939-10999-1-git-send-email-w@1wt.eu> <1515427939-10999-4-git-send-email-w@1wt.eu> <57039ac1-efe2-2f97-386f-dab0b90f64a5@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <57039ac1-efe2-2f97-386f-dab0b90f64a5@intel.com> 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: [ expanded the Cc list a bit ] On Mon, Jan 08, 2018 at 09:03:36AM -0800, Dave Hansen wrote: > On 01/08/2018 08:12 AM, Willy Tarreau wrote: > > Since we're going to keep running on the same PGD when returning to > > userspace for certain performance-critical tasks, we'll need the user > > pages to be executable. So this code disables the extra protection > > that was added consisting in marking user pages _PAGE_NX so that this > > pgd remains usable for userspace. > > > > Note: it isn't necessarily the best approach, but one way or another > > if we want to be able to return to userspace from the kernel, > > we'll have to have this executable anyway. Another approach > > might consist in using another pgd for userland+kernel but > > the current core really looks like an extra careful measure > > to catch early bugs if any. > > I don't like this. This is the purpose of the review. > I think the prctl() should apply to an entire process, not to a thread. As I mentionned in another mail, I didn't know how to do it, even less how to do it fast enough so that we didn't add more cycles to the syscall code. > If it applies to a process, you can unpoison the PGD. I even had code > to do this in an earlier version of the (whole system) runtime PTI > on/off stuff. > > Why are you even posting half-baked hacks like this now? Is there > something super-pressing about this set that we need to lock in a new > ABI now? No need to lock in or whatever. It's just that a number of us simply cannot use the current protection due to the huge cost it comes with for their specific workload, and having to choose between performance or protection remains a problem. Having a bit more available time and being directly concerned by this problem I tried to propose something to 1) see if there was any hope and 2) possibly help things move forward in this direction. The patches are marked RFC, they're for discussing, not for merging. Willy