Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754070AbeAHRqm (ORCPT + 1 other); Mon, 8 Jan 2018 12:46:42 -0500 Received: from mail-wr0-f193.google.com ([209.85.128.193]:41395 "EHLO mail-wr0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751026AbeAHRqk (ORCPT ); Mon, 8 Jan 2018 12:46:40 -0500 X-Google-Smtp-Source: ACJfBoulmhONnQwyRyLFwpJW4p3F6L1lxN0zlFxeE31y7jR4okyIGoZqXEK+5YFJru/exmkl3WDS9A== Date: Mon, 8 Jan 2018 18:46:36 +0100 From: Ingo Molnar To: Thomas Gleixner Cc: Willy Tarreau , linux-kernel@vger.kernel.org, x86@kernel.org, gnomes@lxorguk.ukuu.org.uk, torvalds@linux-foundation.org, Dave Hansen , Andy Lutomirski , Borislav Petkov , Peter Zijlstra , Josh Poimboeuf Subject: Re: [PATCH RFC 2/4] x86/arch_prctl: add ARCH_GET_NOPTI and ARCH_SET_NOPTI to enable/disable PTI Message-ID: <20180108174636.76ioxk6yem73yh7i@gmail.com> References: <1515427939-10999-1-git-send-email-w@1wt.eu> <1515427939-10999-3-git-send-email-w@1wt.eu> <20180108171759.qissiwwxyg6m7rrl@gmail.com> 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: * Thomas Gleixner wrote: > On Mon, 8 Jan 2018, Ingo Molnar wrote: > > * Thomas Gleixner wrote: > > > Per task is really an odd choice. That should be per process I think, but > > > that of course needs synchronization of some form. Aside of that we need to > > > think about fork(). > > > > So per task (thread) is the most natural approach to low level asm flaggery. > > Well, yes and no. PTI is a property of the mm/pgdir and that's process > wide. Yes and no: the contents of CR3 is a property of the _thread_ (CPU), so we do have the implementational degree of freedom of executing user-space with either the user+kernel PGD or the user-only PGD. The question I'm asking is whether it makes sense to offer this - the _possibility_ is clearly there unless I'm missing something. > > Making it per thread also makes some sense conceptually: in a complex > > multi-threaded runtime implementation some threads might never execute > > 'untrusted' code, some might. No need to penalize the 'server' threads. > > If one thread runs untrusted code then your 'trusted' thread is not longer > trusted either as they share everything. I think you are missing the wider context here: a number of runtime environments (browsers, JIT compilers, etc.) are able to run "untrusted code" while still applying heavy sandboxing constraints. In some of those runtime models it's very much possible to have untrusted code in the same address space as trusted code. BPF is an example for such a runtime model: we can run user-defined BPF JIT-ed code in kernel context. Thanks, Ingo