DF-2650 / fix.diff
--- a/sys/vfs/hammer2/hammer2_bulkfree.c +++ b/sys/vfs/hammer2/hammer2_bulkfree.c @@ -845,7 +858,20 @@ * it's a problem if it does. (Or L0 (4MB) for that matter). */ radix = (int)(bref->data_off & HAMMER2_OFF_MASK_RADIX); - KKASSERT(radix != 0); + /* + * DF-2650: a radix of 0 means a 1-byte allocation, which cannot + * exist on media. On-disk corruption or a crafted image must not + * panic an INVARIANTS kernel; skip the record instead of marking + * a bogus fragment. + */ + if (radix == 0) { + kprintf("hammer2_bulkfree_scan: illegal radix-0 data_off " + "%016jx %016jx/%d\n", + (intmax_t)bref->data_off, + (intmax_t)bref->key, + bref->keybits); + return 0; + } bytes = (size_t)1 << radix; class = (bref->type << 8) | HAMMER2_PBUFRADIX; |