From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from NAM11-DM6-obe.outbound.protection.outlook.com (NAM11-DM6-obe.outbound.protection.outlook.com [40.107.223.42]) by mx.groups.io with SMTP id smtpd.web10.185.1626801530604965378 for ; Tue, 20 Jul 2021 10:18:50 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@amd.com header.s=selector1 header.b=lTno8lzy; 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.223.42, mailfrom: thomas.lendacky@amd.com) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=VRrBV6kDoVGueI3Wns+OQykmi5jpYVUuDWOZVY6EJLrGyD6ydaGPvL2p1d1Yg56zPC1LHvg4xBdXl4s+JK4N2UsBgpxsXRHEqAFVCGepYQj6qAMgSZZXajqvxi3DCYQZWRMK2gG9icdWQUmQRgj1Bd/U8l4LNGFHpQVEI/139cxVs5Nd6WJjuaXWmuQXD6R+S/fYJMqK15AiTnN0beQkR/R0+s+JCHJKL5MPaUbjMXtdf1l/GQYVp8g+M6ddxwOZCZT95Vt2ZW/8LHEyghyBoKeAciCiw5zRYoNdGtlasu8drYtyBjfH6iBIGWJnmZTYTRi3Nc0AA3vsjjT6PMVrXQ== 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=Oiub5U1yG6MhvX4gUnx0XfS9rqzfNAt3Zb1340oQN7k=; b=ItyRXoQk/5TC7DzdKPImdJ1NiTF38/OppJDRmkCUwd1bOujICDUrRz4NBPLht3THe4ajU/Qod6WcQ5E7/3Bgs08XjBdc3YH1UeXT82tKXRhByUP94+3lX1OJX1ixTBOyWBypjNqf+axfuwokLwpEFfKBWpTSTYpbqpD2D0CMPq9AcvxvTlZMtwQ/RPnQT14wfXWzq/laTLZ19/isoN8g0f+/ChJ209RMSX5cwHaIwRXVLKyiRdgaQcJkRS6BG8qszf8SRuEoiYPP9ZAOx6j6KCgZlOIuQtD5Gx/87Rpu2DdvioT/VikYq6JU/FoIWwwmF8nCXiJaaSQBkTNFhKryyg== 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=Oiub5U1yG6MhvX4gUnx0XfS9rqzfNAt3Zb1340oQN7k=; b=lTno8lzyiKUH8ALsCaaOJFryLWOp7d2Da1J9GFsaOR3S8q0eHMVKnXrp9zI5mSPZYPsmyr4M0OMdLwIBqfYchOC8pZif1rvTS40yu1DKlM5mnlTOiXCkdx/eeoEwmGVkh/hSFFFoIz32JlPg0yp3rwS2QZzS5Hz7zABTn8+LuKQ= Authentication-Results: intel.com; dkim=none (message not signed) header.d=none;intel.com; dmarc=none action=none header.from=amd.com; Received: from DM4PR12MB5229.namprd12.prod.outlook.com (2603:10b6:5:398::12) by DM4PR12MB5358.namprd12.prod.outlook.com (2603:10b6:5:39c::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4331.30; Tue, 20 Jul 2021 17:18:49 +0000 Received: from DM4PR12MB5229.namprd12.prod.outlook.com ([fe80::73:2581:970b:3208]) by DM4PR12MB5229.namprd12.prod.outlook.com ([fe80::73:2581:970b:3208%3]) with mapi id 15.20.4331.034; Tue, 20 Jul 2021 17:18:49 +0000 Subject: Re: [PATCH v3 10/11] OvmfPkg: add BlobVerifierLibSevHashes To: Dov Murik , devel@edk2.groups.io Cc: Tobin Feldman-Fitzthum , Tobin Feldman-Fitzthum , Jim Cadden , James Bottomley , Hubertus Franke , Ard Biesheuvel , Jordan Justen , Ashish Kalra , Brijesh Singh , Erdem Aktas , Jiewen Yao , Min Xu References: <20210720080401.3662854-1-dovmurik@linux.ibm.com> <20210720080401.3662854-11-dovmurik@linux.ibm.com> From: "Lendacky, Thomas" Message-ID: Date: Tue, 20 Jul 2021 12:18:46 -0500 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.11.0 In-Reply-To: <20210720080401.3662854-11-dovmurik@linux.ibm.com> X-ClientProxiedBy: SA0PR13CA0023.namprd13.prod.outlook.com (2603:10b6:806:130::28) To DM4PR12MB5229.namprd12.prod.outlook.com (2603:10b6:5:398::12) Return-Path: thomas.lendacky@amd.com MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from [10.236.30.241] (165.204.77.1) by SA0PR13CA0023.namprd13.prod.outlook.com (2603:10b6:806:130::28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4352.14 via Frontend Transport; Tue, 20 Jul 2021 17:18:48 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: ccd1177b-ad8f-42dc-abac-08d94ba27028 X-MS-TrafficTypeDiagnostic: DM4PR12MB5358: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:6430; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: EpoBrqV7Xlpp8XjargSW5RNyxrCh8q334PZ7bDYDcGCIogK8KrwMz1Nt2vB1I0PFQsm33+wWYAamDGmocqmzGQtnIDnnKOjeoZfRkJ19bUtSs8w+GwWUiRIXO5kdmNFZsqf1KyTKjE94wXqD75+81PRgv/Xf+C4zf2qGdC2i0o46Pmb3EuDaos+c/fE7RAQcb+yPFF0U2V+Ll0anvpqG59Q++JUp1taDRIlQZS/J9THsC2orWdYJJmAEHi3ufEokVuPxcWi6rBybkJMI2Bd7eD6E6XFIsG3UAjnp5nD+sJlITByF3l1azYIV5vaJrR7YOd7DkLXffELEeV36o6BGI31bMHZwLQ0VSQ2VCA/72WntMoN0kkSRBiUG5HOE2D3HVRplCQtvI9/uzB2npNqv5hniFjmkCYSuEV7Lx0zcsg9sPX4JFZep9hCvLtBLNcup6fr+ixfk01SmyHwNAJmqdTa4hsaSd7SOq0mzriBACuuXlvxY8+Bg7hGwCIE/xx4eIcK5ttkcJ1/TJB/cLv+t//Gl7xPBZkCJJnGJ5McZdhzY5l4jXJIt8uM1EErcAqqzR12eg/SWw8DpfwzV4JB7scYygRJmeoy0xcgI2KAM3xjziORNlB74er8wrvi3KfVXghDDQomJ8uWFkMNoiC1zkjSrHA9xXuz8fFtEJjmtoElhluBU3JV5SJMcg55AH/JBuPNhU2ANDJrfLDSM/ruCgAiDDKJgcnsnoJhqRgI3gj0ZqCLojrCs/jHUBWN4jNsD4otBPl8hdIFTbMCZY/vCElSE0ovDMAs1WBVUxoBqt5rvPVDcPy+s49WaFqHsgLmQFKr4NvHYLzQfoUqnDYWbg3if0GcJW3qdqwXvJU1JIbM= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DM4PR12MB5229.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(4636009)(366004)(376002)(396003)(136003)(39860400002)(346002)(38100700002)(966005)(478600001)(31696002)(16576012)(956004)(6486002)(2616005)(54906003)(36756003)(86362001)(2906002)(31686004)(8676002)(53546011)(83380400001)(66946007)(186003)(8936002)(66476007)(4326008)(316002)(66556008)(26005)(5660300002)(7416002)(213903007)(45980500001)(43740500002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?a0NWWXpSMnkvdFhFazdmbVFXblhFVUgzeFBtd1lXRGQvVVcrZ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177b-ad8f-42dc-abac-08d94ba27028 X-MS-Exchange-CrossTenant-AuthSource: DM4PR12MB5229.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Jul 2021 17:18:49.0006 (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: DX0JI72yRAWCtlkMPZPV2Xxmz5XQfynGCafezzcSy6yIYR5h/bFZ78rXZQrvqK/YgjJ3P7okvcWF5/vXzp81Tg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM4PR12MB5358 Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit On 7/20/21 3:04 AM, Dov Murik wrote: > Add an implementation for BlobVerifierLib that locates the SEV hashes > table and verifies that the calculated hashes of the kernel, initrd, and > cmdline blobs indeed match the expected hashes stated in the hashes > table. > > If there's a missing hash or a hash mismatch then EFI_ACCESS_DENIED is > returned which will cause a failure to load a kernel image. > > Cc: Ard Biesheuvel > Cc: Jordan Justen > Cc: Ashish Kalra > Cc: Brijesh Singh > Cc: Erdem Aktas > Cc: James Bottomley > Cc: Jiewen Yao > Cc: Min Xu > Cc: Tom Lendacky > Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=3457 > Co-developed-by: James Bottomley > Signed-off-by: James Bottomley > Signed-off-by: Dov Murik A comment about the use of INT32 in the for loop to protect against a large entry length value would be useful. I don't think it's worth another version, but if you have to make any updates it would be nice to add. Reviewed-by: Tom Lendacky > --- > OvmfPkg/Library/BlobVerifierLib/BlobVerifierLibSevHashes.inf | 37 ++++ > OvmfPkg/Library/BlobVerifierLib/BlobVerifierSevHashes.c | 200 ++++++++++++++++++++ > 2 files changed, 237 insertions(+) >