From patchwork Sat Nov 28 21:07:46 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Esa Jaaskela X-Patchwork-Id: 106262 Received: from mout-p-102.mailbox.org (mout-p-102.mailbox.org [80.241.56.152]) by mx.groups.io with SMTP id smtpd.msgproc01-g2.3294.1795900080595977665 for ; Sat, 28 Nov 2026 13:08:01 -0800 Authentication-Results: mx.groups.io; dkim=fail reason="dkim: body hash did not verify" header.i=@suomi24.fi header.s=MBO0001 header.b=xuSBBtud; spf=pass (domain: suomi24.fi, ip: 80.241.56.152, mailfrom: esa.jaaskela@suomi24.fi) Received: from smtp102.mailbox.org (smtp102.mailbox.org [IPv6:2001:67c:2050:b231:465::102]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519MLKEM768 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mout-p-102.mailbox.org (Postfix) with ESMTPS id 4jcNCx5GdNzKmBV; Sat, 28 Nov 2026 22:07:57 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suomi24.fi; s=MBO0001; t=1795900077; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=fwkH26HuSdk2L6/ZdJkXKjqsPxaovLX3Ul+DXD00c+Y=; b=xuSBBtudbCtbBHLF74hdfv06F4XcuM9/66Hn1LyTmYqz852a98y4MBzbt1xwmi94asGEcV wPRkNs9S3yyfkVC+CS4nQRMJ2NB8e8yHPzwrNGzhezpBjXGaFazIJxlHTIB3tEV15btxMZ wkMUvY1kkLo4HxngLgu2xZJaHiNjqdW12uGNckL7nHgh1lpYvM0SlVwtpe4rNughKJLsl0 /lJ5tx6tenAGxFCVtBWD0qJJrO5PPvUsA+8A+HDJtgRuo7ixpmn4jCSj8T0deuB5Rez1aM BfwTdlzSkZUCiQbGv3aDmH4i24e9ljrnDRMR4XZVigEC1niF/upJ4kdu3Nd2qA== Authentication-Results: outgoing_mbo_mout; dkim=none; spf=pass (outgoing_mbo_mout: domain of esa.jaaskela@suomi24.fi designates 2001:67c:2050:b231:465::102 as permitted sender) smtp.mailfrom=esa.jaaskela@suomi24.fi From: Esa Jaaskela To: yocto-patches@lists.yoctoproject.org Cc: Esa Jaaskela Subject: [meta-security][PATCH] dmverity: Check the root device before sleeping Date: Sat, 28 Nov 2026 23:07:46 +0200 Message-ID: <20261128210746.461103-1-esa.jaaskela@suomi24.fi> X-Mailer: git-send-email 2.47.3 MIME-Version: 1.0 X-Rspamd-Queue-Id: 4jcNCx5GdNzKmBV List-Id: X-Webhook-Received: from 45-33-107-173.ip.linodeusercontent.com [45.33.107.173] by lin-tor-korg-lkml-alma10-1 with HTTPS for ; Sat, 28 Nov 2026 21:08:07 -0000 X-Groupsio-URL: https://lists.yoctoproject.org/g/yocto-patches/message/5585 The loop that waits for the root device resolves root= and then sleeps for rootdelay seconds before it checks the result. Before the loop, only a PARTUUID= root is resolved, so with any other form of root= the boot always waits rootdelay seconds (1 by default), even when the device already exists. Move resolving root= into dmverity_root_device(), and call it before the loop and after each sleep, so that the boot waits only while the root device does not exist. Signed-off-by: Esa Jaaskela --- .../initramfs-framework-dm/dmverity | 51 ++++++++++--------- 1 file changed, 27 insertions(+), 24 deletions(-) diff --git a/recipes-core/initrdscripts/initramfs-framework-dm/dmverity b/recipes-core/initrdscripts/initramfs-framework-dm/dmverity index 1923490..4b29af4 100644 --- a/recipes-core/initrdscripts/initramfs-framework-dm/dmverity +++ b/recipes-core/initrdscripts/initramfs-framework-dm/dmverity @@ -4,6 +4,31 @@ dmverity_enabled() { return 0 } +dmverity_root_device() { + case "${bootparam_root}" in + ID=*) + realpath /dev/disk/by-id/${bootparam_root#ID=} 2>/dev/null + ;; + LABEL=*) + realpath /dev/disk/by-label/${bootparam_root#LABEL=} 2>/dev/null + ;; + PARTLABEL=*) + realpath /dev/disk/by-partlabel/${bootparam_root#PARTLABEL=} 2>/dev/null + ;; + PARTUUID=*) + realpath /dev/disk/by-partuuid/${bootparam_root#PARTUUID=} 2>/dev/null + ;; + PATH=*) + realpath /dev/disk/by-path/${bootparam_root#PATH=} 2>/dev/null + ;; + UUID=*) + realpath /dev/disk/by-uuid/${bootparam_root#UUID=} 2>/dev/null + ;; + *) + echo "${bootparam_root}" + esac +} + dmverity_run() { DATA_SIZE="__not_set__" DATA_BLOCK_SIZE="__not_set__" @@ -43,39 +68,17 @@ dmverity_run() { return fi - RDEV="$(realpath /dev/disk/by-partuuid/${bootparam_root#PARTUUID=} 2>/dev/null)" + RDEV="$(dmverity_root_device)" while [ ! -b "${RDEV}" ]; do if [ $(( $C * $delay )) -gt $timeout ]; then fatal "Root device resolution failed" exit 1 fi - case "${bootparam_root}" in - ID=*) - RDEV="$(realpath /dev/disk/by-id/${bootparam_root#ID=} 2>/dev/null)" - ;; - LABEL=*) - RDEV="$(realpath /dev/disk/by-label/${bootparam_root#LABEL=} 2>/dev/null)" - ;; - PARTLABEL=*) - RDEV="$(realpath /dev/disk/by-partlabel/${bootparam_root#PARTLABEL=} 2>/dev/null)" - ;; - PARTUUID=*) - RDEV="$(realpath /dev/disk/by-partuuid/${bootparam_root#PARTUUID=} 2>/dev/null)" - ;; - PATH=*) - RDEV="$(realpath /dev/disk/by-path/${bootparam_root#PATH=} 2>/dev/null)" - ;; - UUID=*) - RDEV="$(realpath /dev/disk/by-uuid/${bootparam_root#UUID=} 2>/dev/null)" - ;; - *) - RDEV="${bootparam_root}" - esac debug "Sleeping for $delay second(s) to wait root to settle..." sleep $delay C=$(( $C + 1 )) - + RDEV="$(dmverity_root_device)" done veritysetup \