Message ID | 87ldszqp0s.fsf@wolfsden.cz |
---|---|
State | New |
Headers |
Return-Path: <guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org> X-Original-To: patchwork@mira.cbaines.net Delivered-To: patchwork@mira.cbaines.net Received: by mira.cbaines.net (Postfix, from userid 113) id D156027BBE9; Thu, 20 Mar 2025 23:09:38 +0000 (GMT) X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-6.8 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_ADSP_ALL,DKIM_SIGNED,DKIM_VALID,MAILING_LIST_MULTI, RCVD_IN_DNSWL_BLOCKED,RCVD_IN_VALIDITY_CERTIFIED,RCVD_IN_VALIDITY_RPBL, RCVD_IN_VALIDITY_SAFE,SPF_HELO_PASS,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.6 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTPS id 1DACF27BBE2 for <patchwork@mira.cbaines.net>; Thu, 20 Mar 2025 23:09:36 +0000 (GMT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from <guix-patches-bounces@gnu.org>) id 1tvP0e-0006i7-29; Thu, 20 Mar 2025 19:09:08 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from <Debian-debbugs@debbugs.gnu.org>) id 1tvP0a-0006he-70 for guix-patches@gnu.org; Thu, 20 Mar 2025 19:09:04 -0400 Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from <Debian-debbugs@debbugs.gnu.org>) id 1tvP0Z-0004VB-Q8 for guix-patches@gnu.org; Thu, 20 Mar 2025 19:09:03 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=debbugs.gnu.org; s=debbugs-gnu-org; h=MIME-Version:Date:References:In-Reply-To:From:To:Subject; bh=sXR+WDdQdloRXKx52H+EXeA/ta0iXrHDPblGmCDz5cM=; b=QpL9/npHMJ+73HsdwZU6wHiLoDyVT6+emlq/hL8HHdyh6tcjcCEqiexrwlWQ857XmwCxVWpYoXwaIyIm6WYiXsZgeDbDxBKQNBz4iPEw1JfLAZRlSr1Ldh3ynGEMlCQB46LOOQZ6hSwBgSJggXjmMtqoyLFh0+GYa+RGCqQGMBHkiaHKzaf0tpC/QtjM0Rfe9KV7uTnHyGOyXJENCRhBa35GBBnD22h60maxGtTeftPPZRFQuHdgOlNIAI8xHzLEczAbnQR4PO0ZL++F2WHPw3Z3auDv2AnSt8deKwK1QrIz2qcKEHM/YcCO8tA218cj32gaEgHPDxzaynDAYDgnSg==; Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from <Debian-debbugs@debbugs.gnu.org>) id 1tvP0Z-0000PC-Bg for guix-patches@gnu.org; Thu, 20 Mar 2025 19:09:03 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#73654] [PATCH v4] mapped-devices: luks: Support passing --allow-discards during open Resent-From: Tomas Volf <~@wolfsden.cz> Original-Sender: "Debbugs-submit" <debbugs-submit-bounces@debbugs.gnu.org> Resent-CC: guix-patches@gnu.org Resent-Date: Thu, 20 Mar 2025 23:09:03 +0000 Resent-Message-ID: <handler.73654.B73654.17425120941248@debbugs.gnu.org> Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 73654 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch moreinfo To: Maxim Cournoyer <maxim.cournoyer@gmail.com> Cc: soeren@soeren-tempel.net, sisiutl@egregore.fun, ludo@gnu.org, 73654@debbugs.gnu.org, hako@ultrarare.space, GNU Debbugs <control@debbugs.gnu.org> Received: via spool by 73654-submit@debbugs.gnu.org id=B73654.17425120941248 (code B ref 73654); Thu, 20 Mar 2025 23:09:03 +0000 Received: (at 73654) by debbugs.gnu.org; 20 Mar 2025 23:08:14 +0000 Received: from localhost ([127.0.0.1]:59539 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <debbugs-submit-bounces@debbugs.gnu.org>) id 1tvOzj-0000Ji-MB for submit@debbugs.gnu.org; Thu, 20 Mar 2025 19:08:14 -0400 Received: from wolfsden.cz ([37.205.8.62]:35400) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from <~@wolfsden.cz>) id 1tvOze-0000IX-KE; Thu, 20 Mar 2025 19:08:09 -0400 Received: by wolfsden.cz (Postfix, from userid 104) id 780FB37930E; Thu, 20 Mar 2025 23:08:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=wolfsden.cz; s=mail; t=1742512084; bh=uE2TfdhWVDu4xZyXi2xYaibqfT72nZt2lWMviRzeqPc=; h=From:To:Cc:Subject:In-Reply-To:References:Date; b=EnKUQotjz4m4R5rZgpl07yMJAKPnj+VLXhScffWbHy4gRgZAI5/8pSJiPLCLaRmJS DGqnyiptqwArEgViUsFUda54SYLxXnDjapSLzs5PaWDWyLDGULMqf50mUGM40EoDlj MoYEQjbn1ZW01+FLD9U7AgwNWIWODpUQWs8btzPZ6m+6KQ6ECt9ZuLf5kD0EuhWWej EZ4U7qlBzdG//uFGnLtLdcsplzyIlR2ZszWhE8frETEEJteTU6/VRDcZI47e9hmzxb R5Aeu7LzZDVCLs+I1ZLt7+v1Dbin821cuJAbSrukO7RsMuYo5ln+5nOkfH3BaTMex0 gfSvvZhamc4S7ZCT5APHwFdBUJ7ADfw5TEsHQBTcSQf7DodM/tKz/UPZRrEP31A58F UDs5/WN8ueRmhSrcSO0hmJkJqhczgBmtU8qnh3bxdAGy5ltQWqRY9TCHRjIXbWxQwY bKa91s/OKA6ABzpkO8RfPwS/DpLe5/H4z3dOvBP69IxKV+UAjZhB2ZOA8rNCP1atPL gN+9RD2EiH3vV+GrW3eepO+WGBwP9kK9bKmiiJF4IpoIb+IJDjrRUVKk46oAzG3kg2 mbRq1CVLPArFzKbdrPWdEMSszjJ0FEQO8GQg1YAGHYryrDqNIEDbUJjtcUQjNpW8K8 ziIZ2VSvSCLHY7vO4foCnJUg= Received: from localhost (unknown [128.0.188.242]) by wolfsden.cz (Postfix) with ESMTPSA id 846AC3780BC; Thu, 20 Mar 2025 23:08:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=wolfsden.cz; s=mail; t=1742512083; bh=uE2TfdhWVDu4xZyXi2xYaibqfT72nZt2lWMviRzeqPc=; h=From:To:Cc:Subject:In-Reply-To:References:Date; b=t/nf62KLPY1+hcqOt3SbRcM5nzhkzjXXqDkyu400su5oVp0MsCEEQ0OzdUYLLzgAR 6SlxkVTCdWg3QT64tBt2goICM2l6/KwgJtIYUfMGHMF12MNFe5LwE+Iw8t6suy1to6 Ff1MrpqNI8fiB3ArARnoshgi1Ptv6+bTt/LuUGoiGUW5GARUsIXmaq+ZW4LpNjmX4m Met9YqStjXDHNbr2qL+wK/TDDi0O4nWfzDQSq5DzNAEowcf6X9XN6lrGL+RY7MI0nf PCz2lKMQwHCyMd5sSuVIP9Ll/sJvtYW7ioztUT/ZtCp8/4oEXWTejZx4MHKb98wS5p 0eGRXNrp76R/YvYlpwcB4WYMRuYQ9e4OYtZ8cjsdMlC3CK/LGJ/EGbcgrNw3M5NBNt V/1gkWNNQ8axhcJ+oiVzoiuUbTiKJk3o8eUDJOqEl5WjB78bchtO83cOIjrds/HHEC 5LsESoBegQ7JrxpdcFn0TIjRXvRz1p2HTigZCZpkFtw0TqZhILfWT/t6Wkg53twcJs lyr4GSlSz6GJ8bK74V8/jRvJ7s1KyJ3KiMjdIdQEUjRaAYVRYYfObQL26pVNKnWYmq jupw8LpSzTJIh7Xw1Qt7pUgsp0jAwNLCplPG78x1YtLgnRZe9PWOb0YYUWr2+flqO7 8GE97XGIJeaMPXEHZe6QeTCk= From: Tomas Volf <~@wolfsden.cz> In-Reply-To: <87h63oqumz.fsf@gmail.com> (Maxim Cournoyer's message of "Thu, 20 Mar 2025 11:54:28 +0900") References: <94e28c2091f319bfdb681055b7e5bdafa0cb9120.1742125790.git.soeren@soeren-tempel.net> <87h63oqumz.fsf@gmail.com> Date: Fri, 21 Mar 2025 00:08:03 +0100 Message-ID: <87ldszqp0s.fsf@wolfsden.cz> User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: multipart/signed; boundary="=-=-="; micalg=pgp-sha512; protocol="application/pgp-signature" X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: guix-patches@gnu.org List-Id: <guix-patches.gnu.org> List-Unsubscribe: <https://lists.gnu.org/mailman/options/guix-patches>, <mailto:guix-patches-request@gnu.org?subject=unsubscribe> List-Archive: <https://lists.gnu.org/archive/html/guix-patches> List-Post: <mailto:guix-patches@gnu.org> List-Help: <mailto:guix-patches-request@gnu.org?subject=help> List-Subscribe: <https://lists.gnu.org/mailman/listinfo/guix-patches>, <mailto:guix-patches-request@gnu.org?subject=subscribe> Errors-To: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org Sender: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org X-getmail-retrieved-from-mailbox: Patches |
Series |
[bug#73654,v4] mapped-devices: luks: Support passing --allow-discards during open
|
|
Commit Message
Tomas Volf
March 20, 2025, 11:08 p.m. UTC
Maxim Cournoyer <maxim.cournoyer@gmail.com> writes: > tag 73654 + moreinfo > quit > > Hi! > > soeren@soeren-tempel.net writes: > >> From: Sören Tempel <soeren@soeren-tempel.net> >> >> * gnu/system/mapped-devices.scm (open-luks-device): Support opening >> LUKS devices with the --allow-discards option. >> * gnu/system/mapped-devices.scm (luks-device-mapping-with-options): >> Pass through the allow-discards? keyword argument. >> * doc/guix.texi (Mapped Devices): Update documentation for the >> luks-device-mapping-with-options procedure. >> >> Co-authored-by: Sisiutl <sisiutl@egregore.fun> > > I was about to apply it with the following cosmetic changes (mostly to > meet the 80 max column width): > >> --- >> Changes since v3: Fix replacement of “Solid State Disks” with “solid >> state disks” in doc/guix.texi. That is, only perform this replacement >> locally on the added text and not the whole document. >> >> doc/guix.texi | 11 +++++++++- >> gnu/system/mapped-devices.scm | 39 +++++++++++++++++++++-------------- >> 2 files changed, 33 insertions(+), 17 deletions(-) >> >> diff --git a/doc/guix.texi b/doc/guix.texi >> index b1b6d98e74..6eb9fcb8ee 100644 >> --- a/doc/guix.texi >> +++ b/doc/guix.texi >> @@ -18402,7 +18402,7 @@ Mapped Devices >> @code{dm-crypt} Linux kernel module. >> @end defvar >> >> -@deffn {Procedure} luks-device-mapping-with-options [#:key-file] >> +@deffn {Procedure} luks-device-mapping-with-options [#:key-file #:allow-discards?] >> Return a @code{luks-device-mapping} object, which defines LUKS block >> device encryption using the @command{cryptsetup} command from the >> package with the same name. It relies on the @code{dm-crypt} Linux >> @@ -18424,6 +18424,15 @@ Mapped Devices >> (type (luks-device-mapping-with-options >> #:key-file "/crypto.key"))) >> @end lisp >> + >> + >> +@code{allow-discards?} allows the use of discard (TRIM) requests for the >> +underlying device. This is useful for solid state drives. However, >> +this option can have a negative security impact because it can make >> +file system level operations visible on the physical device. For more >> +information, refer to the description of the @code{--allow-discards} >> +option in the @code{cryptsetup-open(8)} man page. >> + >> @end deffn >> >> @defvar raid-device-mapping >> diff --git a/gnu/system/mapped-devices.scm b/gnu/system/mapped-devices.scm >> index 931c371425..3a8f0d66fe 100644 >> --- a/gnu/system/mapped-devices.scm >> +++ b/gnu/system/mapped-devices.scm >> @@ -194,9 +194,10 @@ (define (check-device-initrd-modules device linux-modules location) >> ;;; Common device mappings. >> ;;; >> >> -(define* (open-luks-device source targets #:key key-file) >> +(define* (open-luks-device source targets #:key key-file allow-discards?) >> "Return a gexp that maps SOURCE to TARGET as a LUKS device, using >> -'cryptsetup'." >> +'cryptsetup'. When ALLOW-DISCARDS? is true, the use of discard (TRIM) requests is >> +allowed for the underlying device." >> (with-imported-modules (source-module-closure >> '((gnu build file-systems) >> (guix build utils))) ;; For mkdir-p >> @@ -234,17 +235,21 @@ (define* (open-luks-device source targets #:key key-file) >> (loop (- tries-left 1)))))) >> (error "LUKS partition not found" source)) >> source))) >> - ;; We want to fallback to the password unlock if the keyfile fails. >> - (or (and keyfile >> - (zero? (system*/tty >> - #$(file-append cryptsetup-static "/sbin/cryptsetup") >> - "open" "--type" "luks" >> - "--key-file" keyfile >> - partition #$target))) >> - (zero? (system*/tty >> - #$(file-append cryptsetup-static "/sbin/cryptsetup") >> - "open" "--type" "luks" >> - partition #$target))))))))) >> + (let ((cryptsetup-flags (cons* >> + "open" "--type" "luks" partition #$target >> + (if allow-discards? >> + '("--allow-discards") >> + '())))) >> + ;; We want to fallback to the password unlock if the keyfile fails. >> + (or (and keyfile >> + (zero? >> + (apply system*/tty >> + #$(file-append cryptsetup-static "/sbin/cryptsetup") >> + "--key-file" keyfile >> + cryptsetup-flags))) >> + (zero? (apply system*/tty >> + #$(file-append cryptsetup-static "/sbin/cryptsetup") >> + cryptsetup-flags)))))))))) >> >> (define (close-luks-device source targets) >> "Return a gexp that closes TARGET, a LUKS device." >> @@ -286,13 +291,15 @@ (define luks-device-mapping >> ((gnu build file-systems) >> #:select (find-partition-by-luks-uuid system*/tty)))))) >> >> -(define* (luks-device-mapping-with-options #:key key-file) >> +(define* (luks-device-mapping-with-options #:key key-file allow-discards?) >> "Return a luks-device-mapping object with open modified to pass the arguments >> into the open-luks-device procedure." >> (mapped-device-kind >> (inherit luks-device-mapping) >> - (open (λ (source targets) (open-luks-device source targets >> - #:key-file key-file))))) >> + (open (λ (source targets) >> + (open-luks-device source targets >> + #:key-file key-file >> + #:allow-discards? allow-discards?))))) >> >> (define (open-raid-device sources targets) >> "Return a gexp that assembles SOURCES (a list of devices) to the RAID device >> >> base-commit: f2b3c36bee8c232b026a66de93db38e13fbd7076 > > > But unfortunately it appears to hang at least the 'encrypted-root-os' > system test, which you can run like: > > $ make check-system TESTS=encrypted-root-os > [...] > cSeaBIOS (version 1.16.2/GNU Guix) > > > iPXE (https://ipxe.org) 00:03.0 CA00 PCI2.10 PnP PMM+0EFCB030+0EF0B030 CA00 > > > > Booting from Hard Disk... > GRUB loading.. > Welcome to GRUB! > > Enter passphrase for hd0,gpt2 (12345678-1234-1234-1234-123456789abc): > Attempting to decrypt master key... > lot 0 opened > C-c C-cmake: *** [Makefile:7562: check-system] Interrompre > > Would you have an idea of why this happens and how we could avoid the > hang in the test? I have deployed the patch to my secondary laptop, it hangs on real hardware as well. I am not sure it was testing before sending it. --8<---------------cut here---------------start------------->8--- Unbound variable: allow-discards? --8<---------------cut here---------------end--------------->8--- I assume #$ is missing. And indeed, this is enough to get my system to boot again: --8<---------------cut here---------------start------------->8--- --8<---------------cut here---------------end--------------->8--- I did not run the test case with the fix (it takes really long and I should go to sleep), I will leave it as an exercise to the author. > > Thanks,
--- a/gnu/system/mapped-devices.scm +++ b/gnu/system/mapped-devices.scm @@ -239,7 +239,7 @@ (define* (open-luks-device source targets #:key key-file allow-discards?) source))) (let ((cryptsetup-flags (cons* "open" "--type" "luks" partition #$target - (if allow-discards? + (if #$allow-discards? '("--allow-discards") '())))) ;; We want to fallback to the password unlock if the keyfile fails.