Package: ovmf
Version: 2025.02-8+deb13u1
Severity: normal
Tags: patch
X-Debbugs-Cc: [email protected]

Dear Maintainer,

The OVMF package starting with Trixie contains a .strictnx variant to enforce
permission restrictions that are being applied to firmware across the
ecosystem.

Unfortunately the .strictnx variant does not actually enforce the restrictions
it claims to, which lead to a false negative in upstream Xen's CI testing.  (A
regression which ought to have been caught by .strictnx ended up passing.)

To complicate matters, AIUI the PcdDxeNxMemoryProtectionPolicy default differs
between x86 and ARM, with x86 defaulting into "bug compatibility mode" while
ARM defaults into strict mode.  So, I suspect the ARM strictnx variant
probably is strict.

https://fedoraproject.org/wiki/Changes/Edk2Security contains the list of all
settings required to enforce strictnx in OVMF builds.  The attached patch
wires all of these settings up for the strictnx variant, including the
protection for NULL pointer dereferences which seems like a good move at the
same time.

I have tested that the resulting OVMF_CODE_4M.secboot.strictnx.fd does enforce
restrictions, and now fails with the bad build of Xen in CI.

I'm afraid that I'm not in a position to test the ARM side.

-- no debconf information
>From 878c994280c9bfc43cd13d75b032aa1105c2a4e0 Mon Sep 17 00:00:00 2001
From: Andrew Cooper <[email protected]>
Date: Mon, 16 Nov 2026 13:39:35 +0000
Subject: [PATCH] Fix strictnx build to really be strictnx

Removing `PcdUninstallMemAttrProtocol=TRUE` in order to create strictnx is
insufficient for x86 targets.  PcdDxeNxMemoryProtectionPolicy needs changing
from it's default in order to stop mapping EfiLoaderData as RWX.

Apply all settings from https://fedoraproject.org/wiki/Changes/Edk2Security,
which Fedora have rolled out generally across all OVMF binaries.

Signed-off-by: Andrew Cooper <[email protected]>
---
 debian/rules | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/debian/rules b/debian/rules
index 13f245b1a8f9..ebdc6366c155 100755
--- a/debian/rules
+++ b/debian/rules
@@ -40,6 +40,12 @@ COMMON_FLAGS += $(PCD_FLAGS)
 
 NO_STRICTNX_COMMON_FLAGS = --pcd PcdUninstallMemAttrProtocol=TRUE
 
+STRICTNX_COMMON_FLAGS  = --pcd PcdUninstallMemAttrProtocol=FALSE
+STRICTNX_COMMON_FLAGS += --pcd 
PcdDxeNxMemoryProtectionPolicy=0xC000000000007FD5
+STRICTNX_COMMON_FLAGS += --pcd PcdSetNxForStack=TRUE
+STRICTNX_COMMON_FLAGS += --pcd PcdImageProtectionPolicy=0x03
+STRICTNX_COMMON_FLAGS += --pcd PcdNullPointerDetectionPropertyMask=0x03
+
 OVMF_COMMON_FLAGS  = $(COMMON_FLAGS)
 OVMF_COMMON_FLAGS += -DTPM2_ENABLE=TRUE
 # Uncomment for in-band debug messages
@@ -50,7 +56,7 @@ OVMF_4M_LEGACY_FLAGS = $(OVMF_4M_COMMON_FLAGS) 
$(NO_STRICTNX_COMMON_FLAGS) -DPVS
 OVMF_4M_SECBOOT_FLAGS = $(OVMF_4M_COMMON_FLAGS) $(NO_STRICTNX_COMMON_FLAGS) 
-DBUILD_SHELL=FALSE -DSECURE_BOOT_ENABLE=TRUE -DSMM_REQUIRE=TRUE
 OVMF_4M_SECBOOT_CC_FLAGS = $(OVMF_4M_COMMON_FLAGS) $(NO_STRICTNX_COMMON_FLAGS) 
-DBUILD_SHELL=FALSE -DSECURE_BOOT_ENABLE=TRUE -DSMM_REQUIRE=FALSE
 OVMF_AMDSEV_FLAGS = $(OVMF_COMMON_FLAGS)
-OVMF_4M_SECBOOT_STRICTNX_FLAGS = $(OVMF_4M_COMMON_FLAGS) -DBUILD_SHELL=FALSE 
-DSECURE_BOOT_ENABLE=TRUE -DSMM_REQUIRE=TRUE
+OVMF_4M_SECBOOT_STRICTNX_FLAGS = $(OVMF_4M_COMMON_FLAGS) 
$(STRICTNX_COMMON_FLAGS) -DBUILD_SHELL=FALSE -DSECURE_BOOT_ENABLE=TRUE 
-DSMM_REQUIRE=TRUE
 
 AAVMF_COMMON_FLAGS  = $(COMMON_FLAGS)
 AAVMF_COMMON_FLAGS += -DTPM2_ENABLE=TRUE
@@ -58,7 +64,7 @@ AAVMF_COMMON_FLAGS += -DTPM2_CONFIG_ENABLE=TRUE
 AAVMF_COMMON_FLAGS += -DCAVIUM_ERRATUM_27456=TRUE
 AAVMF_NO_SECBOOT_FLAGS = $(COMMON_FLAGS) $(NO_STRICTNX_COMMON_FLAGS)
 AAVMF_SECBOOT_FLAGS = $(AAVMF_COMMON_FLAGS) $(NO_STRICTNX_COMMON_FLAGS) 
-DBUILD_SHELL=FALSE -DSECURE_BOOT_ENABLE=TRUE
-AAVMF_SECBOOT_STRICTNX_FLAGS = $(AAVMF_COMMON_FLAGS) -DBUILD_SHELL=FALSE 
-DSECURE_BOOT_ENABLE=TRUE
+AAVMF_SECBOOT_STRICTNX_FLAGS = $(AAVMF_COMMON_FLAGS) $(STRICTNX_COMMON_FLAGS) 
-DBUILD_SHELL=FALSE -DSECURE_BOOT_ENABLE=TRUE
 
 RISCV64_FLAGS = $(COMMON_FLAGS)
 LOONGARCH64_FLAGS = $(COMMON_FLAGS)

base-commit: 713ba575906801d6b025b3cf3b8d843d8e1dfc8d
-- 
2.39.5

Reply via email to