From: Thomas Habets Subject: softraid: Correct LBA start offset type To: tech@openbsd.org Date: Mon, 13 Jul 2026 09:51:12 -0500 In softraid, unlike in efidev.c, `findopenbsd_gpt()` returns `u_int64_t`. But it's then assigned to an `u_int`. While the `-1` check should still work, offsets beyond 2TB probably fail. For i386 the change is a no-op since `u_int` is `u_int32_t`, but since the assignment of `start` comes from an `u_int32_t`, it seems more consistent to me. This appears to have been introduced in 2015. The file was renamed since, and I'm not great at CVSWeb, but the git mirror tells me the introducing commit is: commit db7f481f630eb7f6076cea1df64c22c8fb668b3f Author: krw Date: Tue Dec 22 21:15:43 2015 +0000 Find OpenBSD disklabel on GPT partitioned softraid volumes. Now you can boot from such volumes to match being able to install to them. Problem spotted by jcs@, fix tested by rpe@, ok jsing@ Found with LLM. Fixed manually. Looks correct to me. diff --git a/sys/arch/amd64/stand/libsa/softraid_amd64.c b/sys/arch/amd64/stand/libsa/softraid_amd64.c index fa0104727..e24792ee7 100644 --- a/sys/arch/amd64/stand/libsa/softraid_amd64.c +++ b/sys/arch/amd64/stand/libsa/softraid_amd64.c @@ -548,7 +548,7 @@ sr_getdisklabel(struct sr_boot_volume *bv, struct disklabel *label) struct dos_partition *dp; struct dos_mbr mbr; const char *err = NULL; - u_int start = 0; + u_int64_t start = 0; char buf[DEV_BSIZE]; int i; @@ -558,7 +558,7 @@ sr_getdisklabel(struct sr_boot_volume *bv, struct disklabel *label) if (gpt_chk_mbr(mbr.dmbr_parts, bv->sbv_size / (bv->sbv_secsize / DEV_BSIZE)) == 0) { start = findopenbsd_gpt(bv, &err); - if (start == (u_int)-1) { + if (start == (u_int64_t)-1) { if (err != NULL) return (err); return "no OpenBSD partition\n"; diff --git a/sys/arch/arm64/stand/efiboot/softraid_arm64.c b/sys/arch/arm64/stand/efiboot/softraid_arm64.c index e1507e879..0f2178305 100644 --- a/sys/arch/arm64/stand/efiboot/softraid_arm64.c +++ b/sys/arch/arm64/stand/efiboot/softraid_arm64.c @@ -535,7 +535,7 @@ sr_getdisklabel(struct sr_boot_volume *bv, struct disklabel *label) struct dos_partition *dp; struct dos_mbr mbr; const char *err = NULL; - u_int start = 0; + u_int64_t start = 0; char buf[DEV_BSIZE]; int i; @@ -545,7 +545,7 @@ sr_getdisklabel(struct sr_boot_volume *bv, struct disklabel *label) if (gpt_chk_mbr(mbr.dmbr_parts, bv->sbv_size / (bv->sbv_secsize / DEV_BSIZE)) == 0) { start = findopenbsd_gpt(bv, &err); - if (start == (u_int)-1) { + if (start == (u_int64_t)-1) { if (err != NULL) return (err); return "no OpenBSD partition\n"; diff --git a/sys/arch/i386/stand/libsa/softraid_i386.c b/sys/arch/i386/stand/libsa/softraid_i386.c index c2cd613a3..57058efb5 100644 --- a/sys/arch/i386/stand/libsa/softraid_i386.c +++ b/sys/arch/i386/stand/libsa/softraid_i386.c @@ -385,7 +385,7 @@ sr_getdisklabel(struct sr_boot_volume *bv, struct disklabel *label) { struct dos_partition *dp; struct dos_mbr mbr; - u_int start = 0; + u_int32_t start = 0; char buf[DEV_BSIZE]; int i; diff --git a/sys/arch/riscv64/stand/efiboot/softraid_riscv64.c b/sys/arch/riscv64/stand/efiboot/softraid_riscv64.c index f0e3a9177..519f162ea 100644 --- a/sys/arch/riscv64/stand/efiboot/softraid_riscv64.c +++ b/sys/arch/riscv64/stand/efiboot/softraid_riscv64.c @@ -535,7 +535,7 @@ sr_getdisklabel(struct sr_boot_volume *bv, struct disklabel *label) struct dos_partition *dp; struct dos_mbr mbr; const char *err = NULL; - u_int start = 0; + u_int64_t start = 0; char buf[DEV_BSIZE]; int i; @@ -545,7 +545,7 @@ sr_getdisklabel(struct sr_boot_volume *bv, struct disklabel *label) if (gpt_chk_mbr(mbr.dmbr_parts, bv->sbv_size / (bv->sbv_secsize / DEV_BSIZE)) == 0) { start = findopenbsd_gpt(bv, &err); - if (start == (u_int)-1) { + if (start == (u_int64_t)-1) { if (err != NULL) return (err); return "no OpenBSD partition\n";