From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from NAM11-CO1-obe.outbound.protection.outlook.com (NAM11-CO1-obe.outbound.protection.outlook.com [40.107.220.54]) by mx.groups.io with SMTP id smtpd.web09.281.1621985855756235884 for ; Tue, 25 May 2021 16:37:36 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@amd.com header.s=selector1 header.b=oMYctzZq; spf=permerror, err=parse error for token &{10 18 %{i}._ip.%{h}._ehlo.%{d}._spf.vali.email}: invalid domain name (domain: amd.com, ip: 40.107.220.54, mailfrom: brijesh.singh@amd.com) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=E+qPAUpRJ9Gxyx0oH2IM9MpCKT6oRdfCUJ3jbZETkWhtBOlj5sEU8M0ZnTd/vDZPpl9S6GTA4un1hBON0F1dMk5Trb4mY9t64xAhUSTD0iuQDwo/c1bpbKkLC0FqRM/Ur1u8dpL2tXyBOBkpNKW6+ZQ9dioudIGY/Ag/ewqd/ASpwu+KAbys5xfMSjXjXhEPxaHMSGfmSeNzoncE680/x5iSvjnJcTvwrCRey4QhAzjIn7zhlPxBHaPa0xdzTqdDKCOuy2JB0rFvMN3LxwfPEp1q2lUI2wzqj5qiFpjBW0rlYZdhl5J/FpWQCQzqk4tC0IQO5e0fMSz6YWtMUhZQDQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=tq3HgCNPBQ1fqpVUGzxaOvlgLvcVA6yW5945AMpIpKo=; b=PVhWkqQlZZ++3TEv0bFr7fFDAHaysZm2jz8Zsh/1rVoTF1J1e+N1j6hXxWq8CnOKAXjmZzdnFTBTQ+W4sXt4k9A44WTVRiokEuxrZggBOf3ABbKGQa8e5fI83nwoWdxQ4YkLzauryFhYrs7DU+69Tw9SudvrjxAy5lE2iKuumZUmjuhUtER3fFQ7e1g1nsS6wGckvJyStKK4xjAZQDMXO56sVXSvjMnvxNvFNau+6ksAZXydXSLo+vR5JBDhQxs85ewE6im7eXIc9R5wqCB9H4KoozxC6+5U+CQrJJq4ovptyBJBFThesFLghNQXVDCVPVJwn89xol1IeXJTVYGxdg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=amd.com; dmarc=pass action=none header.from=amd.com; dkim=pass header.d=amd.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=tq3HgCNPBQ1fqpVUGzxaOvlgLvcVA6yW5945AMpIpKo=; b=oMYctzZqrrIIpw3xi5A5XLurU4bRwCdg5blA6LXw9nGRA2WcE/yDEVn9rYXFqW4oi9se8hgIGe9mpi4BPzyR9S+LPu+RbGzMqvJefPgq/VEEnfHEJhN8wpM/1o/ov/CZn/TW7Q4pNLz0urmjrCR+pArCm7JA30ksFoJP6krhzPU= Authentication-Results: intel.com; dkim=none (message not signed) header.d=none;intel.com; dmarc=none action=none header.from=amd.com; Received: from SN6PR12MB2718.namprd12.prod.outlook.com (2603:10b6:805:6f::22) by SN1PR12MB2367.namprd12.prod.outlook.com (2603:10b6:802:26::31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4173.20; Tue, 25 May 2021 23:37:33 +0000 Received: from SN6PR12MB2718.namprd12.prod.outlook.com ([fe80::9898:5b48:a062:db94]) by SN6PR12MB2718.namprd12.prod.outlook.com ([fe80::9898:5b48:a062:db94%6]) with mapi id 15.20.4150.023; Tue, 25 May 2021 23:37:33 +0000 Cc: brijesh.singh@amd.com, Tobin Feldman-Fitzthum , Tobin Feldman-Fitzthum , Jim Cadden , Hubertus Franke , Laszlo Ersek , Ard Biesheuvel , Jordan Justen , Ashish Kalra , Erdem Aktas , Jiewen Yao , Min Xu Subject: Re: [edk2-devel] [PATCH v1 0/8] Measured SEV boot with kernel/initrd/cmdline To: jejb@linux.ibm.com, Tom Lendacky , Dov Murik , devel@edk2.groups.io References: <20210525053116.1533673-1-dovmurik@linux.ibm.com> <8b966d52-f207-b747-96a7-2ed6f29aa432@amd.com> <21593112-ea9c-8cd1-7cad-6fc6d9645242@linux.ibm.com> From: "Brijesh Singh" Message-ID: Date: Tue, 25 May 2021 18:37:30 -0500 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:78.0) Gecko/20100101 Thunderbird/78.10.0 In-Reply-To: X-Originating-IP: [70.112.153.56] X-ClientProxiedBy: SN7PR04CA0229.namprd04.prod.outlook.com (2603:10b6:806:127::24) To SN6PR12MB2718.namprd12.prod.outlook.com (2603:10b6:805:6f::22) Return-Path: brijesh.singh@amd.com MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from Brijeshs-MacBook-Pro.local (70.112.153.56) by SN7PR04CA0229.namprd04.prod.outlook.com (2603:10b6:806:127::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4173.20 via Frontend Transport; Tue, 25 May 2021 23:37:32 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: f7480c4f-5820-4d14-ad7e-08d91fd611da X-MS-TrafficTypeDiagnostic: SN1PR12MB2367: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:8882; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: LjDPpHuaRDE+TV4KCvTSsp2wFgHK91EE3mEQiMy2/5rqLTJXYukhjSPHnchJgI5kaJY9QytVHIvvMn5lDlCyFC0Br8AUhxFrzeuStujiOzsDnFniATLPRDO6f06JOflMpGbW0CtZ5+cy4Bau3/nF0n/yrelUNKLyn+nXb/Yr53x9I2n2hlgzZwHyxZJbYl3MviBWq5PSGdbob29NeIx13GG8FXwLKdUIkJybkdFAjJUdM709y3coZQCWuRzxIX6/J1zVIthGevGxX+tK5zUDi8eKlCqdGOdbkiPqhWZii/Bc2V9Am1qEqeKLymcNW7VmwxWdh0NlkNyCHxiSAixY/iaWi7+md303IFlO8CzZ8WtlgNRuVe29iDZzRVRNxD93Y0Frj/OGJrkC6aiy66mNYzn5/QFD1txHMITqkiXOm6AZ0D+spAIFWFa7O6EcPgIPUSWNK0E91Jbxz5Dineo6xpZNzW0LMfhZ5mkRJMyiS5ZUeiOgHCsPm3d1t8r76KQyrJXH5SRSA003WKqh8qyA85nS+tptLzu6AKx9UMitnBkh4B4lRtqB/FZT4gHDQMmaphr9uHaBxK4jKE9uxfNA3YFQ/gbYL3QQ0uu3fdIIAEzaQEDYkqNkNWgdaH0VExCAUE6HI82wkBOco/xPeLxojBrCVHIp83bXaPbjlbdClJylo089RkZig9utKEvapntw1sYozkh/ukgVLy2JHuSjd8RnpgME5XK33Vm52mYtJGQ= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SN6PR12MB2718.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(4636009)(366004)(346002)(136003)(396003)(39860400002)(376002)(52116002)(8676002)(36756003)(956004)(8936002)(2616005)(7416002)(66946007)(6512007)(66556008)(26005)(66476007)(478600001)(16526019)(186003)(31696002)(6486002)(6506007)(110136005)(2906002)(54906003)(86362001)(53546011)(31686004)(38350700002)(83380400001)(4326008)(316002)(44832011)(5660300002)(38100700002)(43740500002)(45980500001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: =?utf-8?B?U3FMYlFDeHdzZEQ0TVdTVEZZSEF6a2FkbytPMVJCTzk4MlZpYlA4SnA4dmhk?= =?utf-8?B?UWw1allBT2s1ZnIzeEx2eFdxRmlDRzlIaTJPV3N6VFJkSVk2ZVg3NlRLUVc1?= =?utf-8?B?cUg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0?= =?utf-8?B?NFNuSFdMMnNkTEozL1JHUGY5czFCREh1UVRkNVNrU2dxcGg2WmJNUEVyN3lk?= =?utf-8?B?OXZEWEpqMlJaVDhVZW5tMDdORk5CRUtHRTc1UkFIM2JXc1JnMWt5V1lRWE1w?= =?utf-8?B?WFFiMGtaTXphenNiL3hUOUtXVzMwbDFiV1l6YlZ4UUwreU5rblZGM2dEek40?= =?utf-8?B?ai9sRUx5RkdDVHZIdTVTS0lTNnVXUjJjdXV3TUYvVVBYTHBzcURFa2dQblZr?= =?utf-8?B?U2psNTNIR3hjMkFZejdaUDFmQi9qNGlET21WR0I4S053QkJXQjdoSXZiUG5Z?= =?utf-8?B?ZnBENUs4RUtJdE5tWEhVZWVOaXlOYVppcjhqb3o2NmlNUmRobGNPMk13SXhm?= =?utf-8?B?b1ZtKy9mYjBXMnpXVEhyYXE2RWZaQVh6dlI5SU1DekN1VW5BN0tpV3hFZk9L?= =?utf-8?B?NC85cFFTVGRodGdFaVRXNnZWZ1hkU3FOdXEySHovM0VEZnFSbWpraXBIelFB?= =?utf-8?B?OTFWMytmVzQ5ZDdEeDhTa3liVldnc2czL0hJKzMvMWFuWi9BQUF0aHdmZnVT?= =?utf-8?B?SEJmS3RxV1F1NVU0UEJkUE04N2NpblFFUUtjTTIwb3JVQzVUVi9vd25ZcUtP?= =?utf-8?B?bEI5UnF2c1Z3OURtUDdJcGdGMWZZWDNLRFlkOFNTeHpBRnArNVM3YTVENEdM?= =?utf-8?B?Q21PcjhjczhwajFZODM0WWRYa0x4SE8rUzBPanE2ZmRud2p5QU9IbTI5Y1g2?= =?utf-8?Q?JURuT3BEwlCBg+QKQlJCsWnMGA0Us3OWyL29EPu?= X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: f7480c4f-5820-4d14-ad7e-08d91fd611da X-MS-Exchange-CrossTenant-AuthSource: SN6PR12MB2718.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 May 2021 23:37:33.3841 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: tMHql0uWYQ4nXta8PwEXzGbGUoJw3tCQbEj2NxK9YBRQ3LXHK3gWH8cTC+KqSAZoNmazkaZRWgbDEiZQwzdlLg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN1PR12MB2367 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Content-Language: en-US On 5/25/21 6:15 PM, James Bottomley wrote: > On Tue, 2021-05-25 at 15:33 -0500, Tom Lendacky wrote: >> On 5/25/21 3:08 PM, Dov Murik wrote: >>> Hi Brijesh, >>> >>> On 25/05/2021 18:48, Brijesh Singh wrote: >>>> On 5/25/21 12:31 AM, Dov Murik wrote: >>>>> Booting with SEV prevented the loading of kernel, initrd, and >>>>> kernel command-line via QEMU fw_cfg interface because they >>>>> arrive from the VMM which is untrusted in SEV. >>>>> >>>>> However, in some cases the kernel, initrd, and cmdline are not >>>>> secret but should not be modified by the host. In such a case, >>>>> we want to verify inside the trusted VM that the kernel, >>>>> initrd, and cmdline are indeed the ones expected by the Guest >>>>> Owner, and only if that is the case go on and boot them up >>>>> (removing the need for grub inside OVMF in that mode). >>>>> >>>>> This patch series declares a new page in MEMFD which will >>>>> contain the hashes of these three blobs (kernel, initrd, >>>>> cmdline), each under its own GUID entry. This tables of hashes >>>>> is populated by QEMU before launch, and encrypted as part of >>>>> the initial VM memory; this makes sure theses hashes are part >>>>> of the SEV measurement (which has to be approved by the Guest >>>>> Owner for secret injection, for example). Note that this >>>>> requires a new QEMU patch which will be submitted soon. >>>> I have not looked at the patches, but trying to brainstorm if we >>>> can avoid reserving a new page in the MEMFD and use the existing >>>> EDK2 infrastructure to verify the blobs (kernel, initrd) loaded >>>> through the FW_CFG interface in the guest memory. >>>> >>>> If I understand correctly, then in your proposed approach, guest >>>> owner wants to ensure that the hypevisor passing its preferred >>>> kernel, initrd and cmdline. The guest owner basically knows the >>>> hashes of these components in advance. >>> Yes, that's correct. >>> >>>> So, can we do something like this: >>>> >>>> - The secret blob provided by the guest owner should contains the >>>> hashes (sha384) of these components. >>>> >>>> - Use openssl API available in the edk2 to calculate the hash >>>> while loading the kernel, initrd and cmdline. >>> Indeed we do something similar already - we use Sha256HashAll (see >>> patch 5 in this series). >>> >>> >>>> - Before booting the kernel, compare the calculated hash with the >>>> one listed in the secret page. If they don't match then fail >>>> otherwise continue. >>> That is indeed what we do in patch 6 (the calls to our >>> ValidateHashEntry). >>> >>> >>>> Did I miss something ? >>> Thanks for proposing this. >>> >>> Your approach has the advantage that there's no need for extra >>> pre-allocated MEMFD page for the hashes, and also it makes the QEMU >>> flow simpler (QEMU doesn't need to compute the hashes and put them >>> in that special MEMFD page). I think that the only change we'll >>> need from QEMU in the x86_load_linux flow (which is when the user >>> supplies -kernel/-initrd) is that it won't modify any memory in a >>> way that the modifies the hashes that Guest Owner expects (for >>> example, avoid writing over the kernel's setup area). >>> >>> However, the disadvantage is that it unifies boot measurement with >>> the secret injection. The Guest Owner _must_ inject the hashes, >>> otherwise the system doesn't boot; whereas in our current >>> suggestion the Guest Owner can check the measurement, verify that >>> everything is OK, and just let the guest continue. >>> >>> But as I write this, I think that maybe without secret injection >>> the guest is not really secure? Because the host could just >>> continue execution of the guest without waiting for measurement >>> check... If the Guest Owner _must_ inject a secret for SEV to be >>> secure in any case, we might as well choose your path and let the >>> Guest Owner inject the table of hashes themselves. >>> >>> I'd like to hear your (and others') thoughts. >> Brijesh and I had a long discussion over this. I think that if you're >> dealing with a malicious hypervisor, then it could, in fact, measure >> all the components that it wants to be used and, using >> LAUNCH_UPDATE_DATA, add a page, that matches the format of the guest >> secret page, to the guest and indicate that page as the guest secret. >> Even though the measurement would fail validation by the guest owner, >> the hypervisor could ignore it and continue to run the guest. >> >> So you need something that proves ownership of the guest secret - >> like a disk key that would fail to unlock the disk if the hypervisor >> is faking the guest secret. >> >> Does all that make sense? > I think it does for the unencrypted boot case. For the encrypted boot > case, the HV can't inject the decryption key, because it doesn't know > it, so the interior guest will know there's a problem as soon as it > can't decrypt the image. > > But I get the point that we can't rely on the secrets page for hashes > if we have nothing cryptographic in it. However, the actual threat > from this is somewhat unclear. As you note: the guest owner knows > there's a problem, but the actual guest is still executing because of > intervention by a malicious hypervisor owner. In the cloud that's more > or less equivalent to me taking over the guest IP and trying to man in > the middle the services ... once the guest owner knows this happened, > they're going to be looking for a new CSP. So I think the threat would > be potent if you could convince the guest owner that nothing were > amiss, so they think the modified guest is legitimate, but less so > otherwise. I guess if we can have the guest BIOS communicate with the guest owner using a secure channel to obtain the hash'es or key to decrypt the hashes then all of it be okay. To establish the secret channel the guest BIOS will use the secret injected through the LAUNCH_SECRET. If OVMF fails to establish the secret channel with the guest owner, then its an indicate that malicious hypervisor booted the guest without injecting a valid secret or skipped the attestation flow. > > James > >