Received: by 10.223.185.116 with SMTP id b49csp842807wrg; Fri, 16 Feb 2018 08:04:05 -0800 (PST) X-Google-Smtp-Source: AH8x225ILhF2+/773+UP/BCiecXqirb2lhadr97FKl1jk3bZiQR8o8QsX7fHR32syCmv7sZbwqfZ X-Received: by 10.98.63.147 with SMTP id z19mr2570392pfj.221.1518796964146; Fri, 16 Feb 2018 08:02:44 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518796962; cv=none; d=google.com; s=arc-20160816; b=HHcy8emvzAg1mEpx5BWu7RwkDw1IwahZWsKNwZQVAimoj5kD4optWBq0T/XeEIah8B Q7PXkHFdz5h7TJcO3xYOIjOLAYv+Aa9/WH2KaE75gNTerzNPwjdJoXByMFYclAxrTtOv n7yqiCC4S4XSHR1aLyU+LMt4H95Ut6O30eBOwqU04U/W0trzoyxIyVA+XvCmChM2YSsM CrE05fzmCXvWBP6/7tbFDI29UX/Ax7tZIEExAgFCdp7gtXf5Yye0hPVeGeouE5v7cKJt UiNsLHwIkflVClpZXeNb5PXK0TnNF6WmS+CtGHaM0mPTF+IcavGUI+6QsjyS4JIMVrh9 po3w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:to:cc:in-reply-to:date:subject :mime-version:message-id:from:dkim-signature :arc-authentication-results; bh=Ybt2D04h7OiKyAULdpyYz2vMn1LGa/zyKEiDW5Wgxys=; b=vQzIj/OCcPRNgYtHe1BwiXOyjxeTAMaqDttpbA6Ub5SfFlpPd9sP/4KjAC5MOG8LPK gbSaFmTYsqzQ6Rz2LWn51aUAUwa1V2Wn1KNSZhP016sPc68NxC0kvS926xwTOMUPX8sz 3BI+y+ygVV+6Zz4mFQ6fUkrZrXjTS2hQCx2Z8SVApWHFFKcHsis1SCXEkUu3CQZzuQdH YmiTd7r5yU/brlUwYc+o5Ajb+DFqJThzb+Jkgr7tBdsrVy679HjlWz9KXqzAoctzLCc9 EHK9wNLQ0p3Or/AeIwdok6QaYPK7tygq6FVAkv7Qx4qYkozEXEvH0LtXE2oCqK8Mxksu nivg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=Hi/mviwe; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id y7-v6si4429678plh.806.2018.02.16.08.01.39; Fri, 16 Feb 2018 08:02:42 -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=@gmail.com header.s=20161025 header.b=Hi/mviwe; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1422986AbeBPAWY (ORCPT + 99 others); Thu, 15 Feb 2018 19:22:24 -0500 Received: from mail-pg0-f42.google.com ([74.125.83.42]:45442 "EHLO mail-pg0-f42.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1422716AbeBPAWX (ORCPT ); Thu, 15 Feb 2018 19:22:23 -0500 Received: by mail-pg0-f42.google.com with SMTP id e11so1110464pgq.12 for ; Thu, 15 Feb 2018 16:22:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:message-id:mime-version:subject:date:in-reply-to:cc:to :references; bh=Ybt2D04h7OiKyAULdpyYz2vMn1LGa/zyKEiDW5Wgxys=; b=Hi/mviwe1jfjRM1ZBikZdib9d1sqhm2pxGI476B2tBpxp1ZY5f97o3ZTr4l7/IJUaz 8ny0iojns/K8XCgp3XB9Yjg4CWD+EyRaB0E1KcgTQQc6LU8cbPgcP2Y3uD7VgQkKUHfQ E2wUuGdlvi/Jr5lIIuFWrMFypAFOnXp1o8GpQQheNx08jiJVAvTdA7v/wZLSL2nGZdgW SRVo9h5Ry2lU82oZU6vcnRIeV4NGhx8+l3o1X7ZerP7iIaGtGiBEM535K6NwSal+1vTa l1YHOzYE8P56ukMgh07+Xhwnhwld1nzguoj3mA0us4r9qe2WzOymEOKf0WdDYdrr3oDw 9Zog== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:message-id:mime-version:subject:date :in-reply-to:cc:to:references; bh=Ybt2D04h7OiKyAULdpyYz2vMn1LGa/zyKEiDW5Wgxys=; b=uSqQFNck/9T/mxliqMFRETuR02o4nuMFmWvSX1EjyjAc2zQhXlHGFpLz/paUyNDJhX 8uWEkwr8Z/7HHfUlwSad2uR8njNC1cnE1+Y+a35T1nS2n+HAFA2Ojil8UpKXA6ZCgEEs yOZeKv+B+m1t1G9SB7QJz1KRKUwpDdDiTp2vWPt2QSBXWWKcpxPwRrh3vPpcd1fWeaeb ouDPzF1aSPLVNp5me9kg95lNHuRbRsnoxsvKzqs24mOx54vgNFFsC3DjbdBcyubniNoj 5BDXj+I07U1HPohKHJpgYT5NIPZbXTg4diUMu1UPD4hyRX8rv2c1QfdWeY/M/UzfaByn 5eOg== X-Gm-Message-State: APf1xPD7MLrgbuirysl9aZ9+YmY9LT5vsTdI3fS2uwzdIR3No8sN+iXU K+Fp+4c512l6ZK1a5SnzEFw= X-Received: by 10.99.113.11 with SMTP id m11mr3580144pgc.57.1518740542617; Thu, 15 Feb 2018 16:22:22 -0800 (PST) Received: from [10.2.101.129] ([208.91.2.2]) by smtp.gmail.com with ESMTPSA id v88sm7249990pfd.68.2018.02.15.16.22.19 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 15 Feb 2018 16:22:21 -0800 (PST) From: Nadav Amit Message-Id: Content-Type: multipart/signed; boundary="Apple-Mail=_530BEB66-AC1A-415E-86FC-5727FF7DFE2D"; protocol="application/pgp-signature"; micalg=pgp-sha512 Mime-Version: 1.0 (Mac OS X Mail 10.3 \(3273\)) Subject: Re: [PATCH RFC v2 4/6] x86: Disable PTI on compatibility mode Date: Thu, 15 Feb 2018 16:22:17 -0800 In-Reply-To: Cc: Andy Lutomirski , Pavel Emelyanov , Cyrill Gorcunov , Ingo Molnar , Thomas Gleixner , Peter Zijlstra , Dave Hansen , Willy Tarreau , X86 ML , LKML To: Linus Torvalds References: <20180215163602.61162-1-namit@vmware.com> <20180215163602.61162-5-namit@vmware.com> <9EB804CA-0EC9-4CBB-965A-F3C8520201E7@gmail.com> X-Mailer: Apple Mail (2.3273) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org --Apple-Mail=_530BEB66-AC1A-415E-86FC-5727FF7DFE2D Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=utf-8 Linus Torvalds wrote: > On Thu, Feb 15, 2018 at 3:29 PM, Andy Lutomirski = wrote: >> It's possible we could get away with adding the prctl but making the >> default be that only the bitness that matches the program being run = is >> allowed. After all, it's possible that CRIU is literally the only >> program that switches bitness using the GDT. (DOSEMU2 definitely = does >> cross-bitness stuff, but it uses the LDT as far as I know.) And I've >> never been entirely sure that CRIU fully counts toward the Linux >> "don't break ABI" guarantee. >=20 > Ugh. >=20 > There are just _so_ many reasons to dislike that. >=20 > It's not that I don't think we could try to encourage it, but this > whole "security depends on it being in sync" seems really like a > fundamentally bad design. >=20 >> Linus, how would you feel about, by default, preventing 64-bit >> programs from long-jumping to __USER32_CS and vice versa? >=20 > How? It's a standard GDT entry. Are you going to start switching the > GDT around every context switch? >=20 > I *thought* that user space can just do a far jump on its own. But > it's so long since I had to care that I may have forgotten all the > requirements for going between "compatibility mode" and real long > mode. >=20 > I just feel this all is a nightmare. I can see how you would want to > think that compatibility mode doesn't need PTI, but at the same time > it feels like a really risky move to do this. >=20 > I can see one thread being in compatibiilty mode, and another being in > long mode, and sharing the address space. But even with just one > thread, I'm not seeing how you keep user mode from going from > compatibility mode to L mode with just a far jump. >=20 > But maybe you have some clever scheme in mind that guarantees that > there are no issues, or maybe I've just forgotten all the details of > long mode vs compat mode. It is not too pretty, I agree, but it should do the work. There is only = one problematic descriptor that can be used to switch from = compatibility-mode to long-mode in the GDT (LDT descriptors always have the L-bit cleared). Changing the descriptor's present bit on context switch when needed can = do the work. I tried to do it transparently, and if long-mode is entered, by any = thread, restore PTI. There is one corner case I did not cover (LAR) and Andy = felt this scheme is too complicated. Unfortunately, I don=E2=80=99t have a = better scheme in mind. --Apple-Mail=_530BEB66-AC1A-415E-86FC-5727FF7DFE2D Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename=signature.asc Content-Type: application/pgp-signature; name=signature.asc Content-Description: Message signed with OpenPGP -----BEGIN PGP SIGNATURE----- iQIzBAEBCgAdFiEE0YCJM4pMIpzxUdmOK4dOkxJsY0AFAlqGJDkACgkQK4dOkxJs Y0CMxRAA2JOCasXtFF9WAdCuTiKnLh2sQNY64ztpEnZL2cXoyl6QFetHK1vgq9vT +qzDs5zRjoFgseNXj11ARVwt5SJky+d2CT2vp2FPJBmBDgvZ5hDtcoUmnk5v1ur3 WNYqIO1qMEnd7k27x4AGaknOU3eHJCOvvrYyI9tHfeTw40wYIXxDzkcH886+56f8 /xVYq/q6JGfX44ndyW/bDLLdzbZjIUNEXlVuyAHpeptVzP7ij4fG31hpL3XLJ7oJ ZD7w6lTavTNvsya0f88ctPe2prAcTIxuWaew2SPJetdh5Las/zCF5K6e6OHlnRg5 W0c5DVDY3FNMWjEJkmxeax48PgI3Vjrl518wpxvNGf6RKKwrVXXeCxctpM7I5mq3 ox1FXs4ea/t4gF6akUWH2wseuQglHD6teRoTKoJj5La8yAwynfUFEKbCcjL4iQSR yGXmHrHPlr3dIV8WyU4eHdkAPjKIOTtWZCtGgsvr0aJSd88j/R75MTWcBfFKEbLA F4WlzXvQpltdI0uqBJjJgZeL6AcppR81OUrbUEFYsh7FB8PqHgwM79uVTyG4km1Q hm/8qnk8cCQ6P5w6yJm2nM/3zZd6tD/oFDm6XLKy87XlGOCKIMyo9rmFk5raci04 0x272gIhwbMP7hqOkiSWNT7qW1MP2a2yKV3J8dDagOvI4WCOiOM= =gOjl -----END PGP SIGNATURE----- --Apple-Mail=_530BEB66-AC1A-415E-86FC-5727FF7DFE2D--