From 7510f1853da61ff94685428118a05a01b8842f76 Mon Sep 17 00:00:00 2001 From: kn Date: Wed, 5 Oct 2022 09:58:43 +0000 Subject: [PATCH] Skip softraid(4) keydisks Keydisks appear as chunks internally (with special properties) and installboot(8) thus treated them like actual data chunks. Most users probably don't hit this as their keydisk is detached and thus appears "offline" and gets skipped. Installing to online keydisks may work but is neither expected nor intended to work, so properly skip them. Odd setups like keydisk and CRYPTO chunk on the same physical disk would end up installing getting bootblocks installed twice. Pointed out by Mikolaj Kucharski who also provided the actual diff (minor wording tweaks by me) OK jsing --- usr.sbin/installboot/efi_softraid.c | 9 ++++++++- usr.sbin/installboot/i386_softraid.c | 9 ++++++++- usr.sbin/installboot/sparc64_softraid.c | 9 ++++++++- 3 files changed, 24 insertions(+), 3 deletions(-) diff --git a/usr.sbin/installboot/efi_softraid.c b/usr.sbin/installboot/efi_softraid.c index 79c46406b9c..ed1c6423387 100644 --- a/usr.sbin/installboot/efi_softraid.c +++ b/usr.sbin/installboot/efi_softraid.c @@ -1,4 +1,4 @@ -/* $OpenBSD: efi_softraid.c,v 1.2 2022/08/29 18:54:43 kn Exp $ */ +/* $OpenBSD: efi_softraid.c,v 1.3 2022/10/05 09:58:43 kn Exp $ */ /* * Copyright (c) 2012 Joel Sing * Copyright (c) 2022 Klemens Nanni @@ -54,6 +54,13 @@ sr_install_bootblk(int devfd, int vol, int disk) return; } + /* Keydisks always have a size of zero. */ + if (bd.bd_size == 0) { + fprintf(stderr, "softraid chunk %u is keydisk - skipping...\n", + disk); + return; + } + if (strlen(bd.bd_vendor) < 1) errx(1, "invalid disk name"); part = bd.bd_vendor[strlen(bd.bd_vendor) - 1]; diff --git a/usr.sbin/installboot/i386_softraid.c b/usr.sbin/installboot/i386_softraid.c index b3ff06a6713..16ae394b146 100644 --- a/usr.sbin/installboot/i386_softraid.c +++ b/usr.sbin/installboot/i386_softraid.c @@ -1,4 +1,4 @@ -/* $OpenBSD: i386_softraid.c,v 1.19 2022/08/29 18:54:43 kn Exp $ */ +/* $OpenBSD: i386_softraid.c,v 1.20 2022/10/05 09:58:43 kn Exp $ */ /* * Copyright (c) 2012 Joel Sing * Copyright (c) 2010 Otto Moerbeek @@ -65,6 +65,13 @@ sr_install_bootblk(int devfd, int vol, int disk) return; } + /* Keydisks always have a size of zero. */ + if (bd.bd_size == 0) { + fprintf(stderr, "softraid chunk %u is keydisk - skipping...\n", + disk); + return; + } + if (strlen(bd.bd_vendor) < 1) errx(1, "invalid disk name"); part = bd.bd_vendor[strlen(bd.bd_vendor) - 1]; diff --git a/usr.sbin/installboot/sparc64_softraid.c b/usr.sbin/installboot/sparc64_softraid.c index 022b211c436..81fb199326a 100644 --- a/usr.sbin/installboot/sparc64_softraid.c +++ b/usr.sbin/installboot/sparc64_softraid.c @@ -1,4 +1,4 @@ -/* $OpenBSD: sparc64_softraid.c,v 1.6 2022/08/29 18:54:43 kn Exp $ */ +/* $OpenBSD: sparc64_softraid.c,v 1.7 2022/10/05 09:58:43 kn Exp $ */ /* * Copyright (c) 2012 Joel Sing * @@ -55,6 +55,13 @@ sr_install_bootblk(int devfd, int vol, int disk) return; } + /* Keydisks always have a size of zero. */ + if (bd.bd_size == 0) { + fprintf(stderr, "softraid chunk %u is keydisk - skipping...\n", + disk); + return; + } + if (strlen(bd.bd_vendor) < 1) errx(1, "invalid disk name"); part = bd.bd_vendor[strlen(bd.bd_vendor) - 1]; -- 2.20.1