build: batch of fixes 2026-08-13

- fix(qemu): add missing bochs module explicitly
- fix(base): escape die() message in emergency hook script
- fix(base): replace eval with safe variable indirection in splitsep and export_n

Resolves: RHEL-172462,RHEL-210943

From-source-git-commit: 2a395c7d4abe8e26836ecf109ab69600d4243e03
This commit is contained in:
Pavel Valena 2026-08-13 16:05:43 +02:00
parent daef90bbf9
commit 2af42b1801
4 changed files with 149 additions and 1 deletions

View File

@ -0,0 +1,27 @@
From 6328318f17933798a4a1a4e3b974b27070a470ad Mon Sep 17 00:00:00 2001
From: Pavel Valena <pvalena@redhat.com>
Date: Wed, 12 Aug 2026 22:55:18 +0200
Subject: [PATCH 39/41] fix(qemu): add missing bochs module explicitly
As it is needed to display console properly, and doesn't get detected in some cases.
Resolves: RHEL-172462
---
modules.d/90qemu/module-setup.sh | 3 +++
1 file changed, 3 insertions(+)
diff --git a/modules.d/90qemu/module-setup.sh b/modules.d/90qemu/module-setup.sh
index fecaca61..27c4c143 100755
--- a/modules.d/90qemu/module-setup.sh
+++ b/modules.d/90qemu/module-setup.sh
@@ -21,4 +21,7 @@ installkernel() {
spapr-vscsi \
qemu_fw_cfg \
efi_secret
+
+ # needed for displaying console properly
+ hostonly='' instmods bochs
}
--
2.55.0

View File

@ -0,0 +1,47 @@
From daed5d8f3691580a6b9b72e54d7bfc5fb6ded4df Mon Sep 17 00:00:00 2001
From: Pavel Valena <pvalena@redhat.com>
Date: Tue, 28 Jul 2026 04:03:13 +0200
Subject: [PATCH 40/41] fix(base): escape die() message in emergency hook
script
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
die() appends its error message to $hookdir/emergency/01-die.sh using
echo "warn dracut: FATAL: \"$*\"", which is later sourced by
emergency_shell(). When die() is called with DHCP-controlled data —
specifically $netroot derived from the DHCP ROOT_PATH option via
netroot.sh's handler-resolution failure path — a command-substitution
sequence such as $(cmd) embedded in that data executes as root when
dracut sources the emergency hook directory.
Replace `echo` with `printf '%q'` to shell-escape the message before
writing it into the hook script, preventing command injection via
DHCP-controlled values that reach die() through error paths.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
(cherry picked from commit 508599e7864c8902bbc5480a0f4d20804d9dd41a)
Resolves: RHEL-210943
---
modules.d/99base/dracut-lib.sh | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/modules.d/99base/dracut-lib.sh b/modules.d/99base/dracut-lib.sh
index 05c361c6..855305b3 100755
--- a/modules.d/99base/dracut-lib.sh
+++ b/modules.d/99base/dracut-lib.sh
@@ -410,7 +410,8 @@ die() {
} > /dev/kmsg
{
- echo "warn dracut: FATAL: \"$*\""
+ printf 'warn dracut: FATAL: %q\n' "$*"
+
echo "warn dracut: Refusing to continue"
} >> $hookdir/emergency/01-die.sh
[ -d /run/initramfs ] || mkdir -p -- /run/initramfs
--
2.55.0

View File

@ -0,0 +1,61 @@
From 2a395c7d4abe8e26836ecf109ab69600d4243e03 Mon Sep 17 00:00:00 2001
From: Pavel Valena <pvalena@redhat.com>
Date: Thu, 7 May 2026 00:59:05 +0200
Subject: [PATCH 41/41] fix(base): replace eval with safe variable indirection
in splitsep and export_n
splitsep: use local nameref to avoid eval injection via single-quote breakout.
export_n: use ${!var} and printf -v to avoid eval injection via double-quote breakout.
(cherry picked from commit 1488eb683109cc5b2e5e038e1e89851ab0cd9508)
Related: RHEL-210943
---
modules.d/99base/dracut-lib.sh | 15 ++++++++++-----
1 file changed, 10 insertions(+), 5 deletions(-)
diff --git a/modules.d/99base/dracut-lib.sh b/modules.d/99base/dracut-lib.sh
index 855305b3..48dfd590 100755
--- a/modules.d/99base/dracut-lib.sh
+++ b/modules.d/99base/dracut-lib.sh
@@ -329,12 +329,18 @@ splitsep() {
while [ -n "$str" ] && [ "$#" -gt 1 ]; do
tmp="${str%%"$sep"*}"
- eval "$1='${tmp}'"
+ local -n _splitsep_ref="$1"
+ _splitsep_ref="$tmp"
+ unset -n _splitsep_ref
str="${str#"$tmp"}"
str="${str#"$sep"}"
shift
done
- [ -n "$str" ] && [ -n "$1" ] && eval "$1='$str'"
+ if [ -n "$str" -a -n "$1" ]; then
+ local -n _splitsep_ref="$1"
+ _splitsep_ref="$str"
+ unset -n _splitsep_ref
+ fi
debug_on
return 0
}
@@ -923,14 +929,13 @@ emergency_shell() {
}
# Retain the values of these variables but ensure that they are unexported
-# This is a POSIX-compliant equivalent of bash's "export -n"
export_n() {
local var
local val
for var in "$@"; do
- eval "val=\$$var"
+ val="${!var}"
unset "$var"
- [ -n "$val" ] && eval "$var=\"$val\""
+ [ -n "$val" ] && printf -v "$var" '%s' "$val"
done
}
--
2.55.0

View File

@ -8,7 +8,7 @@
Name: dracut
Version: 107
Release: 9%{?dist}
Release: 10%{?dist}
Summary: Initramfs generator using udev
@ -136,6 +136,15 @@ Patch37: 0037-fix-systemd-networkd-escape-DHCP-lease-values-in-dhc.patch
# fix(i18n): prefer 'simpledrm' over 'drm' module
# Author: Pavel Valena <pvalena@redhat.com>
Patch38: 0038-fix-i18n-prefer-simpledrm-over-drm-module.patch
# fix(qemu): add missing bochs module explicitly
# Author: Pavel Valena <pvalena@redhat.com>
Patch39: 0039-fix-qemu-add-missing-bochs-module-explicitly.patch
# fix(base): escape die() message in emergency hook script
# Author: Pavel Valena <pvalena@redhat.com>
Patch40: 0040-fix-base-escape-die-message-in-emergency-hook-script.patch
# fix(base): replace eval with safe variable indirection in splitsep and export_n
# Author: Pavel Valena <pvalena@redhat.com>
Patch41: 0041-fix-base-replace-eval-with-safe-variable-indirection.patch
# Please use source-git to work with this spec file:
# HowTo: https://packit.dev/source-git/work-with-source-git
@ -557,6 +566,10 @@ echo 'dracut_rescue_image="yes"' > $RPM_BUILD_ROOT%{dracutlibdir}/dracut.conf.d/
%{_prefix}/lib/kernel/install.d/51-dracut-rescue.install
%changelog
* Tue Jul 28 2026 Pavel Valena <pvalena@redhat.com> - 107-10
- fix(base): escape die() message in emergency hook script
- fix(base): replace eval with safe variable indirection in splitsep and export_n
* Thu Jul 02 2026 Pavel Valena <pvalena@redhat.com> - 107-9
- fix(i18n): prefer 'simpledrm' over 'drm' module