diff --git a/sys/vfs/hammer2/hammer2_bulkfree.c b/sys/vfs/hammer2/hammer2_bulkfree.c --- a/sys/vfs/hammer2/hammer2_bulkfree.c +++ b/sys/vfs/hammer2/hammer2_bulkfree.c @@ -724,7 +724,18 @@ bfi->sstop = cbinfo.sbase; - incr = bfi->sstop / (hmp->total_size / 10000); + /* + * DF-0818 (defense-in-depth): the divisor `total_size / 10000` is 0 + * whenever total_size < 10000. Mount validation currently requires + * volu_size >= HAMMER2_VOLUME_ALIGN (8 MiB) which keeps this safe, + * but the unguarded divide is a latent foot-gun. Clamp the divisor + * so any future relaxation of the size validation cannot surface a + * #DE trap here. + */ + if (hmp->total_size < 10000) + incr = 10000; + else + incr = bfi->sstop / (hmp->total_size / 10000); if (incr > 10000) incr = 10000;