From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp2.migadu.com ([2001:41d0:303:e224::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms13.migadu.com with LMTPS id aC+9I87882YbMwAAe85BDQ:P1 (envelope-from ) for ; Wed, 25 Sep 2024 12:06:38 +0000 Received: from aspmx1.migadu.com ([2001:41d0:303:e224::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp2.migadu.com with LMTPS id aC+9I87882YbMwAAe85BDQ (envelope-from ) for ; Wed, 25 Sep 2024 14:06:38 +0200 X-Envelope-To: larch@yhetil.org Authentication-Results: aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=debbugs.gnu.org header.s=debbugs-gnu-org header.b=g+XMuzyy; dkim=fail ("headers rsa verify failed") header.d=rimm.ee header.s=herman header.b=lg93xlug; spf=pass (aspmx1.migadu.com: domain of "guix-patches-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-patches-bounces+larch=yhetil.org@gnu.org"; dmarc=pass (policy=none) header.from=gnu.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1727265998; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding:resent-cc: resent-from:resent-sender:resent-message-id:in-reply-to:in-reply-to: references:references:list-id:list-help:list-unsubscribe: list-subscribe:list-post:dkim-signature; bh=/0JKAnM5t64THUuoT4qiKSOCSq+rdBW2bp9hPc4an08=; b=tl8etP2igp7O7xCq8oRlR8zT/6CldMd9KlkIzHQ3F6kZ8IPAQScwYK8LUL5GhEyzeEunL8 T9fq3oLERBupuniwDBN7CQvAe5UH1am5yE2pruo53+gvgKIO/UvRAzt6BZoB4/Pyq/5Knx EtQoXPMDGjTEDJk5XetNqtV66FJLNU7CuziMJBff+zk3hZWW5vQmjoU7wxUkDmVziGyLrT oYrgNCS8Qu0aLUYQFh3rnPXEPDe1GbYtxQGV56TqpH3JeneV/Xzi1Ai8uDxhq+K6HOCdya BKuindsGX0qL1fKQrF/t9/kfhUf7DhShLYTpKRCrZaNu7BU6Iq7hIoOQYzrWyg== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1727265998; a=rsa-sha256; cv=none; b=kGNnYcaBA8UQ44VqvVEtozSvUBYlg1ExcIKPJr83PmJtm0zz/Eo5F2/DiNdUa3p9NMWFvz p+zvqB/X/ThQwRBl5y5i7umhZ3rSnfv8ZaT9qJRUXVP294dC9EH63o7Is9nhBJsa4mJQVe TngBTGtPWPI6NvtM/IPcclXxljOP2UiXdrK/HS3KadUxlYtaFO6TKZwWnLoDAx++a97Cvh l88tUBq5zwGHsHVCl5cMWZ1KlG6Jh7FSBMH2SRgPMWQQ9WXqU100EY7n3WwlnytZ5Mkmfv x41n/XJqcKqUqZeG26bCFl3EJ6c7GqlZKI6++6M/aek5EsoLHur73ZO7nhJGlg== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=debbugs.gnu.org header.s=debbugs-gnu-org header.b=g+XMuzyy; dkim=fail ("headers rsa verify failed") header.d=rimm.ee header.s=herman header.b=lg93xlug; spf=pass (aspmx1.migadu.com: domain of "guix-patches-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-patches-bounces+larch=yhetil.org@gnu.org"; dmarc=pass (policy=none) header.from=gnu.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id 0C1E86568C for ; Wed, 25 Sep 2024 14:06:37 +0200 (CEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1stQ4c-0004m3-Qg; Wed, 25 Sep 2024 07:20:46 -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 ) id 1stQ4a-0004ek-UL for guix-patches@gnu.org; Wed, 25 Sep 2024 07:20:45 -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 ) id 1stQ4Z-0004zM-0m; Wed, 25 Sep 2024 07:20:43 -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:References:In-Reply-To:Date:From:To:Subject; bh=/0JKAnM5t64THUuoT4qiKSOCSq+rdBW2bp9hPc4an08=; b=g+XMuzyyXxiZ+Ky5xlWgDB+ssUd4TackmMSZMIQ5NPHFRxQcGjFeXXCn1686m1P9L1FEl3svXXdjYo0dkdt6tyYtUAc6ztql4JiVNudLVOFSf1RdPo5pfrU3ZVkAuAJqa/Npq26wJDJ7k0/s7AAE991qxZgmqjCj3ndb0EbzKywpOwULWOqeXmurcYtAc8oFVepx6csMRmsWdlCT/HTimKM74sRSu8Wxb5fzGhqEMnBU8gkg0IxjfoqiXMJ9Jid/TgHqZ2I/fus3CcfEWD6nZuikzqjNNOelO9fmROHfXSVCnwd+or3g9+UZ8Ib1VrnFOcLPy06tz7zale9v1l8bSQ==; Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1stQ4v-0001eR-Dd; Wed, 25 Sep 2024 07:21:05 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#68524] [PATCH v3 5/5] gnu: bootloaders: Add uki-efi-bootloader. Resent-From: Herman Rimm Original-Sender: "Debbugs-submit" Resent-CC: pelzflorian@pelzflorian.de, lilah@lunabee.space, ludo@gnu.org, maxim.cournoyer@gmail.com, guix-patches@gnu.org Resent-Date: Wed, 25 Sep 2024 11:21:05 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 68524 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 68524@debbugs.gnu.org Cc: Lilah Tascheter , Florian Pelz , Lilah Tascheter , Ludovic =?UTF-8?Q?Court=C3=A8s?= , Maxim Cournoyer X-Debbugs-Original-Xcc: Florian Pelz , Lilah Tascheter , Ludovic =?UTF-8?Q?Court=C3=A8s?= , Maxim Cournoyer Received: via spool by 68524-submit@debbugs.gnu.org id=B68524.17272632315923 (code B ref 68524); Wed, 25 Sep 2024 11:21:05 +0000 Received: (at 68524) by debbugs.gnu.org; 25 Sep 2024 11:20:31 +0000 Received: from localhost ([127.0.0.1]:57501 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1stQ4M-0001Wb-PY for submit@debbugs.gnu.org; Wed, 25 Sep 2024 07:20:31 -0400 Received: from 81-205-150-117.fixed.kpn.net ([81.205.150.117]:50673 helo=email.rimm.ee) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1stQ4F-0001Sq-Ts for 68524@debbugs.gnu.org; Wed, 25 Sep 2024 07:20:25 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rimm.ee; s=herman; t=1727262782; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=/0JKAnM5t64THUuoT4qiKSOCSq+rdBW2bp9hPc4an08=; b=lg93xlugl8YwXA/YZXjnrmnwZ/J8lGc+/cV9fONAuPCQefQ7uVN+jbRipwMbi9qrvaxfgm tAdgbi7nEW4Jj7hG2MnnPJDMB6XA8VSkpmJLCs4U+l566lI7YkRHtEnjIetSTXkOizknRy zAoJ4mrV87UsAK0aaxw1zHogzEtG29HTyxBFi3IF01brPtWhHY7iuAJVWDfegHXFx5xjBi QNa29ooFnRjhT5OKo5wFLnI7HnkOHpHfV0j6pBWSts3z55YZMg5eINV5Ud8lpZP+qSFgAV 8HFqrVwwjs6oJrNpMlYS06mze9YfM6aSwweW2LmB6vuzRFK3VbpKbNocbpmN6Q== Received: by 81-205-150-117.fixed.kpn.net (OpenSMTPD) with ESMTPSA id dd08b030 (TLSv1.3:TLS_CHACHA20_POLY1305_SHA256:256:NO); Wed, 25 Sep 2024 11:13:02 +0000 (UTC) Date: Wed, 25 Sep 2024 13:12:03 +0200 Message-ID: X-Mailer: git-send-email 2.45.2 In-Reply-To: References: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-to: Herman Rimm X-ACL-Warn: , Herman Rimm via Guix-patches From: Herman Rimm via Guix-patches via Errors-To: guix-patches-bounces+larch=yhetil.org@gnu.org Sender: guix-patches-bounces+larch=yhetil.org@gnu.org X-Migadu-Flow: FLOW_IN X-Migadu-Country: US X-Migadu-Scanner: mx12.migadu.com X-Migadu-Spam-Score: -5.52 X-Migadu-Queue-Id: 0C1E86568C X-Spam-Score: -5.52 X-TUID: zulAIupJ16yZ From: Lilah Tascheter * gnu/bootloader.scm (): New keypair field. * gnu/bootloader/uki.scm: New file. * gnu/local.mk (GNU_SYSTEM_MODULES): Add bootloader/uki.scm. * doc/guix.texi (Bootloader Configuration): Document UKI bootloader. Change-Id: I2097da9f3dd35137b3419f6d0545de26d53cb6da --- doc/guix.texi | 25 +++++++++- gnu/bootloader.scm | 3 ++ gnu/bootloader/uki.scm | 106 +++++++++++++++++++++++++++++++++++++++++ gnu/local.mk | 1 + 4 files changed, 133 insertions(+), 2 deletions(-) create mode 100644 gnu/bootloader/uki.scm diff --git a/doc/guix.texi b/doc/guix.texi index 93be87d3cc..56d5b462c2 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -42486,6 +42486,24 @@ Bootloader Configuration @item @code{extlinux-gpt-bootloader} This is the same as above, but for systems with a GPT partition table. +@cindex Secure Boot, UEFI +@vindex uki-efi-bootloader +@item @code{uki-efi-bootloader} +Makes and installs UKI images for UEFI systems. Requires an @code{'esp} +target providing a @code{path} to the mount point of the EFI System +Partition. Not all system generations may be available with this +option, as UKI images contain the entire kernel and initramfs, and ESPs +tend to be small. + +Full disk encryption with @code{uki-efi-bootloader} only requires a +single password entry with fast decryption, in contrast to GRUB2 +requiring a second password entry with slow, LUKS1-only decryption. + +This is the only bootloader to currently support UEFI Secure Boot, when +configured as below. + +[THE CONFIGURATION BELOW] + @cindex ARM, bootloaders @cindex AArch64, bootloaders @vindex u-boot-a20-olinuxino-lime-bootloader @@ -42854,8 +42872,11 @@ Bootloader Configuration @end lisp @item @code{chain-loader} (default: @code{#f}) -Varies slightly depending on bootloader. For @code{grub}, this is anything that -the @code{chainloader} directive can accept +Varies slightly depending on bootloader. For @code{grub}, this is +anything that the @code{chainloader} directive can accept +(@pxref{Chain-loading,,, grub, GNU GRUB manual}). For @code{uki-efi}, +this is any efi binary to be installed alongside the system. The +following is an example of chainloading a different GNU/Linux system. @lisp (bootloader diff --git a/gnu/bootloader.scm b/gnu/bootloader.scm index 5e4578add0..ae7f20832e 100644 --- a/gnu/bootloader.scm +++ b/gnu/bootloader.scm @@ -100,6 +100,7 @@ (define-module (gnu bootloader) bootloader-configuration-default-entry bootloader-configuration-efi-removable? bootloader-configuration-32bit? + bootloader-configuration-keypair bootloader-configuration-timeout bootloader-configuration-keyboard-layout bootloader-configuration-theme @@ -546,6 +547,8 @@ (define-record-type* (default #f)) ;bool (32bit? bootloader-configuration-32bit? (default #f)) ;bool + (keypair bootloader-configuration-keypair + (default #f)) ;(cert . priv) pair (timeout bootloader-configuration-timeout (default 5)) ;seconds as integer (keyboard-layout bootloader-configuration-keyboard-layout diff --git a/gnu/bootloader/uki.scm b/gnu/bootloader/uki.scm new file mode 100644 index 0000000000..848b7618e9 --- /dev/null +++ b/gnu/bootloader/uki.scm @@ -0,0 +1,106 @@ +;;; GNU Guix --- Functional package management for GNU +;;; Copyright © 2024 Lilah Tascheter +;;; +;;; This file is part of GNU Guix. +;;; +;;; GNU Guix is free software; you can redistribute it and/or modify it +;;; under the terms of the GNU General Public License as published by +;;; the Free Software Foundation; either version 3 of the License, or (at +;;; your option) any later version. +;;; +;;; GNU Guix is distributed in the hope that it will be useful, but +;;; WITHOUT ANY WARRANTY; without even the implied warranty of +;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +;;; GNU General Public License for more details. +;;; +;;; You should have received a copy of the GNU General Public License +;;; along with GNU Guix. If not, see . + +(define-module (gnu bootloader uki) + #:use-module (gnu bootloader) + #:use-module (gnu packages bootloaders) + #:use-module (gnu packages efi) + #:use-module (gnu packages linux) + #:use-module (gnu system boot) + #:use-module (guix gexp) + #:use-module (guix diagnostics) + #:use-module (guix i18n) + #:use-module (guix records) + #:use-module (ice-9 match) + #:export (uki-efi-bootloader)) + +;; TODO: Support 32bit/mixed-mode UEFI. May be relevant: +;; https://github.com/systemd/systemd/issues/17056 +(define (menu-entry+bootcfg->builder entry bootcfg) + (match-menu-entry entry + (label linux linux-arguments initrd chain-loader) + (match-bootloader-configuration bootcfg (32bit? theme keypair) + (cond + ;; Support chainloader in order to allow arbitrary signed EFI + ;; binaries. + (chain-loader + (match keypair + ((cert key) + #~(lambda (dest) + (invoke/quiet #+(sbsigntools "/bin/sbsign") + "--cert" #$cert "--key" #$key + "--output" dest #$chain-loader) + (invoke/quiet #+(sbsigntools "/bin/sbverify") + "--cert" #$(car keypair) dest))) + (#f #~(lambda (dest) (copy-file #$chain-loader dest))))) + (linux + (let* ((arch (efi-arch #:32? 32bit?)) + (stub (file-append systemd-stub "/libexec/linux" arch + ".efi.stub"))) + #~(lambda (dest) + (invoke/quiet + #+(file-append ukify "/bin/ukify") "build" + "--output" dest "--linux" #$linux "--initrd" #$initrd + "--cmdline" (string-join (list #$@linux-arguments)) + "--os-release" #$label "--stub" #$stub + "--efi-arch" #$arch + #$@(if theme #~("--splash" #$theme) '()) + #$@(match keypair + ((cert key) + #~("--secureboot-certificate" #$cert + "--secureboot-private-key" #$key)) + (#f '())))))) + (else + (leave + (G_ "uki-efi-bootloader doesn't support multiboot"))))))) + +;; We cannot use Guix's build system to make UKI images for two reasons: +;; 1. signing is necessarily non-reproducable, especially since keys +;; should not be in the store, or else risk being publically accessible. +;; 2. Menu-entries may reference files which do not exist in the store. +(define* (install-uki #:key + bootloader-config + current-boot-alternative + old-boot-alternatives + #:allow-other-keys) + (define* (menu-entry->plan entry num #:optional (prefix "menu-entry")) + #~(cons* #$(menu-entry+bootcfg->builder entry bootloader-config) + #$(string-append prefix "-" (number->string num) ".efi") + #$(menu-entry-label entry))) + + (define (boot-alternative->plan alt) + (menu-entry->plan (boot-alternative->menu-entry alt) + (boot-alternative-generation alt) + "generation")) + + (install-efi + bootloader-config + (let ((entries + (bootloader-configuration-menu-entries bootloader-config))) + #~(list #$(boot-alternative->plan current-boot-alternative) + #$@(map menu-entry->plan entries (iota (length entries))) + #$@(map boot-alternative->plan old-boot-alternatives))))) + +(define uki-efi-bootloader + (bootloader + (name 'uki-efi) + (default-targets (list (bootloader-target + (type 'vendir) + (offset 'esp) + (path "EFI/Guix")))) + (installer install-uki))) diff --git a/gnu/local.mk b/gnu/local.mk index e2d32d4fbf..507ca26dfc 100644 --- a/gnu/local.mk +++ b/gnu/local.mk @@ -94,6 +94,7 @@ GNU_SYSTEM_MODULES = \ %D%/bootloader/extlinux.scm \ %D%/bootloader/u-boot.scm \ %D%/bootloader/depthcharge.scm \ + %D%/bootloader/uki.scm \ %D%/ci.scm \ %D%/compression.scm \ %D%/home.scm \ -- 2.45.2