]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
boot: fix MEMMAP_DEVICE_PATH EndingAddress field calculation
authorLennart Poettering <lennart@amutable.com>
Thu, 16 Jul 2026 13:59:08 +0000 (15:59 +0200)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Thu, 16 Jul 2026 16:17:14 +0000 (01:17 +0900)
Let's do what EDK2 does.

Fixes: #43038
src/boot/linux.c

index 09fb63419dc98b0f6a05efacd2cf00a08a3ef0a0..4ebba7bd4acf861af4f62c4caf78835aedd55dc5 100644 (file)
@@ -217,7 +217,11 @@ EFI_STATUS linux_exec(
                         },
                         .MemoryType = EfiLoaderData,
                         .StartingAddress = POINTER_TO_PHYSICAL_ADDRESS(kernel->iov_base),
-                        .EndingAddress = POINTER_TO_PHYSICAL_ADDRESS(kernel->iov_base) + kernel->iov_len,
+                        /* NB: the UEFI spec doesn't clarify whether the EndingAddress field should point to
+                         * the very last byte or the byte one after. EDK2 puts the very last byte in this
+                         * field, hence let's do so here too. Note that iovec_is_set() check above ensured
+                         * this cannot underflow. */
+                        .EndingAddress = POINTER_TO_PHYSICAL_ADDRESS(kernel->iov_base) + kernel->iov_len - 1,
                 },
                 .end_path = DEVICE_PATH_END_NODE,
         };