From 37b7b68f1b886fef2841400633469ad35301e80f Mon Sep 17 00:00:00 2001 From: Eduard Shishkin Date: Sat, 7 Dec 2024 12:48:12 +0100 Subject: [PATCH] zipl/src: Fix imprecise check that file locates on specified device MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit In case when target parameters are specified by user, the check that a file locates on a specified device, compares a logical device with a base disk, which is incorrect. Fix the check to compare base disks (a specified one with the base disk determined by disk_get_info() procedure called w/o any user hints). Fixes: c0f02d2f68a2 ("zipl/src: Fix problems when target parameters are specified by user") Signed-off-by: Eduard Shishkin Acked-by: Jan Höppner Signed-off-by: Jan Höppner --- zipl/src/bootmap.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/zipl/src/bootmap.c b/zipl/src/bootmap.c index 7d340156..880b93ce 100644 --- a/zipl/src/bootmap.c +++ b/zipl/src/bootmap.c @@ -299,14 +299,15 @@ create_component_header(void* buffer, component_header_type type) } /* - * Not precise check that the file FILENAME locates on specified physical DISK. + * Not precise check that the file FILENAME locates on the physical + * disk specified by WHERE. * * Try to auto-detect parameters of the disk which the file locates on * and compare found device-ID with DISK. * Return 0, if auto-detection succeeded, and it is proven that the * file does NOT locate on DISK. Otherwise, return 1. */ -static int file_is_on_disk(const char *filename, dev_t disk) +static int file_is_on_disk(const char *filename, struct disk_info *where) { /* * Retrieve info of the underlying disk without any user hints @@ -331,7 +332,7 @@ static int file_is_on_disk(const char *filename, dev_t disk) "Warning: Preparing a logical device for boot might fail\n"); return 1; } - if (info->device != disk) { + if (info->basedisks[0] != where->basedisks[0]) { disk_free_info(info); return 0; } @@ -378,7 +379,7 @@ static int add_component_file_range(struct install_set *bis, return -1; } } else { - if (!file_is_on_disk(filename, bis->info->device)) { + if (!file_is_on_disk(filename, bis->info)) { error_reason("File is not on target device"); return -1; }