Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754601AbeAHRyI (ORCPT + 1 other); Mon, 8 Jan 2018 12:54:08 -0500 Received: from mail-io0-f172.google.com ([209.85.223.172]:40521 "EHLO mail-io0-f172.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753041AbeAHRyG (ORCPT ); Mon, 8 Jan 2018 12:54:06 -0500 X-Google-Smtp-Source: ACJfBosXw/1gpi48NjBG2QUsxz6eudNnWePXjo3GR4YLXKFRP0DTmtpNGQSo9Jowg88tIvdoY5Th9QYEgASnjP8gioE= MIME-Version: 1.0 In-Reply-To: <1515427939-10999-3-git-send-email-w@1wt.eu> References: <1515427939-10999-1-git-send-email-w@1wt.eu> <1515427939-10999-3-git-send-email-w@1wt.eu> From: Linus Torvalds Date: Mon, 8 Jan 2018 09:54:05 -0800 X-Google-Sender-Auth: Cq5xIBfw0DmfvZK2d5VmDzMqCvo Message-ID: Subject: Re: [PATCH RFC 2/4] x86/arch_prctl: add ARCH_GET_NOPTI and ARCH_SET_NOPTI to enable/disable PTI To: Willy Tarreau Cc: Linux Kernel Mailing List , "the arch/x86 maintainers" , Thomas Gleixner , One Thousand Gnomes Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Return-Path: 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. But in no case should you even try to handle the multi-threaded case - just error out for trying to change the PTI setting. 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. Linus