Received: by 10.223.176.5 with SMTP id f5csp993317wra; Tue, 30 Jan 2018 23:16:35 -0800 (PST) X-Google-Smtp-Source: AH8x225SniaWNnMDQ1GfftMwDDyLGvzjbE0Hh0B9LWYobjtY4CUfpC03GkslgE1CdBa/lrtKbhFh X-Received: by 10.99.151.2 with SMTP id n2mr22927603pge.87.1517382995240; Tue, 30 Jan 2018 23:16:35 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1517382995; cv=none; d=google.com; s=arc-20160816; b=dQacvNH52BzOMe5+3zSf/NdRgKUQXdUtqW3kunBl8wHOhtEo/i9dsrNFGs2MOzJlpI RWvMo6d5Zux2UsrVJhGBusg/RYOP/9/5oV811fqc3/heUMTv2/JLeUB3WygAJ376txDe IYthqWvkFDdvt/iqfG/pDCNooZ7kFMxjCyebp2xf2DslYtoHWsyO1CbpmubZ+0E+IUqc xGsXtnZNs/UOUwue4j5ob89IbErN0x2knK6+0pD/psMFtyDnEcLBmY2XSbcsT1H1Hj2w 9ZCvl4K7Lhb8w22BzN3Ms9jN5RAOAGF8DRH6bFSIF9La/6pknXUP5bfRywh3kN+JjnAf jiYQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:arc-authentication-results; bh=qvGlCrkccmkpmV8kIu8z7vW35nlIF0cvTtK5DpWHgr4=; b=r/Ug7r69Zu+lCv4Qw3qEPchw3ox4/QFPFVRqB2J+JYb5kL8VzIsIiuvVc8FCDZlsAM jw0qNsVmSYdrqjYzFHXKOlS1BhZFHg2w5HNWJ/XPtqWwJ8A6SvYDimPnd6mm7DXDmUpO h5M+3ZRog6lFLRURlXc8i77udQ4oAxA+clu1I8It7kgTG5KR3uK4F7qtkTw8cVdlzqR6 aoREqDBkGa1rQOvSGjXiCHbu3tILrXCyeqtV6Bk699i3dEHs0Ngu/y0QytHTfWfEqQu5 jkyhOiT78QjnaJL7evQHg0XeVWsg2BzPlT80wQUeiAU89qsu9SnMbKYIrnflyXImMOiV Mbrw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id r83si1386897pfd.355.2018.01.30.23.16.19; Tue, 30 Jan 2018 23:16:35 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752329AbeAaHFV (ORCPT + 99 others); Wed, 31 Jan 2018 02:05:21 -0500 Received: from isilmar-4.linta.de ([136.243.71.142]:47508 "EHLO isilmar-4.linta.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751953AbeAaHFT (ORCPT ); Wed, 31 Jan 2018 02:05:19 -0500 Received: from light.dominikbrodowski.net (isilmar.linta [10.0.0.1]) by isilmar-4.linta.de (Postfix) with ESMTPS id B0E32200906; Wed, 31 Jan 2018 07:05:18 +0000 (UTC) Received: by light.dominikbrodowski.net (Postfix, from userid 1000) id C223920BE8; Wed, 31 Jan 2018 08:03:00 +0100 (CET) Date: Wed, 31 Jan 2018 08:03:00 +0100 From: Dominik Brodowski To: mingo@kernel.org, hpa@zytor.com, tim.c.chen@linux.intel.com, dwmw@amazon.co.uk, linux-kernel@vger.kernel.org, tglx@linutronix.de Cc: jpoimboe@redhat.com Subject: Re: [tip:x86/pti] x86/speculation: Use Indirect Branch Prediction Barrier in context switch Message-ID: <20180131070300.GA28206@light.dominikbrodowski.net> References: <1517263487-3708-1-git-send-email-dwmw@amazon.co.uk> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.9.3 (2018-01-21) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Jan 30, 2018 at 02:39:45PM -0800, tip-bot for Tim Chen wrote: > Commit-ID: 18bf3c3ea8ece8f03b6fc58508f2dfd23c7711c7 > Gitweb: https://git.kernel.org/tip/18bf3c3ea8ece8f03b6fc58508f2dfd23c7711c7 > Author: Tim Chen > AuthorDate: Mon, 29 Jan 2018 22:04:47 +0000 > Committer: Thomas Gleixner > CommitDate: Tue, 30 Jan 2018 23:09:21 +0100 > > x86/speculation: Use Indirect Branch Prediction Barrier in context switch > > Flush indirect branches when switching into a process that marked itself > non dumpable. This protects high value processes like gpg better, > without having too high performance overhead. For the record, I am still opposed to limit this to non-dumpable processes. Whether a process needs protection by IBPB on context switches is a different question to whether a process should be allowed to be dumped, though the former may be a superset of the latter. In my opinion, IBPB should be enabled on all context switches to userspace processes, until we have a clear mitigation strategy for userspace against Spectre-v2 designed and implemented. Thanks, Dominik -------------------------- From: Dominik Brodowski Date: Wed, 31 Jan 2018 07:43:12 +0100 Subject: [PATCH] x86/speculation: Do not limit Indirect Branch Prediction Barrier to non-dumpable processes Whether a process needs protection by IBPB on context switches is a different question to whether a process should be allowed to be dumped, though the former may be a superset of the latter. Enable IBPB on all context switches to a different userspace process, until we have a clear mitigation strategy for userspace against Spectre-v2 designed and implemented. Signed-off-by: Dominik Brodowski diff --git a/arch/x86/mm/tlb.c b/arch/x86/mm/tlb.c index 012d02624848..f54897b68b16 100644 --- a/arch/x86/mm/tlb.c +++ b/arch/x86/mm/tlb.c @@ -255,19 +255,13 @@ void switch_mm_irqs_off(struct mm_struct *prev, struct mm_struct *next, * predictor when switching between processes. This stops * one process from doing Spectre-v2 attacks on another. * - * As an optimization, flush indirect branches only when - * switching into processes that disable dumping. This - * protects high value processes like gpg, without having - * too high performance overhead. IBPB is *expensive*! - * * This will not flush branches when switching into kernel * threads. It will also not flush if we switch to idle * thread and back to the same process. It will flush if we - * switch to a different non-dumpable process. + * switch to a different user process. */ if (tsk && tsk->mm && - tsk->mm->context.ctx_id != last_ctx_id && - get_dumpable(tsk->mm) != SUID_DUMP_USER) + tsk->mm->context.ctx_id != last_ctx_id) indirect_branch_prediction_barrier(); if (IS_ENABLED(CONFIG_VMAP_STACK)) {