Received: by 10.213.65.68 with SMTP id h4csp206799imn; Wed, 21 Mar 2018 16:31:28 -0700 (PDT) X-Google-Smtp-Source: AG47ELsRF4ajkxdEGg+GzEG40tg13ST65/hW1j9DmRotxUE9HriyCNVtbpwYg6trbgy7dn1eWUX6 X-Received: by 2002:a17:902:b7cc:: with SMTP id v12-v6mr7009179plz.237.1521675088069; Wed, 21 Mar 2018 16:31:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521675088; cv=none; d=google.com; s=arc-20160816; b=K28qiQJtBjfv9jnj34dcQ2QQVg2nH1svtUs0Bko1VjZM644LuMQKxTcL3xX/WQ3son CnHkSLyjx0x+Yj8xwV74YUcqGj/HGAdqERNLwUEnt9uThW6S8ocT44LRTUB88GoQqCc6 K3msymqNpslo1tEBSmQyA1Ky3WPvi3fLRNpWgCDGex9mdJcPqA9tBExxNqv8z/BSTYha C6C+pwVPQCWqQjv2HQnpKk9V9QpRIKq2ASRhM5ius/HGM5Rj4MjPcRsKNcdP8mARI11d WEER9ALqA1SePNA/fwO2W12X8uwN5iY1eDDQIblGBvNYnGiKhu520P5DHA5nxvhePody G9ow== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:cc:references:to:subject:arc-authentication-results; bh=x5fsOKZZ4euvt4Tku7veaWIPzvLLmmifc3R9OZ3je64=; b=A/wMOzH0Q9o4cBTfBmHAa2GyT+LRDLygKeoIo7yj5V0W3EEJT2TLjf45wEHuSbkbu8 qY0agt/EHhvC7a2pj3JBXIDB/SA6O2LUMF/1TOaszvPrqdZu7epWIn/n8uuvklnFHoI1 cnSPFKb/80xgngRu0ZLFwEMaLdFPhKjTbdKzbhLhtl+3lDMjupWr9UWXFajnS172JQQA yq//b70PUV1oA3Ybq5BcfZcb5YWNTZHqrRZvLIFfuw8uvFBF2dm71UVXifu/L/maFzr8 BawHOoVnglkQ/sI6g/T18uXeXRgELtU1IRI6R0XEMlenYOfRLqAO7mv/W6BbXXmaCii4 FT0A== 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 e6si3424345pgt.198.2018.03.21.16.31.13; Wed, 21 Mar 2018 16:31:28 -0700 (PDT) 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 S1754129AbeCUXaV (ORCPT + 99 others); Wed, 21 Mar 2018 19:30:21 -0400 Received: from mga17.intel.com ([192.55.52.151]:32097 "EHLO mga17.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753980AbeCUXaU (ORCPT ); Wed, 21 Mar 2018 19:30:20 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga006.jf.intel.com ([10.7.209.51]) by fmsmga107.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 21 Mar 2018 16:30:20 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.48,341,1517904000"; d="scan'208";a="27773929" Received: from ray.jf.intel.com (HELO [10.7.201.20]) ([10.7.201.20]) by orsmga006.jf.intel.com with ESMTP; 21 Mar 2018 16:30:19 -0700 Subject: Re: [PATCH] x86/speculation: Fill the RSB on context switch also on non-IBPB CPUs To: "Maciej S. Szmigiero" , Thomas Gleixner , Ingo Molnar References: <9eb945bd-f77e-0301-d977-d1acf931b19d@maciej.szmigiero.name> Cc: "H. Peter Anvin" , David Woodhouse , KarimAllah Ahmed , Andi Kleen , Tim Chen , thomas.lendacky@amd.com, x86@kernel.org, linux-kernel@vger.kernel.org From: Dave Hansen Message-ID: <757282b8-8b59-bcc6-1f6b-3383ae8a8575@intel.com> Date: Wed, 21 Mar 2018 16:30:17 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.6.0 MIME-Version: 1.0 In-Reply-To: <9eb945bd-f77e-0301-d977-d1acf931b19d@maciej.szmigiero.name> Content-Type: text/plain; charset=iso-8859-2 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 03/20/2018 04:17 AM, Maciej S. Szmigiero wrote: > Since it is unlikely that existing RSB entries from the previous task match > the new task call stack we can use the existing unconditional > RSB-filling-on-context-switch infrastructure to protect against such > userspace-to-userspace attacks. > > This patch brings a change in behavior only for the following CPU types: > * Intel pre-Skylake CPUs without updated microcode, > * AMD Family 15h model >60h, Family 17h CPUs without updated microcode. > > Other CPU types either already do the RSB filling on context switch for > other reasons or do support IBPB for more complete userspace-to-userspace > protection. I think I misunderstood your reasoning a bit. Let me see if I can restate the problem a bit. IBPB provides provides userspace-to-userspace protection because it prevents all indirect branch predictions after the barrier from being controlled by software executed before the barrier. We only use IBPB for KVM and when processes clear their dumpable flag. You're saying that, even if we don't have IBPB, we can do *some* userspace-to-userspace protection with RSB manipulation. The RSB manipulation obviously only helps 'RET' instructions and not JMP/CALL, but it does do *something* useful. Is that right? Do you really want this behavior on all context switches? We don't do IBPB on all context switches, only the ones where we are switching *to* a non-dumpable process. Do you perhaps want to do RSB manipulation in lieu of IBPB when switching *to* a non-dumpable process and IBPB is not available?