Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755419AbeAHSWn (ORCPT + 1 other); Mon, 8 Jan 2018 13:22:43 -0500 Received: from wtarreau.pck.nerim.net ([62.212.114.60]:38982 "EHLO 1wt.eu" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755000AbeAHSWm (ORCPT ); Mon, 8 Jan 2018 13:22:42 -0500 Date: Mon, 8 Jan 2018 19:22:34 +0100 From: Willy Tarreau To: Linus Torvalds Cc: Linux Kernel Mailing List , the arch/x86 maintainers , Thomas Gleixner , One Thousand Gnomes Subject: Re: [PATCH RFC 2/4] x86/arch_prctl: add ARCH_GET_NOPTI and ARCH_SET_NOPTI to enable/disable PTI Message-ID: <20180108182234.GL10913@1wt.eu> References: <1515427939-10999-1-git-send-email-w@1wt.eu> <1515427939-10999-3-git-send-email-w@1wt.eu> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.6.1 (2016-04-27) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Return-Path: On Mon, Jan 08, 2018 at 09:54:05AM -0800, Linus Torvalds wrote: > On Mon, Jan 8, 2018 at 8:12 AM, Willy Tarreau wrote: > > This allows to report the current state of the PTI protection and to > > enable or disable it for the current task. > > So I really think that this needs to be done up-front to avoid a lot > of complexity. And per mm. > > If the process is already threaded (so the mm has multiple users), > it's too late to start playing games with PTI. > > In fact, maybe the whole thing needs to be controlled before "exec" > happens, so that we have the knowledge as we build up the mm, rather > than being "runtime" dynamic at all. In fact I initially wanted to start with a prctl() flag that acts upon exec because it looked simpler. But then I realized that this would always require a wrapper and that it's not necessarily more convenient. It even makes permission checks more complicated from an administration perspective, and I'd hate to see such a wrapper ending up setuid... > But in no case should you even try to handle the multi-threaded case - > just error out for trying to change the PTI setting. I totally agree here. Like Ingo says, there *may* be useful cases for this but I'm not sure we're prepared to address a new class of bugs caused by this yet. And now I can get rid of GET_NOPTI, it was just for debugging. > So make the thing per-mm, and then at task switch time as you switch > mms, you set the bit in a percpu variable for testing at kernel entry. I'll see how to do that, this is not yet 100% clear to me, I'm still discovering (this code has immensely changed since last time I *really* dug into it). So I suspect I'll have to set this variable in __switch_to() based on this other MM flag. I'll study this. Thanks, Willy