shmrealloc initializes OLD shmsegs[] instead of newsegs[] - heap OOB write + uninit new array (dead code)
Summary
shmrealloc (sysv_shm.c:692-698): after kmalloc newsegs + bcopy shmalloced entries, second init loop writes shmsegs[i] (OLD array) instead of newsegs[i] -> writes past old shmalloced-slot array = heap OOB write; newsegs[shmalloced..shmmni-1] NEVER initialized (kmalloc not M_ZERO) -> random shm_perm.mode/key/seq + random shm_internal ptr reachable by shm_find_segment_by_key/shmid. DEAD CODE: shminit sets shmalloced=shmmni (:717) before user code, shmmni is CTLFLAG_RD (:136), early-return guard shmalloced>=shmmni (:689) always taken. Real bug would activate if shmmni made growable at runtime.
Discussion (0)
PoC verification
Evidence pack
findings/poc/DF-0094 Β· 1 files| File | Type | Description | Size | |
|---|---|---|---|---|
| fix.diff | suggested-fix | shmrealloc initializes OLD shmsegs[] instead of newsegs[] - heap OOB write + uni | 438 B | view raw |
Fix verification
fixedfix.diff applied + combined nativekernel build rc=0 (-Werror)
fix.diff applied + combined nativekernel build rc=0 (-Werror)
Confirmed kernel references
β
Detail
Exploit chain
none (Info severity)
Evidence (decisive lines)
Source-confirmed at sys/kern/sysv_shm.c:683: shmrealloc inits OLD shmsegs[] not newsegs[] (dead code)
Verified recommended fix
Source-confirmed at sys/kern/sysv_shm.c:683: shmrealloc inits OLD shmsegs[] not newsegs[] (dead code)
Verdict
Source-confirmed at sys/kern/sysv_shm.c:683: shmrealloc inits OLD shmsegs[] not newsegs[] (dead code)
No comments yet.