Received: by 10.223.176.46 with SMTP id f43csp104263wra; Thu, 25 Jan 2018 18:20:39 -0800 (PST) X-Google-Smtp-Source: AH8x2274zQ+znD0oxH4pGvDTPGpraTQgnXDLzMRq9Lo4157Yyyq/g/v+JuYRLvWzXhhGssrnSd11 X-Received: by 10.98.62.150 with SMTP id y22mr17765538pfj.92.1516933239124; Thu, 25 Jan 2018 18:20:39 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1516933239; cv=none; d=google.com; s=arc-20160816; b=Twi0vhMXZnSAL2sIROHGJGbJGE1egClXSudYyIjE6uh2+2q8THAkmTNzvAMYJrCTAq CNnlRF9ZvteXjb18CmGUdghkkMJSmgDfYfbM0kgslOHO44IeEJoSNF4Eua6eLfdpfZoO 9irbAKCQjPHgpIKnpwBtyb/02ww+Qh66hVJH7qAddbrEsla+OYgjnNmZXpR2tm4hE0lM 6l/RaH9bCVU3eLqZQ6xPK5n8Vu/e26Nzk1q45ElMPZQZDLj3uepi4riLkUXeK7qZpwSW 3PHZAcTJML0GNBygYk/sp1q1aAnFxRlEqYGuHG8LzywH5M4FleadV9bdQdEgaXXNPC37 ocjw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-disposition :content-transfer-encoding:subject:cc:to:from:date:message-id :mime-version:dkim-signature:arc-authentication-results; bh=ZqumEnDhIJITuIqMFv6t//MfAVdPXhcH2HzJo8zrBpM=; b=KsjYahnqrq0E8rfnZFJygssH5yC3mWdoROSV5akrpwzBhrPyOQy78G76CV39+DnLtD 9nMADtV/CxB9d3RZ9CFnRRTESUNKmeMNFhpzHwfD/QFrskdLUqqcnXJl8XunXb0o7gbH Z9t8WvFlYPCF0wt3kz19b6PQqAXjs5Kua3ciFBO7rmO49psjNzug9ly57InTPrsTPHn1 0XMv7SqXW2EjRKeIG7W0ZovusV/RtSWqFopzJNukaNmr6xjY2s3PpKUdg/tZGdEWdJKq RqKpdzVMFOXuv/hCKmyjdMxv1TS1FctycKybjI5qAtO7agjb23s/o0aliuaX5pVXCcs6 bX+Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2017-10-26 header.b=gAa19aGU; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v10-v6si2908155ply.177.2018.01.25.18.20.25; Thu, 25 Jan 2018 18:20:39 -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; dkim=pass header.i=@oracle.com header.s=corp-2017-10-26 header.b=gAa19aGU; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751698AbeAZCUF (ORCPT + 99 others); Thu, 25 Jan 2018 21:20:05 -0500 Received: from userp2120.oracle.com ([156.151.31.85]:51972 "EHLO userp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751444AbeAZCUD (ORCPT ); Thu, 25 Jan 2018 21:20:03 -0500 Received: from pps.filterd (userp2120.oracle.com [127.0.0.1]) by userp2120.oracle.com (8.16.0.22/8.16.0.22) with SMTP id w0Q2HQf3151277; Fri, 26 Jan 2018 02:19:15 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=mime-version : message-id : date : from : to : cc : subject : content-type : content-transfer-encoding; s=corp-2017-10-26; bh=ZqumEnDhIJITuIqMFv6t//MfAVdPXhcH2HzJo8zrBpM=; b=gAa19aGUChkz/3LqN/hi1s9IVFd5yL4FIBYUjwqjqjnnreN+kBQYHU1+5RmBhD73atkw UIvsC6AkseSXXp/3vXjyHwd+the/NZ32EwnDT8SE+m7ySLYGDzeNdC0VetRh8ZFyLbfh dl7wsyJG9VHqNGMS2UN2850b/0y0j+7Qmj5SKDCvx8Zbl/vn5t0xIHHjtad+x9S10Zqb EEeUdWaE+NZaOYCTavyWe1Yri6c+riwHbQH/1Y6dIQUpSqzQim7tvfgTsCMvUmyzzu3T Jad7z45n14VsZFL8kBB1Z5wnRiVqKM3d+H8GegLr3flI7R3U25u4STPGwFC54UiWJyha 1Q== Received: from aserv0021.oracle.com (aserv0021.oracle.com [141.146.126.233]) by userp2120.oracle.com with ESMTP id 2fqu8f021g-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 26 Jan 2018 02:19:14 +0000 Received: from aserv0122.oracle.com (aserv0122.oracle.com [141.146.126.236]) by aserv0021.oracle.com (8.14.4/8.14.4) with ESMTP id w0Q2BiV9021212 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Fri, 26 Jan 2018 02:11:45 GMT Received: from abhmp0015.oracle.com (abhmp0015.oracle.com [141.146.116.21]) by aserv0122.oracle.com (8.14.4/8.14.4) with ESMTP id w0Q2BgUS001654; Fri, 26 Jan 2018 02:11:42 GMT MIME-Version: 1.0 Message-ID: <7c0b0879-3448-43e4-8380-4708fc787113@default> Date: Thu, 25 Jan 2018 18:11:42 -0800 (PST) From: Liran Alon To: Cc: , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: Re: [RFC 09/10] x86/enter: Create macros to restrict/unrestrict Indirect Branch Speculation X-Mailer: Zimbra on Oracle Beehive Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=8785 signatures=668655 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=1 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=607 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1711220000 definitions=main-1801260026 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org ----- dave.hansen@intel.com wrote: > On 01/23/2018 03:13 AM, Liran Alon wrote: > > Therefore, breaking KASLR. In order to handle this, every exit from > > kernel-mode to user-mode should stuff RSB. In addition, this > stuffing > > of RSB may need to be done from a fixed address to avoid leaking > the > > address of the RSB stuffing itself. >=20 > With PTI alone in place, I don't see how userspace could do anything > with this information. Even if userspace started to speculate to a > kernel address, there is nothing at the kernel address to execute: no > TLB entry, no PTE to load, nothing. >=20 > You probably have a valid point about host->guest, though. I see it differently. It is true that attacker cannot speculate to a kernel-address, but it doesn= 't mean it cannot use the leaked kernel-address together with another unrel= ated vulnerability to build a reliable exploit. Security is built in layers. The purpose of KASLR is to break the reliablity of an exploit which relies = on vulnerability primitives such as: memory-corruption of a kernel-address,= hijack kernel control-flow to a kernel-address or even just read a kernel-= address. In modern exploitation, it is common to chain multiple different v= ulnerabilities in order to build a reliable exploit. Therefore, leaking a k= ernel-address could be exactly the missing primitive to complete a vulnerab= ility-chain of a reliable exploit. I don't see a big difference between leaking a kernel-address from user-mod= e vs. leaking a hypervisor-address from guest. They are both useful just as= a primitive which is part of an exploit chain. One could argue though, that currently KASLR is fundementally broken and th= erefore should not be considered a security boundary anymore. This argument= could be legit as there were some well-known techniques that could break K= ASLR before KPTI patch-set was introduced (e.g. Timing memory accesses to k= ernel-addresses and messure reliably by leveraging TSX). Another well-known= argument against KASLR is that it is a non-deterministic mitigation which = some argue is not good enough. However, I think that if we decide KASLR is = not a security boundary anymore, it should be made loud and clear. In general, I think there are some info-leak vulnerabilities in our current= mitigation plan which doesn't seem to be addressed. I will be glad if we c= ould address them clearly. These are all the open issues as I see them: 1) Because IBRS doesn't restrict low prediction-mode code from using BTB of= high prediction-mode code, It is possible to info-leak addresses from high= prediction-mode code to low prediciton-mode code. This is the KASLR breakage discussed above. Again, could be ignored if we d= iscard KASLR as a security boundary. 2) Both IBRS & retpoline don't prevent use of BHB of high prediction-mode c= ode from being used by low prediction-mode code. Therefore, low prediction-= mode code could deduce the conditional branches taken by high prediction-mo= de code. 3) Similar leak to (1) exists from the fact that RSB entries of high predic= tion-mode code could be leaked by low prediction-mode code which may reveal= kernel-addresses. Again, we could decide that this isn't a security bounda= ry. An alternative to solve this could be to just stuff RSB from a fixed ad= dress between prediction-mode transitions. -Liran P.S: It seems to me that all these issues could be resolved completely at hardwa= re in future CPUs if BTB/BHB/RSB entries were tagged with prediction-mode (= or similar metadata). It will be nice if Intel/AMD could share if that is t= he planned long-term solution instead of IBRS-all-the-time.