Skip to contentSkip to conversation

s390x: Abort immediately on invalid loadparm

PATCH New [email protected] 1 participant 2 messages Jan 17, 2025

lore
Share & tools
lore
#0 lore raw

cover s390x: Abort immediately on invalid loadparm

From: Jared Rossi <[email protected]>

This is a small fix to the IPL behavior in case the user has entered an invalid loadparm. The loadparm is a very specific value, which must be deliberately set by the user. Therefore, if it is not valid, then it is a mistake in the guest configuration.

As such, we immediately terminate the IPL process if the loadparm is invalid, either because it is too large or because it points to an empty boot entry.

Jared Rossi (1):
pc-bios/s390-ccw: Abort IPL on invalid loadparm

 pc-bios/s390-ccw/bootmap.c | 15 +++++++++------
 1 file changed, 9 insertions(+), 6 deletions(-)
Signature · 1 line
2.43.5
#1 lore raw

PATCH 1/1 pc-bios/s390-ccw: Abort IPL on invalid loadparm

From: Jared Rossi <[email protected]>

Because the loadparm specifies an exact kernel the user wants to boot, if the loadparm is invalid it must represent a misconfiguration of the guest. Thus we should abort the IPL immediately, without attempting to use other devices, to avoid booting into an unintended guest image.

---
 pc-bios/s390-ccw/bootmap.c | 15 +++++++++------
 1 file changed, 9 insertions(+), 6 deletions(-)
pc-bios/s390-ccw/bootmap.c +9 -6
index 56f2f75640..0f8baa0198 100644
@@ -336,8 +336,7 @@ static int run_eckd_boot_script(block_number_t bmt_block_nr,
 
     debug_print_int("loadparm", loadparm);
     if (loadparm >= MAX_BOOT_ENTRIES) {
-        puts("loadparm value greater than max number of boot entries allowed");
-        return -EINVAL;
+        panic("loadparm value greater than max number of boot entries allowed");
     }
 
     memset(sec, FREE_SPACE_FILLER, sizeof(sec));
@@ -348,8 +347,8 @@ static int run_eckd_boot_script(block_number_t bmt_block_nr,
 
     block_nr = gen_eckd_block_num(&bmt->entry[loadparm].xeckd, ldipl);
     if (block_nr == NULL_BLOCK_NR) {
-        puts("Cannot find Boot Map Table Entry");
-        return -EIO;
+        printf("The requested boot entry (%d) is invalid\n", loadparm);
+        panic("Invalid loadparm");
     }
 
     memset(sec, FREE_SPACE_FILLER, sizeof(sec));
@@ -792,8 +791,12 @@ static int ipl_scsi(void)
 
     debug_print_int("loadparm", loadparm);
     if (loadparm >= MAX_BOOT_ENTRIES) {
-        puts("loadparm value greater than max number of boot entries allowed");
-        return -EINVAL;
+        panic("loadparm value greater than max number of boot entries allowed");
+    }
+
+    if (!valid_entries[loadparm]) {
+        printf("The requested boot entry (%d) is invalid\n", loadparm);
+        panic("Invalid loadparm");
     }
 
     return zipl_run(&prog_table->entry[loadparm].scsi);
Signature · 1 line
2.43.5