From nobody Fri May 3 16:01:57 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+77174+1787277+3901457@groups.io; helo=mail02.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+77174+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=linux.ibm.com ARC-Seal: i=1; a=rsa-sha256; t=1624877478; cv=none; d=zohomail.com; s=zohoarc; b=GnJVh5OLLBuUgxyj74IcGU5RmUB+S6XfYj0+bH8m2VNZ0TdkRLIi1gYcx80Bde6NWoF8mGD1R7E5S8T/j8v+oL2gLiYt6jQo60UOeaHyyAt0bA9Y+hyaGGsVOEYZrcZ/Zg5INJkkJnAyzpMDd/62H//L+vrqnhsJyKDkuUMES/M= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1624877478; h=Content-Transfer-Encoding:Cc:Date:From:List-Subscribe:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Sender:Subject:To; bh=V+CdMF4hc1+VNpX8sFZ4gT4Q5G7RQTgXiPNmd42WWv8=; b=aCk3LprifgYlieEQ5DwPX+Jk24PnwEVC/m9dyyTgY5BR2Y5UcG3fq7+4006fgz/Zq+oh/EIx0IKz/XIQTDB2j6dDF+L5iuSMmFilqKMU9InRGNXPR5Go74mNKg4U8/qsxBXLQoP5zGMnr6Ht6+zdYtvnw9MsYQsfIdwALfo6ydU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+77174+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 162487747840438.73436382659838; Mon, 28 Jun 2021 03:51:18 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id JhltYY1788612xjVhg4U0R95; Mon, 28 Jun 2021 03:51:18 -0700 X-Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) by mx.groups.io with SMTP id smtpd.web08.9501.1624877477346101953 for ; Mon, 28 Jun 2021 03:51:17 -0700 X-Received: from pps.filterd (m0098409.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.43/8.16.0.43) with SMTP id 15SAhWT3160430; Mon, 28 Jun 2021 06:51:17 -0400 X-Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com with ESMTP id 39fcga0vs9-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 28 Jun 2021 06:51:16 -0400 X-Received: from m0098409.ppops.net (m0098409.ppops.net [127.0.0.1]) by pps.reinject (8.16.0.43/8.16.0.43) with SMTP id 15SAhajn160624; Mon, 28 Jun 2021 06:51:16 -0400 X-Received: from ppma02wdc.us.ibm.com (aa.5b.37a9.ip4.static.sl-reverse.com [169.55.91.170]) by mx0a-001b2d01.pphosted.com with ESMTP id 39fcga0vrs-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 28 Jun 2021 06:51:16 -0400 X-Received: from pps.filterd (ppma02wdc.us.ibm.com [127.0.0.1]) by ppma02wdc.us.ibm.com (8.16.1.2/8.16.1.2) with SMTP id 15SAgfxF031741; Mon, 28 Jun 2021 10:51:14 GMT X-Received: from b01cxnp22036.gho.pok.ibm.com (b01cxnp22036.gho.pok.ibm.com [9.57.198.26]) by ppma02wdc.us.ibm.com with ESMTP id 39duva98gs-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 28 Jun 2021 10:51:14 +0000 X-Received: from b01ledav006.gho.pok.ibm.com (b01ledav006.gho.pok.ibm.com [9.57.199.111]) by b01cxnp22036.gho.pok.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 15SApEm79110188 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 28 Jun 2021 10:51:14 GMT X-Received: from b01ledav006.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 19089AC059; Mon, 28 Jun 2021 10:51:14 +0000 (GMT) X-Received: from b01ledav006.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id E5CFBAC05B; Mon, 28 Jun 2021 10:51:13 +0000 (GMT) X-Received: from localhost.localdomain (unknown [9.2.130.16]) by b01ledav006.gho.pok.ibm.com (Postfix) with ESMTP; Mon, 28 Jun 2021 10:51:13 +0000 (GMT) From: "Dov Murik" To: devel@edk2.groups.io Cc: Dov Murik , Laszlo Ersek , Ard Biesheuvel , Jordan Justen , James Bottomley , Tobin Feldman-Fitzthum Subject: [edk2-devel] [PATCH v3 0/5] OvmfPkg: Use QemuKernelLoaderFs to read cmdline/initrd Date: Mon, 28 Jun 2021 10:51:05 +0000 Message-Id: <20210628105110.379951-1-dovmurik@linux.ibm.com> X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: mG8_Xd0Ud_EckPqGKtNUVVkiw0CCBBZh X-Proofpoint-GUID: Iib7hkJD2GPD-TFN64WZB0pAiDMl9UGE X-Proofpoint-UnRewURL: 0 URL was un-rewritten MIME-Version: 1.0 Precedence: Bulk List-Unsubscribe: List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,dovmurik@linux.ibm.com X-Gm-Message-State: 3HjBZr1LCfvoX118AyEbXxIUx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1624877478; bh=acIT8WJ9s1A8kwSA+JxHiQFb9Nw0Wif4dagLFFlewNE=; h=Cc:Date:From:Reply-To:Subject:To; b=AkhRo3VrPlInafyBO1O4nkapCBsrm7hqIh9RHHJSzebi0wGR9Mtlx5jfEohxum4jdQ/ 2y7tQ0/nRZDwZHVur0lbfjXNm+3DqPdMhu8uRAWGLoZ+lKno+qbkO/klxtO6Z6/qrFdZh y3KRTgw47JZnYaKues8h2HCDNaqWtWYG2Lg= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Type: text/plain; charset="utf-8" BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=3D3457 In order to support measured SEV boot with kernel/initrd/cmdline, we'd like to have one place that reads those blobs; in the future we'll add the measurement and verification in that place. We already have a synthetic filesystem (QemuKernelLoaderFs) which holds three files: "kernel", "initrd", and "cmdline". The kernel is indeed read from this filesystem in LoadImage; but the cmdline (and the length of initrd) are read from QemuFwCfgLib items. This patch series first fixes two identical memory leak bugs in GenericQemuLoadImageLib and X86QemuLoadImageLib; then modifies GenericQemuLoadImageLib to read cmdline (and the initrd size) from the QemuKernelLoaderFs synthetic filesystem, thus removing the dependency on QemuFwCfgLib. Note that X86QemuLoadImageLib is not modified, because it contains a QemuLoadLegacyImage() which reads other items of the QemuFwCfg which are not available in QemuKernelLoaderFs. Since we don't want to support the legacy boot path in the future measured SEV boot, we leave X86QemuLoadImageLib as-is (except for a comment addition in patch 3) and will force use for GenericQemuLoadImageLib in the measured SEV boot implementation. Relevant discussion threads start in: https://edk2.groups.io/g/devel/message/76069 To test this on x86_64, I forced the use of GenericQemuLoadImageLib using the following local patch: diff --git a/OvmfPkg/OvmfPkgX64.dsc b/OvmfPkg/OvmfPkgX64.dsc index 0a237a905866..46442b543bcf 100644 --- a/OvmfPkg/OvmfPkgX64.dsc +++ b/OvmfPkg/OvmfPkgX64.dsc @@ -404,7 +404,7 @@ [LibraryClasses.common.DXE_DRIVER] PciLib|OvmfPkg/Library/DxePciLibI440FxQ35/DxePciLibI440FxQ35.inf MpInitLib|UefiCpuPkg/Library/MpInitLib/DxeMpInitLib.inf QemuFwCfgS3Lib|OvmfPkg/Library/QemuFwCfgS3Lib/DxeQemuFwCfgS3LibFwCfg.inf - QemuLoadImageLib|OvmfPkg/Library/X86QemuLoadImageLib/X86QemuLoadImageLib= .inf + QemuLoadImageLib|OvmfPkg/Library/GenericQemuLoadImageLib/GenericQemuLoad= ImageLib.inf # XXX don't commit this or someone will be mad !if $(TPM_ENABLE) =3D=3D TRUE Tpm12DeviceLib|SecurityPkg/Library/Tpm12DeviceLibTcg/Tpm12DeviceLibTcg.i= nf Tpm2DeviceLib|SecurityPkg/Library/Tpm2DeviceLibTcg2/Tpm2DeviceLibTcg2.inf I tested boot with QEMU and OVMF with the following QEMU arguments: -kernel a -kernel a -initrd b -kernel a -cmdline c -kernel a -initrd b -cmdline c (and also without -kernel) Code is at https://github.com/confidential-containers-demo/edk2/tree/use-synthetic-fs-= for-cmdline-v3 v3 changes: - Insert patches 1+2 at the top of the series to fix cmdline leak bugs - Organize #include and .inf - Add UINTN overflow check - Fix error paths and function epilogue to properly release all resources - Clarity: rename long variables, reword comments v2: https://edk2.groups.io/g/devel/message/76664 v2 changes: - Add comment to header of X86QemuLoadImageLib.inf - Clearer function names in GenericQemuLoadImageLib.c - Fix coding style issues v1: https://edk2.groups.io/g/devel/message/76265 Cc: Laszlo Ersek Cc: Ard Biesheuvel Cc: Jordan Justen Cc: James Bottomley Cc: Tobin Feldman-Fitzthum Dov Murik (5): OvmfPkg/GenericQemuLoadImageLib: plug cmdline blob leak on success OvmfPkg/X86QemuLoadImageLib: plug cmdline blob leak on success Revert "OvmfPkg/QemuKernelLoaderFsDxe: don't expose kernel command line" OvmfPkg/GenericQemuLoadImageLib: Read cmdline from QemuKernelLoaderFs OvmfPkg/X86QemuLoadImageLib: State fw_cfg dependency in file header OvmfPkg/Library/GenericQemuLoadImageLib/GenericQemuLoadImageLib.inf | 3 = +- OvmfPkg/Library/X86QemuLoadImageLib/X86QemuLoadImageLib.inf | 3 + OvmfPkg/Library/GenericQemuLoadImageLib/GenericQemuLoadImageLib.c | 157 = ++++++++++++++++++-- OvmfPkg/Library/X86QemuLoadImageLib/X86QemuLoadImageLib.c | 9 = +- OvmfPkg/QemuKernelLoaderFsDxe/QemuKernelLoaderFsDxe.c | 11 = +- 5 files changed, 161 insertions(+), 22 deletions(-) --=20 2.25.1 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#77174): https://edk2.groups.io/g/devel/message/77174 Mute This Topic: https://groups.io/mt/83841915/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-