Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754436AbeAHRud (ORCPT + 1 other); Mon, 8 Jan 2018 12:50:33 -0500 Received: from mail-wr0-f177.google.com ([209.85.128.177]:41154 "EHLO mail-wr0-f177.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751806AbeAHRuc (ORCPT ); Mon, 8 Jan 2018 12:50:32 -0500 X-Google-Smtp-Source: ACJfBovC5DWhLr1tQ1i98aHpF35k0VXnabzvupa/FjXo0FydjVvdzlBWmvSBfXfTgxZltAzT+bqDzg== Date: Mon, 8 Jan 2018 18:50:28 +0100 From: Ingo Molnar To: Dave Hansen Cc: Thomas Gleixner , Willy Tarreau , linux-kernel@vger.kernel.org, x86@kernel.org, gnomes@lxorguk.ukuu.org.uk, torvalds@linux-foundation.org Subject: Re: [PATCH RFC 3/4] x86/pti: don't mark the user PGD with _PAGE_NX. Message-ID: <20180108175028.acwe3glhw4rsvdsx@gmail.com> References: <1515427939-10999-1-git-send-email-w@1wt.eu> <1515427939-10999-4-git-send-email-w@1wt.eu> <760b7264-1ae7-bcaa-6d20-f47cc7c7fce1@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <760b7264-1ae7-bcaa-6d20-f47cc7c7fce1@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: * Dave Hansen wrote: > On 01/08/2018 09:05 AM, Thomas Gleixner wrote: > > On Mon, 8 Jan 2018, 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 surely want to keep that as a safety measure. The entry code is simple to > > get wrong and running with the wrong pagetables by a silly mistake and > > thereby undoing the protection is surely not what we want. > > > > Need to find a free time slot to think about that. > > This does get immensely easier if we choose a mode at exec() (or fork() > even) and never change it. The prctl() _could_ just be a flag to tell > what your children should do. Switching PTI on/off for a whole process would be nightmarish. The simplest model is indeed child inheritance tree propagation - plus perhaps the ability for a thread to change its *own* PTI status, which obviously doesn't create any deep "process lookup" or cross-CPU complications. ( Note that here I only mean "simple to implement" - we might decide to not offer the ABI. ) Thanks, Ingo