Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S965631AbeAJPVd (ORCPT + 1 other); Wed, 10 Jan 2018 10:21:33 -0500 Received: from smtp-fw-4101.amazon.com ([72.21.198.25]:35421 "EHLO smtp-fw-4101.amazon.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S965083AbeAJPVU (ORCPT ); Wed, 10 Jan 2018 10:21:20 -0500 X-Amazon-filename: smime.p7s X-IronPort-AV: E=Sophos;i="5.46,340,1511827200"; d="p7s'?scan'208";a="702701388" Message-ID: <1515597645.22302.187.camel@amazon.co.uk> Subject: Re: [PATCH v6 00/10] Retpoline: Avoid speculative indirect calls in kernel To: Paul Turner , Tom Lendacky CC: Andi Kleen , LKML , Linus Torvalds , Greg Kroah-Hartman , Tim Chen , "Dave Hansen" , Thomas Gleixner , "Kees Cook" , Rik van Riel , Peter Zijlstra , Andy Lutomirski , Jiri Kosina , One Thousand Gnomes In-Reply-To: References: <1515363085-4219-1-git-send-email-dwmw@amazon.co.uk> Face: iVBORw0KGgoAAAANSUhEUgAAADAAAAAwBAMAAAClLOS0AAAAG1BMVEUHBwcUFBQpKSlGRkZhYWF9fX2Xl5eysrLMzMxFF+rXAAACaElEQVQ4y21UQXbbIBQE9wJALmAg6ToWON22FrhZthHgbvssUPathC7QWMful2JHSmtWwGg+zPxBCE0DU4QoJQgRgsg4w2gJjBNE8PjFBZgnQMBs+uZ1NQNQjZO3BV4AGDFC0f+l4DBG0VUAM4yv7SO8IgRdHXQ+A78HKL5OAeCfNQV5cHX8DsBUyIJKtYbt98BKaGNCKjfgFVkqYVLbkHKsRsbSCSa0T6npIqLrpRBgQKHUpQmgs9eEKaiUcooE8WWfCGVnBiUcn1uF2XhbfmN9apKnmMP2K4kizKkQWxuaVNOpU2cACIyxO1Po8ETHcXEDMVnozcejkAYA9iaD4pU0ZvNQ8VurNnTuFAYVtuIPUZW25PjDIjQAlGyffIiRQxoWAZBmJ0LTdW2Nyc0iP3DqRhxizvGJkBWZmyFVyZkddWzmBoIBVMpCCJ1CFzl98xav4VJKSSD45KbUT75ixikTphDSRh8+Uz7JLgUTAgAFwzqzjxc/nDY7WUApqY0OMdTwCKZSXplSKkgIRCHElCp8ZnhnKqXuwcNbk1L0VXE+I9alUXoHlLHl3mv7/dWQlJwtjREC7mu9L/U2jQyMUuO2EDS4q9Kl2ddm232bxIE5pjJuVwiljNn/Cfv25/T0cu5cZbwHGVq7h/zp0B4n3S99V/utD+Uo8BiGx9xCsOAV5z7/tjo4Z4z1Lvb90KZ7eFOoOeXOukqF2seo234YYuaQPpRP+cVZU5adT1Edun5Iz3z8fTz3+eSDh0Ip1c7zx1MaijGzTd/3MbRuBHz8cvcVgCMBRpOHvgu59WDhoat+nIZm+LWm9C/aaaGq5DCP9QAAAABJRU5ErkJggg== Organization: Amazon Content-Type: multipart/signed; micalg=sha-256; protocol="application/x-pkcs7-signature"; boundary="=-PgZL+7UAZnE5eKer0Gu3" Date: Wed, 10 Jan 2018 15:20:45 +0000 X-Mailer: Evolution 3.18.5.2-0ubuntu3.2 MIME-Version: 1.0 From: "Woodhouse, David" X-Evolution-Source: 1481217574.17989.4@uc8d3ff76b9bc5848a9cc Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Return-Path: --=-PgZL+7UAZnE5eKer0Gu3 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Mon, 2018-01-08 at 02:42 -0800, Paul Turner wrote: >=20 > While the cases above involve the crafting and use of poisoned > entries.=C2=A0 Recall also that one of the initial conditions was that we > should avoid RSB underflow as some CPUs may try to use other indirect > predictors when this occurs. I think we should start by deliberately ignoring the CPUs which use the other indirect predictors on RSB underflow. Those CPUs don't perform *quite* so badly with IBRS anyway. Let's get the minimum amount of RSB handling in to cope with the pre- SKL CPUs, and then see if we really do want to extend it to make SKL 100% secure in retpoline mode or not. So let's go through your list of cases and attempt to distinguish the underflow concerns (which I declare we don't care about for now) from the pollution (which we care about especially for non-SMEP) concerns... > The cases we care about here are: > - When we return _into_ protected execution.=C2=A0 For the kernel, this > means when we exit interrupt context into kernel context, since may > have emptied or reduced the number of RSB entries while in iinterrupt > context. Don't care about that particular example. That's underflow-only. However, we *do* care about entry to kernel code from userspace, for interrupts and system calls etc. Basically everywhere that the IBRS code would be setting IBRS, we need to flush the RSB (if !SMEP, I think). > - Context switch (even if we are returning to user code, we need to > at unwind the scheduler/triggering frames that preempted it > previously, considering that detail, this is a subset of the above, > but listed for completeness) Don't care. This is underflow-only. (Which means I think we want to drop Andi's patch?) > - On VMEXIT (it turns out we need to worry about both poisoned > entries, and no entries, the solution is a single refill > nonetheless). Do care. This fixes pollution from the guest, and even SMEP isn't enough to make us not care. > - Leaving deeper (>C1) c-states, which may have flushed hardware > state Don't care. > - Where we are unwinding call-chains of >16 entries[*] Don't care. Overall, I think the RSB-stuffing is needed in all the same places that it's needed with IBRS. --=-PgZL+7UAZnE5eKer0Gu3 Content-Type: application/x-pkcs7-signature; name="smime.p7s" Content-Disposition: attachment; filename="smime.p7s" Content-Transfer-Encoding: base64 MIAGCSqGSIb3DQEHAqCAMIACAQExDzANBglghkgBZQMEAgEFADCABgkqhkiG9w0BBwEAAKCCEE4w ggUuMIIEFqADAgECAhEApEtL31g6H7ROXdOiQnA9RjANBgkqhkiG9w0BAQsFADCBlzELMAkGA1UE BhMCR0IxGzAZBgNVBAgTEkdyZWF0ZXIgTWFuY2hlc3RlcjEQMA4GA1UEBxMHU2FsZm9yZDEaMBgG A1UEChMRQ09NT0RPIENBIExpbWl0ZWQxPTA7BgNVBAMTNENPTU9ETyBSU0EgQ2xpZW50IEF1dGhl bnRpY2F0aW9uIGFuZCBTZWN1cmUgRW1haWwgQ0EwHhcNMTcxMjIxMDAwMDAwWhcNMTgxMjIxMjM1 OTU5WjAiMSAwHgYJKoZIhvcNAQkBFhFkd213QGFtYXpvbi5jby51azCCASIwDQYJKoZIhvcNAQEB BQADggEPADCCAQoCggEBAKdGKgXuwKMg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