diff options
author | 2020-06-08 19:17:12 +0000 | |
---|---|---|
committer | 2020-06-08 19:17:12 +0000 | |
commit | 9de342e3b04133ec23118695b2817c7cf6cad954 (patch) | |
tree | a6520a92f3352cc1f5561d55501eb175e23e493a /sys/dev/softraid.c | |
parent | Set up 64-bit mmio windows and enable DMA bypass mode. (diff) | |
download | wireguard-openbsd-9de342e3b04133ec23118695b2817c7cf6cad954.tar.xz wireguard-openbsd-9de342e3b04133ec23118695b2817c7cf6cad954.zip |
Provide clear errors when trying to install oversized boot loader
sparc64 installboot(8) on softraid(4) with too large files, e.g. unstripped
builds, fails poorly with "installboot: softraid installboot failed".
This is due to the BIOCINSTALLBOOT ioctl(2) returing the default EINVAL
rather than using softraid's sr_error() interface properly; additionally,
installboot does not check for such message from the bio(4) layer.
Make the kernel generate "boot block too large" and "boot loader too large"
messages for softraid devices and have installboot act upon them analogous
to bioctl(8), by adapting its bio_status() into the new sr_status() helper.
Input, reminder to look at bioctl, same kernel diff from, OK jsing
Diffstat (limited to 'sys/dev/softraid.c')
-rw-r--r-- | sys/dev/softraid.c | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/sys/dev/softraid.c b/sys/dev/softraid.c index dce30576d1b..95b7ddd57b4 100644 --- a/sys/dev/softraid.c +++ b/sys/dev/softraid.c @@ -1,4 +1,4 @@ -/* $OpenBSD: softraid.c,v 1.401 2020/04/14 07:38:21 jca Exp $ */ +/* $OpenBSD: softraid.c,v 1.402 2020/06/08 19:17:12 kn Exp $ */ /* * Copyright (c) 2007, 2008, 2009 Marco Peereboom <marco@peereboom.us> * Copyright (c) 2008 Chris Kuethe <ckuethe@openbsd.org> @@ -3704,11 +3704,17 @@ sr_ioctl_installboot(struct sr_softc *sc, struct sr_discipline *sd, goto done; } - if (bb->bb_bootblk_size > SR_BOOT_BLOCKS_SIZE * DEV_BSIZE) + if (bb->bb_bootblk_size > SR_BOOT_BLOCKS_SIZE * DEV_BSIZE) { + sr_error(sc, "boot block too large (%d > %d)", + bb->bb_bootblk_size, SR_BOOT_BLOCKS_SIZE * DEV_BSIZE); goto done; + } - if (bb->bb_bootldr_size > SR_BOOT_LOADER_SIZE * DEV_BSIZE) + if (bb->bb_bootldr_size > SR_BOOT_LOADER_SIZE * DEV_BSIZE) { + sr_error(sc, "boot loader too large (%d > %d)", + bb->bb_bootldr_size, SR_BOOT_LOADER_SIZE * DEV_BSIZE); goto done; + } secsize = sd->sd_meta->ssdi.ssd_secsize; |