From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.158.5]) by mx.groups.io with SMTP id smtpd.web09.10215.1623146234657904488 for ; Tue, 08 Jun 2021 02:57:15 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@ibm.com header.s=pp1 header.b=c+UZSC/u; spf=pass (domain: linux.ibm.com, ip: 148.163.158.5, mailfrom: dovmurik@linux.ibm.com) Received: from pps.filterd (m0098416.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.43/8.16.0.43) with SMTP id 1589YXFa063961; Tue, 8 Jun 2021 05:57:12 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=subject : to : cc : references : from : message-id : date : mime-version : in-reply-to : content-type : content-transfer-encoding; s=pp1; bh=0IMyZm3kLEcWpxnpQOoFQ3nPNyEc6gRQjhYckeUZUtM=; b=c+UZSC/uQr1vupZGS7pSK4wiCJi+FCclnQllhG/aAZQOGhkCSk44lHl2U9dsoiQWLUGL ngC3nhJs22gV5XTlbea4C9CKQ6qPPfsVnDxY6v/ClDK+HSLf6WfGUNueB7XHDqVfW26g RQJF4jGQO5I+4MMv3nN0sS2FXqbFFghzH9EX402KOCYutsVQ6x17lvniksaWPvXnCh2u LJ1ttJxGKDurhVfRylxDWeiQWv2Fvo4w3b5pYv78mt714fQqrvfakKH7vO8E7EOidn1b KaGv7o2sCyEyIt3IVNQG1MoxwJ71JnnN1C/4LpGGezQbXtWgRU56K0RIcH4TpZOUhd/J xw== Received: from pps.reinject (localhost [127.0.0.1]) by mx0b-001b2d01.pphosted.com with ESMTP id 3922cteyx3-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 08 Jun 2021 05:57:12 -0400 Received: from m0098416.ppops.net (m0098416.ppops.net [127.0.0.1]) by pps.reinject (8.16.0.43/8.16.0.43) with SMTP id 1589Z2C5065361; Tue, 8 Jun 2021 05:57:11 -0400 Received: from ppma04ams.nl.ibm.com (63.31.33a9.ip4.static.sl-reverse.com [169.51.49.99]) by mx0b-001b2d01.pphosted.com with ESMTP id 3922cteyw9-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 08 Jun 2021 05:57:11 -0400 Received: from pps.filterd (ppma04ams.nl.ibm.com [127.0.0.1]) by ppma04ams.nl.ibm.com (8.16.1.2/8.16.1.2) with SMTP id 1589lu6b029850; Tue, 8 Jun 2021 09:57:09 GMT Received: from b06cxnps3074.portsmouth.uk.ibm.com (d06relay09.portsmouth.uk.ibm.com [9.149.109.194]) by ppma04ams.nl.ibm.com with ESMTP id 3900w89e2v-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 08 Jun 2021 09:57:09 +0000 Received: from d06av25.portsmouth.uk.ibm.com (d06av25.portsmouth.uk.ibm.com [9.149.105.61]) by b06cxnps3074.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 1589v6QL20906300 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 8 Jun 2021 09:57:06 GMT Received: from d06av25.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 9370F11C04A; Tue, 8 Jun 2021 09:57:06 +0000 (GMT) Received: from d06av25.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 8396111C04C; Tue, 8 Jun 2021 09:57:02 +0000 (GMT) Received: from [9.160.63.216] (unknown [9.160.63.216]) by d06av25.portsmouth.uk.ibm.com (Postfix) with ESMTP; Tue, 8 Jun 2021 09:57:02 +0000 (GMT) Subject: Re: [edk2-devel] [PATCH v1 0/8] Measured SEV boot with kernel/initrd/cmdline To: Laszlo Ersek , devel@edk2.groups.io, Ard Biesheuvel Cc: Tobin Feldman-Fitzthum , Tobin Feldman-Fitzthum , Jim Cadden , James Bottomley , Hubertus Franke , Jordan Justen , Ashish Kalra , Brijesh Singh , Erdem Aktas , Jiewen Yao , Min Xu , Tom Lendacky References: <20210525053116.1533673-1-dovmurik@linux.ibm.com> <5d8c598e-31de-7973-df51-e913bba54587@redhat.com> From: "Dov Murik" Message-ID: Date: Tue, 8 Jun 2021 12:57:00 +0300 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.11.0 MIME-Version: 1.0 In-Reply-To: X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: 3870zxRXeEaR65J6kZ54G2n1fTPROYoj X-Proofpoint-GUID: kJ82eeglsMXIjrmGRVY1fRCpvUEBAqYp X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.391,18.0.761 definitions=2021-06-08_08:2021-06-04,2021-06-08 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 suspectscore=0 clxscore=1015 impostorscore=0 mlxscore=0 bulkscore=0 mlxlogscore=999 malwarescore=0 lowpriorityscore=0 priorityscore=1501 phishscore=0 spamscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2104190000 definitions=main-2106080063 Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit On 04/06/2021 14:26, Laszlo Ersek wrote: > On 06/04/21 12:30, Dov Murik wrote: > ... >> >>> [Ard, please see this one question:] >>> >>> - A major complication for hashing all three of: kernel, initrd, >>> cmdline, is that the *fetching* of this triplet is split between two >>> places. (Well, it is split between *three* places in fact, but I'm >>> going to ignore LinuxInitrdDynamicShellCommand for now, because the >>> AmdSevX64 platform sets BUILD_SHELL to FALSE for production.) >>> >>> The kernel and the initrd are fetched in QemuKernelLoaderFsDxe, but >>> the command line is fetched in (both) QemuLoadImageLib instances. >>> This requires that all these modules be littered with hashing as >>> well, which I find *really bad*. Even if we factor out the actual >>> logic, I strongly dislike having *just hooks* for hashing in multiple >>> modules. >>> >>> Now, please refer to efc52d67e157 ("OvmfPkg/QemuKernelLoaderFsDxe: >>> don't expose kernel command line", 2020-03-05). If we first >>> >>> (a) reverted that commit, and >>> >>> (b) modified *both* QemuLoadImageLib instances, to load the kernel >>> command line from the *synthetic filesystem* (rather than directly >>> from fw_cfg), >>> >>> then we could centralize the hashing to just QemuKernelLoaderFsDxe. >>> >>> Ard -- what's your thought on this? >>> >> >> I understand there's agreement here, and that both this suggested >> change (use the synthetic filesystem) and my patch series (add hash >> verification) touch the same code areas. How do you envision this >> process in the mailing list? Seperate patch serieses with dependency? >> One long patch series with both changes? What goes first? > > Good point. I do have a kind of patch order laid out in my mind, but I > didn't think of whether we should have the patches in one patch series, > or in two "waves". > > OK, let's go with two patch sets. > > In the first set, we should just focus on the above steps (a) and (b). > Step (a) shouldn't be too hard. In step (b), you'd modify both > QemuLoadImageLib instances (two separate patches), replacing the > QemuFwCfgLib APIs for fetching the cmdline with > EFI_SIMPLE_FILE_SYSTEM_PROTOCOL and EFI_FILE_PROTOCOL APIs. > > Speaking from memory, the synthetic filesystem has a unique device path, > so the first step would be calling gBS->LocateDevicePath(), for finding > SimpleFs on the unique device path. Once you have the SimpleFs > interface, you can call OpenVolume, then open the "cmdline" file using > the EFI_FILE_PROTOCOL output by OpenVolume. > > Once we merge this series (basically just three patches), there is no > QemuFwCfgLib dependency left in either QemuLoadImageLib instance, I > reckon. I started working on that, and managed to remove all QemuFwCfg* calls in the main path of QemuLoadKernelImage (so far working on X86QemuLoadImageLib.c). That works fine: I read the content of the "cmdline" synthetic file, and I check the size of the synthetic "initrd" file. I used Library/FileHandleLib.h; I hope that's fine. However, there's another path (which I don't reach with my test setup), which is the call to QemuLoadLegacyImage, which has a lot of calls to QemuFwCfg* in its body. Am I expected to change that legacy path as well? Or is it in a "it's working don't touch" state? If I modify this, how do I test it? Thanks for the guidance, -Dov