⬢ DragonFlyBSD Kernel Audit
DF-2912 / fix.diff
← back to finding ↓ download raw
--- a/sys/kern/subr_disklabel64.c	2026-06-29 12:51:19.000000000 +0000
+++ b/sys/kern/subr_disklabel64.c	2026-10-26 01:54:34.229220561 +0000
@@ -479,7 +479,10 @@
 	lp->d_pbase = lp->d_bbase + ((BOOT2SIZE64 + blkmask) & ~blkmask);
 
 	/* Reserve space for the backup label at the slice end */
-	lp->d_abase = lp->d_total_size - ressize;
+	if (lp->d_total_size > (uint64_t)ressize)
+		lp->d_abase = lp->d_total_size - ressize;
+	else
+		lp->d_abase = lp->d_pbase;	/* tiny slice: no backup area */
 
 	/*
 	 * NOTE: The pbase and pstop are calculated to align to PALIGN_SIZE
@@ -488,8 +491,13 @@
 	 */
 	lp->d_pbase = ((doffset + lp->d_pbase + PALIGN_MASK) &
 		       ~(uint64_t)PALIGN_MASK) - doffset;
-	lp->d_pstop = ((lp->d_abase - lp->d_pbase) &
-		       ~(uint64_t)PALIGN_MASK) + lp->d_pbase;
+	if (lp->d_abase > lp->d_pbase) {
+		lp->d_pstop = ((lp->d_abase - lp->d_pbase) &
+			       ~(uint64_t)PALIGN_MASK) + lp->d_pbase;
+	} else {
+		/* tiny slice: no allocatable partition space */
+		lp->d_pstop = lp->d_pbase;
+	}
 
 	/*
 	 * All partitions are left empty unless DSO_COMPATPARTA is set