summaryrefslogtreecommitdiff
path: root/src/boot
diff options
context:
space:
mode:
authorJan Janssen <medhefgo@web.de>2022-01-18 12:24:26 +0100
committerJan Janssen <medhefgo@web.de>2022-01-18 16:20:09 +0100
commit45a24eb7e991eba9c2aff6e981617a3634666ef5 (patch)
treec7934d10a15c168d8c9e13f0cc9eefa64209362c /src/boot
parentba900c1719549f09bb388207e5b879af99423acc (diff)
downloadsystemd-45a24eb7e991eba9c2aff6e981617a3634666ef5.tar.gz
boot: Search for the partition node directly
Some firmware creates partition device paths without a messaging device path node, making the search for the xboot loader partition fail. Fixes: #17756
Diffstat (limited to 'src/boot')
-rw-r--r--src/boot/efi/xbootldr.c26
1 files changed, 12 insertions, 14 deletions
diff --git a/src/boot/efi/xbootldr.c b/src/boot/efi/xbootldr.c
index 4972877d20..26b77c9344 100644
--- a/src/boot/efi/xbootldr.c
+++ b/src/boot/efi/xbootldr.c
@@ -12,20 +12,17 @@ union GptHeaderBuffer {
uint8_t space[CONST_ALIGN_TO(sizeof(EFI_PARTITION_TABLE_HEADER), 512)];
};
-static EFI_DEVICE_PATH *path_parent(EFI_DEVICE_PATH *path, EFI_DEVICE_PATH *node) {
- EFI_DEVICE_PATH *parent;
- UINTN len;
-
+static EFI_DEVICE_PATH *path_chop(EFI_DEVICE_PATH *path, EFI_DEVICE_PATH *node) {
assert(path);
assert(node);
- len = (UINT8*) NextDevicePathNode(node) - (UINT8*) path;
- parent = (EFI_DEVICE_PATH*) xallocate_pool(len + sizeof(EFI_DEVICE_PATH));
+ UINTN len = (UINT8 *) node - (UINT8 *) path;
+ EFI_DEVICE_PATH *chopped = xallocate_pool(len + END_DEVICE_PATH_LENGTH);
- CopyMem(parent, path, len);
- CopyMem((UINT8*) parent + len, EndDevicePath, sizeof(EFI_DEVICE_PATH));
+ CopyMem(chopped, path, len);
+ SetDevicePathEndNode((EFI_DEVICE_PATH *) ((UINT8 *) chopped + len));
- return parent;
+ return chopped;
}
static BOOLEAN verify_gpt(union GptHeaderBuffer *gpt_header_buffer, EFI_LBA lba_expected) {
@@ -183,13 +180,14 @@ static EFI_STATUS find_device(
EFI_BLOCK_IO *block_io;
EFI_DEVICE_PATH *p;
- /* First, Let's look for the SCSI/SATA/USB/… device path node, i.e. one above the media
- * devices */
- if (DevicePathType(node) != MESSAGING_DEVICE_PATH)
+ if (DevicePathType(node) != MEDIA_DEVICE_PATH)
+ continue;
+
+ if (DevicePathSubType(node) != MEDIA_HARDDRIVE_DP)
continue;
- /* Determine the device path one level up */
- disk_path = p = path_parent(partition_path, node);
+ /* Chop off the partition part, leaving us with the path to the disk itself. */
+ disk_path = p = path_chop(partition_path, node);
if (!disk_path)
continue;