From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from list by lists.gnu.org with archive (Exim 4.90_1) id 1ny5LB-0002DJ-GW for mharc-grub-devel@gnu.org; Mon, 06 Jun 2022 01:31:49 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:34170) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ny5LA-0002D6-Gv for grub-devel@gnu.org; Mon, 06 Jun 2022 01:31:48 -0400 Received: from out1-smtp.messagingengine.com ([66.111.4.25]:59681) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ny5L8-0002dy-D2 for grub-devel@gnu.org; Mon, 06 Jun 2022 01:31:48 -0400 Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.nyi.internal (Postfix) with ESMTP id E1B5E5C00D1; Mon, 6 Jun 2022 01:31:45 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute4.internal (MEProxy); Mon, 06 Jun 2022 01:31:45 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pks.im; h=cc:cc :content-type:date:date:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:sender:subject :subject:to:to; s=fm2; t=1654493505; x=1654579905; bh=RkcyNmuU7F TUVlZnzJLCTO909g0F731Ghdb0rX0Jb9o=; b=WVyu5joFaXaz5y41IvPtaqr7kx tT6Dh/m70Ny3f0xqvEFiC34BWSc6uYFoeAgkI5EuygxhFJsEcVu2Y6irrjlMkJMT 9M8BWGk3wtD0nQ0hwH0mPa2NH8XH1eieFjK9+c3b6uapkOPH9gNpG1IqnRiM9eFE Vu8MB7QzvTMzk5V0xfCdboZmZeiKNWNcyxx05kLptapAgZM/ZM1o/zaFsZfvl0qB 50rqH6IWyN4S0921rhdbjQZ7jwj9staQVztziaAgH4iJMf/nOtuR/p/0FlscWC9c +FxalpjTJ8ravnRzsaf0ayIiirVeEeDY3qk7/6fXLvsKvrGo1NVk+LnlFK2g== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-type:date:date:feedback-id :feedback-id:from:from:in-reply-to:in-reply-to:message-id :mime-version:references:reply-to:sender:subject:subject:to:to :x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm2; t=1654493505; x=1654579905; bh=RkcyNmuU7FTUVlZnzJLCTO909g0F 731Ghdb0rX0Jb9o=; b=lKA8BmetlSJIimjmnEsK0fCyhGBvjCwnk1sL6+C1Tyie 5IiJd5VFwT0nslpw2nNQGVxtf1GT3SHPbsYwfCQ+CswboEq9nsveQh3FWsvGaKCf WoFjylYzQ7Zbvqf0ASTabR1lF5SCoF0iNOJ/5fgpJ+HDCzOGF7/YjdRltlc9DVhF 9TbkZdGDWXuqnQ4PK6AlFDY7U0rji8y0WD8Fz4OyZl/fkLBrVTJCD0C9FGFU6YQ4 r3wIVYCDvhwssi8k0A03nEVEyswVmYsvj7exf8Jd8HE1Y9leELW+AOf29fIZ608i CWQ3x7Dn3OFujKV7PSORSPy5k22WFmmJVpYSyOdqhQ== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvfedruddtuddgleeiucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne gfrhhlucfvnfffucdludejmdenucfjughrpeffhffvvefukfhfgggtuggjsehgtderredt tddvnecuhfhrohhmpefrrghtrhhitghkucfuthgvihhnhhgrrhguthcuoehpshesphhksh drihhmqeenucggtffrrghtthgvrhhnpeefveefudelffffudffleetffejtddvjeduueef tdegteeukeevffdtffduffffieenucffohhmrghinhepghhnuhdrohhrghdpphhkshdrih hmnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomhepphhs sehpkhhsrdhimh X-ME-Proxy: Feedback-ID: i197146af:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Mon, 6 Jun 2022 01:31:44 -0400 (EDT) Received: from localhost (tanuki [10.192.0.23]) by vm-mail.pks.im (OpenSMTPD) with ESMTPSA id 82daf2f2 (TLSv1.3:TLS_AES_256_GCM_SHA384:256:NO); Mon, 6 Jun 2022 05:31:43 +0000 (UTC) Date: Mon, 6 Jun 2022 07:32:40 +0200 From: Patrick Steinhardt To: Glenn Washburn Cc: The development of GNU GRUB , Josselin Poiret , Pierre-Louis Bonicoli , Daniel Kiper Subject: Re: [PATCH v2 3/3] grub-core/kern/disk.c: handle LUKS2 devices Message-ID: References: <20220329103158.4096409-1-pierre-louis.bonicoli@libregerbil.fr> <20220329103158.4096409-4-pierre-louis.bonicoli@libregerbil.fr> <20220504164708.5322406a@crass-HP-ZBook-15-G2> <87ee12tpsd.fsf@jpoiret.xyz> <20220510225552.1b9aaa94@crass-HP-ZBook-15-G2> <20220605134318.075d9e87@crass-HP-ZBook-15-G2> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="1xrORIY50Czhwe16" Content-Disposition: inline In-Reply-To: <20220605134318.075d9e87@crass-HP-ZBook-15-G2> Received-SPF: pass client-ip=66.111.4.25; envelope-from=ps@pks.im; helo=out1-smtp.messagingengine.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: The development of GNU GRUB List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 06 Jun 2022 05:31:48 -0000 --1xrORIY50Czhwe16 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Sun, Jun 05, 2022 at 01:43:18PM -0500, Glenn Washburn wrote: > On Sun, 29 May 2022 09:09:38 +0200 > Patrick Steinhardt wrote: >=20 > > On Tue, May 10, 2022 at 10:55:52PM -0500, Glenn Washburn wrote: > > > On Mon, 09 May 2022 22:27:30 +0200 > > > Josselin Poiret wrote: > > >=20 > > > > Hello everyone, > > > >=20 > > > > Glenn Washburn writes: > > > >=20 > > > > > I don't really like this, but it gets the job done and is a work-= around > > > > > for a peculiarity of the LUKS2 backend. The cheat mount code for > > > > > cryptodisk does only calls scan() and not recover_key(). For LUKS= 1 scan > > > > > will return a grub_cryptodisk_t with log_sector_size set, but LUK= S2 > > > > > will not. This is because for LUKS1 the log_sector_size is consta= nt > > > > > (LUKS1 also sets most of the other properties of the cryptodisk d= evice, > > > > > like crypto algorithm, because they are in the binary header). Ho= wever, > > > > > for LUKS2 the sector size (along with other properties) is in the= json > > > > > header, which isn't getting parsed in scan().=20 > > > > > > > > > > For single segment LUKS2 containers, scan() could get the sector = size > > > > > from the json segment object. The LUKS2 spec says that normal LUK= S2 > > > > > devices are single segment[1], so this should work in the the cas= es the > > > > > care about (currently). scan() would not be able to fill in the o= ther > > > > > properties, like crypto algorithm, because that depends on the ke= yslot > > > > > used, which needs key recovery to be determined. To avoid parsing= the > > > > > json data twice, once in scan() and once in recover_key(), which = should > > > > > be avoided, the parsed json object could be put in the grub_crypt= odisk_t > > > > > in scan(), and used and freed in recover_key(). We'd probably als= o want > > > > > to add a way for grub_cryptodisk_t objects to get cleaned up by t= he > > > > > backend using them, so that the json object could be freed even if > > > > > recover_key() is never called. > > > > > > > > > > I think the above is the real fix, a moderate amount more work, a= nd not > > > > > something I'd expect Pierre-Louis to take up. So if we're not goi= ng to > > > > > do this to get this functionality to work, we'll need a hack to g= et it > > > > > working. However, I'd prefer a different one. > > > > > > > > > > I've not tested this, but it seems to me that we can set the > > > > > log_sector_size field to GRUB_DISK_SECTOR_BITS _if_ it equals zer= o in > > > > > grub_cryptodisk_cheat_insert(). This limits the hack to only GRUB > > > > > host/user-space code. > > > >=20 > > > > Regarding these last lines, it's also possible to directly ask dm f= or > > > > the actual sector size when cheatmounting, as well as the crypto > > > > algorithm, bypassing the whole issue of parsing the json and findin= g the > > > > right slot. This is roughly what's done in patch 2 of [1], maybe t= his > > > > workaround would be more to your liking? > > >=20 > > > Hah! Yes, thanks for reminding me. I forgot I'd suggested this and its > > > a better approach than what I suggested above. And probably the one I= 'd > > > support, but I need to more thoroughly take a look at it. > > >=20 > > > > I've distributed this patch to several people that were having issu= es on > > > > GNU Guix and they've been happily using LUKS2 with GRUB with it. > > >=20 > > > Yes, this does work and too much of a hack as-is. Regardless, your > > > contribution is appreciated. I'd like to get your patch with the GRUB= fs > > > tests merged. Do you want to make the changes I suggested and send a = new > > > patch here? If not, at some point I'll probably make them myself and > > > submit it to the list. > > >=20 > > > > [1] https://lists.gnu.org/archive/html/grub-devel/2021-12/msg00079.= html > > > > (20211211122945.6326-1-dev@jpoiret.xyz) > > >=20 > > > Glenn > >=20 > > I very much agree that we should land the test-patches regardless of > > what happens to the rest: they cover an important test gap. > >=20 > > Other than that the patches look sane to me. The biggest question to me > > is which of the three patch series we want to include in the end: > >=20 > > - Yours has the extra benefit of added tests, but these can go in > > independently. > >=20 > > - Josselin's patches [1] have the benefit that they try to derive a > > "proper" sector size via device-mapper. > >=20 > > - My own patches [2] include two additional patches: one to strip > > dashes of the UUID so that findfs is easier to use and the same > > across LUKS and LUKS2. And one out-of-bounds copy of the UUID in > > LUKS. Both are kind of orthogonal though. One more thing I like > > better about this patch series is that it clearly discerns LUKS > > and LUKS2 devices. > >=20 > > So ultimately it feels like all of the patch series have their own > > advantages, but they should be combinable. The tests and my own > > orthogonal patches can be split out. And if we combined the approach in > > Josselin's patches to use DM to get the sector size with a proper > > conceptual split of LUKS and LUKS2 as in my own patches then I'd be more > > than happy. >=20 > I think[1] Fabian's patch[2] for getting sector size is actually better > and more general than using DM. My preference is for a combination of > Fabian's and Josselin's patches. I also noted that my own two orthogonal patches to fix the out-of-bounds copy and dash-stripping have landed in `master` already. So I agree that a combination of the other two series would be best. Patrick > Your response made me question how we could get the correct luks module > to put in the grub config if we don't have a separate > GRUB_DEV_ABSTRACTION_LUKS2. But actually that code uses the command > "grub-probe --device $@ --target=3Dabstraction, which calls > probe_abstraction() -> grub_util_cryptodisk_get_abstraction(), which > then uses the "modname" member of the grub_cryptodisk_t device. So > GRUB_DEV_ABSTRACTION_* is not used, nor needed in this case. When you > do make use of GRUB_DEV_ABSTRACTION_LUKS2, its just to duplicate > existing code. I think its best to not have a separate > GRUB_DEV_ABSTRACTION_LUKS2. >=20 > Glenn >=20 > [1] https://lists.gnu.org/archive/html/grub-devel/2022-05/msg00184.html > [2] https://lists.gnu.org/archive/html/grub-devel/2021-08/msg00017.html >=20 > >=20 > > I may very well be biased here though given that one of the patch series > > is my own. > >=20 > > Patrick > >=20 > > [1]: <20220520182039.21654-1-dev@jpoiret.xyz> > > [2]: --1xrORIY50Czhwe16 Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAABCgAdFiEEF9hrgiFbCdvenl/rVbJhu7ckPpQFAmKdkXcACgkQVbJhu7ck PpQljw/8DIgLabkUg94jHsf5e9ZDTGQseQLIuwU7eu+twZB78js9o8kI7Htt5/Df gY9Ayesu9f/2J9w0fHt6VvTb6niFAW2McnUMwDmdh0lRa7KqRamUZZQrqz/45nPC YcGFYAn3YHQNH6F1PYRI/G6mN8jXUDDLXCzSuxOLHL5JzUmw/JR+AZ+Wr4IWwfRF bOVemqeqg6Kxi6ySVbU3NGvsRsIvdNu7xGn6ImlPUBjZ3MFKOFOI173YzPcowNhy YsDdznoo1TvalRGMlNsfw9/L4B+KqTjw0RcgGeykXyjpMIxm4Vg1DnoqXKL7bAxg RIwB2VjSH5LNVL/P9WLqEb3/iJ9CmZcQ9kw0Bs1kOG1V+qzRW5Th7WfqwvPpPgFL IjwjWY1HZ+5iVzA7wUeE8Tc0Bh1Ww4v1MMULCnATHTK77Bq+VuiqLt6sSYjvkpbq qSOPonLFHlsU65sm+9chmfOKUZ1UuVrOD8dNHlkkuy5vvFeFLoig/R8aj7KR6yGA c4GMLgFqVi1MKzGn3lTVV668E7PedTou2ZiJubbkl6PPYMpVSsj+xitsgVYhpuMk aOyP1gfp6QLZLgWs6ebvmDL4lCxFwE3WMqH3mCkfffQLlL7jlAZJiDFdJbypvQ4l YQGrOcfheHgJpsl95U9R9AAx7WQ16mJ+fjKYTUlHwkSB8TrYeL0= =6jAN -----END PGP SIGNATURE----- --1xrORIY50Czhwe16--