From: Yu Watanabe Date: Tue, 17 Feb 2026 18:27:41 +0000 (+0900) Subject: boot: Fix UKI boot for kernels with non-zero ImageBase (#40429) X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=78a61335e3e1a3b1dc24b2b1641ba3f76b75b5fd;p=thirdparty%2Fsystemd.git boot: Fix UKI boot for kernels with non-zero ImageBase (#40429) The current code incorrectly subtracts ImageBase from section VirtualAddress values when loading sections into memory. This is based on a misunderstanding of the PE specification. VirtualAddress in section headers is the address of the first byte of the section relative to the image base when the section is loaded into memory. In other words, VirtualAddress is already an RVA measured from the image base, it is definitely NOT an absolute address that needs to be adjusted. So when loading a PE image into a newly allocated buffer, sections should be copied to buffer + VirtualAddress, regardless of what ImageBase says. The ImageBase field merely indicates the *preferred* load address, it does not affect how section RVAs are interpreted. This happens to not cause issues when ImageBase was 0 (since VirtualAddress - 0 = VirtualAddress), which is why this bug went undetected on modern kernels. However, it fails with kernels that have non-zero ImageBase values. So let's remove the nonsensical VirtualAddress < ImageBase check, and remove the ImageBase subtractions from section loading offsets. This lets all kernel UKIs work properly again. Fixes: #40342 --- 78a61335e3e1a3b1dc24b2b1641ba3f76b75b5fd