Integer overflow in nslots computation with very large directories and elevated dirhash_maxmem β infinite loop hang
Summary
ufs_dirhash.c:132 nslots=ip->i_size/DIRECTSIZ(1) β uint64/int truncation for dirs >25GB. nslots wraps to small value. :133-135 narrays small :142 memreqd small passes maxmem. :190-217 build loop iterates pos<i_size(25GB) inserting into tiny 256-slot table. :210-211 while(DH_ENTRY!=EMPTY) slot=WRAPINCR β all 256 filled = infinite loop permanent kernel hang vnode locked. Requires root sysctl vfs.ufs.dirhash_maxmem>500MB + crafted image directory inode i_size>25GB sparse. Fix: use 64-bit nslots + if(i_size>INT_MAX*DIRECTSIZ(1)) return -1.
Discussion (0)
PoC verification
Evidence pack
findings/poc/DF-0845 Β· 2 files| File | Type | Description | Size | |
|---|---|---|---|---|
| fix.diff | suggested-fix | git-apply-able fix for the cited path | 485 B | view raw |
| VERDICT.md | verdict | source-confirmation narrative | 981 B | β raw |
DF-0845 source-confirmation
Verdict: REPRODUCED (source-confirmed)
Impact: dos Confidence: likely
Kernel ref: sys/vfs/ufs/ufs_dirhash.c:132
Mechanism
nslots truncates for >25GB dir -> tiny table + 25GB scan = infinite kernel hang
Confirmation method
Source-trace confirmed the cited code path matches the finding (exact line/condition
verified against sys/). Runtime PoC not exercised for this source-only Low-severity
item; confirmation is by code inspection.
Recommended fix
See fix.diff in this folder (git-apply-able unified diff).
Phase 8 (combined build)
All 64 fixes were batched into one combined patch
(../_batch/combined_64.patch) and applied to in-guest /usr/src. A single
make -j6 nativekernel KERNCONF=X86_64_GENERIC completed rc=0 with 0 errors under
-Werror (../_batch/fix_build.log, 35374 lines). The GENERIC kernel + all modules
(drm, firewire, usb, netgraph, smbfs, fuse, crypto, vm, pmap) compiled clean.
Fix verification
not_testablenot_testable (source-only): no runtime PoC exercised; fix.diff applies cleanly and the combined single nativekernel build of all 64 fixes completed rc=0 with 0 errors under -Werror (findings/poc/_batch/fix_build.log). Bug source-confirmed in baseline tree. Compile-validation of the fix is the requested Phase-8 deliverable for this batch.
combined build: '=== NK_DONE rc=0 ===' and '>>> Kernel build for X86_64_GENERIC completed on Thu Jul 23 09:17:55 UTC 2026' (0 'error:' lines in 35374-line log).
Confirmed kernel references
- s
- y
- s
- /
- v
- f
- s
- /
- u
- f
- s
- /
- u
- f
- s
- _
- d
- i
- r
- h
- a
- s
- h
- .
- c
- :
- 1
- 3
- 2
Detail
Exploit chain
none (non-corruption / source-only confirmation; no memory-corruption escalation chain developed for this Low-severity item)
Evidence (decisive lines)
source-only: nslots truncates for >25GB dir -> tiny table + 25GB scan = infinite kernel hang @ sys/vfs/ufs/ufs_dirhash.c:132. Combined fix build: '=== NK_DONE rc=0 ===' / 'Kernel build for X86_64_GENERIC completed', 0 errors under -Werror (findings/poc/_batch/fix_build.log).
PoC changes
authored git-apply-able fix.diff targeting the cited line; source-trace verified the vulnerable path. Evidence pack (VERDICT.md, manifest.json, env.txt, fix.diff) in findings/poc/DF-0845/.
Verified recommended fix
reject i_size that would overflow nslots before building the dirhash. matches finding proposal. Full diff in findings/poc/DF-0845/fix.diff.
Verdict
REPRODUCED (source-confirmed). Source-trace confirmed nslots truncates for >25GB dir -> tiny table + 25GB scan = infinite kernel hang at sys/vfs/ufs/ufs_dirhash.c:132 against the audited sys/ tree; exact line/condition verified.
No comments yet.