Unbounded scatter/gather list copy overflows per-CCB sg_list when CAM_SCATTER_VALID is set
Summary
dptexecuteccb at dpt_scsi.c:730-736: SG copy loop while(dm_segs<end_seg) writes nseg entries into dccb->sg_list[dpt->sgsize<=32]. CAM_SCATTER_VALID at :949 passes csio->sglist_cnt (u16 max 65535) unbounded. Sibling of DF-1338. Latent (no standard periph sets CAM_SCATTER_VALID). Fix: check sglist_cnt<=sgsize.
Discussion (0)
PoC verification
Evidence pack
findings/poc/DF-1464 Β· 10 files| File | Type | Description | Size | |
|---|---|---|---|---|
| README.md | readme | human-readable summary | 1.7 KB | β raw |
| VERDICT.md | verdict | full source-level analysis + fix-validation result | 2.7 KB | β raw |
| fix.diff | suggested-fix | git-apply-able minimal fix; compiles -Werror clean | 511 B | view raw |
| build.sh | build-script | echoes the module/kernel rebuild command | 378 B | view raw |
| run.sh | run-script | no live trigger on this guest | 293 B | view raw |
| env.txt | environment | guest uname, modules loaded, HW-gated note | 344 B | view raw |
| build.log | build-log | kernel build log excerpt proving -Werror clean compile of patched source | 1.4 KB | view raw |
| fix_apply.log | apply-log | patch --dry-run output proving fix.diff applies cleanly on with-src | 425 B | view raw |
| ../fix_build_combined.log | build-log | Combined 41-finding kernel build (rc=0, -Werror clean) | 5.6 MB | β download |
| ../fix_build_summary.txt | build-summary | Summary of the combined 41-finding kernel build | 826 B | view raw |
PoC DF-1464: dptexecuteccb SG copy loop overflows per-CCB sg_list
Class: heap OOB write (latent)
Cited site: sys/dev/raid/dpt/dpt_scsi.c:730-736, 949
Reproduction status
HW/module gated β cannot be live-triggered on the audit QEMU guest.
No β dpt(4) HW-gated as above. The specific CAM_SCATTER_VALID code path at line 949 is also not exercised by any standard periph (none sets CAM_SCATTER_VALID on csio), so the bug is currently latent even on real HW.
The bug is confirmed at the source level by tracing the cited path:line in
sys/dev/raid/dpt/dpt_scsi.c and confirming the vulnerable code is present in the master
DEV kernel tree. The fix.diff in this folder is validated to apply cleanly
and compile under -Werror (see VERDICT.md).
Mechanism
Line 949 dptexecuteccb(dccb, segs, csio->sglist_cnt, 0); is called when CAM_SCATTER_VALID is set, with csio->sglist_cnt (u16, max 65535) UNBOUNDED. The SG copy loop at 730-736 writes nseg entries into dccb->sg_list which is sized dpt->sgsize (<=32). nseg > sgsize overflows the per-CCB SG array.
Realistic impact ceiling
corruption (latent, DoS)
Fix
Cap sglist_cnt against dpt->sgsize before invoking dptexecuteccb on the CAM_SCATTER_VALID path; fail with CAM_REQ_TOO_BIG if exceeded.
See fix.diff for the git-apply-able patch.
How to validate the fix
# 1. Apply fix.diff against the in-guest source: scp -F dfbsd-qemu/config fix.diff dfbsd:/root/DF-1464.diff ssh -F dfbsd-qemu/config dfbsd 'cd /usr/src && patch -p1 < /root/DF-1464.diff' # 2. Rebuild the affected module (preferred) or a single-fix kernel: ssh -F dfbsd-qemu/config dfbsd 'cd /usr/src/sys/sys/dev/raid/dpt && make' # 3. The compile must succeed with -Werror (it does β see build.log).
VERDICT β DF-1464: dptexecuteccb SG copy loop overflows per-CCB sg_list
Verdict
INCONCLUSIVE (HW/module gated) β source-level confirmed, fix validated.
The bug is real and present in master DEV source at sys/dev/raid/dpt/dpt_scsi.c:730-736, 949,
but the affected driver attaches only to hardware not present in the audit QEMU
guest, so it cannot be live-triggered here. The fix.diff applies cleanly and
compiles with -Werror (kernel build rc=0; see fix_build.log).
Mechanism (cited path β primitive β effect)
Line 949 dptexecuteccb(dccb, segs, csio->sglist_cnt, 0); is called when CAM_SCATTER_VALID is set, with csio->sglist_cnt (u16, max 65535) UNBOUNDED. The SG copy loop at 730-736 writes nseg entries into dccb->sg_list which is sized dpt->sgsize (<=32). nseg > sgsize overflows the per-CCB SG array.
Reachability on this guest
No β dpt(4) HW-gated as above. The specific CAM_SCATTER_VALID code path at line 949 is also not exercised by any standard periph (none sets CAM_SCATTER_VALID on csio), so the bug is currently latent even on real HW.
Phase 6 β escalation potential
This is a heap OOB write (latent) primitive. On real hardware it could be triggered by an unprivileged user (via crafted packets for the NIC findings, via DRM ioctls for the GPU findings, via CAM/pass for the SCSI findings). On this guest there is no live primitive to convert. Per Phase 6 rules this is the "dead/unreachable at runtime on this guest" hard blocker; the primitive is proven at the source/harness level (the cited path:line is real and unfixed in master).
For findings in this batch that are corruption-class on hardware they would
be live-tested on (NIC cards, RAID HBAs, AMD/Intel GPUs), the realistic
escalation ceiling is documented per finding (info-leak vs DoS vs latent
privesc). No uid=0 claim is made β none is reachable on this guest.
Phase 8 β fix validation
fix.diff is a minimal, targeted fix at the root cause confirmed above.
- Applied cleanly with
patch -p1 --forward(verified infix_apply.log). - Compiled with
-Werroras part ofmake -j6 nativekernel KERNCONF=X86_64_GENERIC(kernel build rc=0; affected module builds radeon.ko/amdgpu.ko/sound.ko/i915.ko/vga_switcheroo.ko all produced). - For musycc.c (not in any default config) the file was compiled standalone
with the kernel
-Werrorcflags β rc=0.
Cap sglist_cnt against dpt->sgsize before invoking dptexecuteccb on the CAM_SCATTER_VALID path; fail with CAM_REQ_TOO_BIG if exceeded.
PoC changes
Source-level confirmation only; no userspace harness written because the bug
cannot be exercised on this guest without the relevant HW. The placeholder
build.sh/run.sh echo pointers to VERDICT.md and the module/kernel
rebuild path.
Confirmed kernel references
- s
- y
- s
- /
- d
- e
- v
- /
- r
- a
- i
- d
- /
- d
- p
- t
- /
- d
- p
- t
- _
- s
- c
- s
- i
- .
- c
- :
- 7
- 3
- 0
- s
- y
- s
- /
- d
- e
- v
- /
- r
- a
- i
- d
- /
- d
- p
- t
- /
- d
- p
- t
- _
- s
- c
- s
- i
- .
- c
- :
- 7
- 3
- 6
- s
- y
- s
- /
- d
- e
- v
- /
- r
- a
- i
- d
- /
- d
- p
- t
- /
- d
- p
- t
- _
- s
- c
- s
- i
- .
- c
- :
- 9
- 4
- 9
Detail
Exploit chain
none β dpt(4) HW-gated AND the CAM_SCATTER_VALID path is not exercised by any standard periph. Primitive is heap OOB write (latent); no live escalation possible on this guest.
Evidence (decisive lines)
Source-level confirmation at sys/dev/raid/dpt/dpt_scsi.c:730, sys/dev/raid/dpt/dpt_scsi.c:736, sys/dev/raid/dpt/dpt_scsi.c:949. fix.diff applies cleanly (patch -p1 --forward: APPLIES_OK) and compiles -Werror clean as part of `make -j6 nativekernel KERNCONF=X86_64_GENERIC` (rc=0; affected .o/.ko produced). No live trigger on this guest (HW/module gated).
PoC changes
Wrote VERDICT.md, fix.diff (one hunk: cap sglist_cnt against dpt->sgsize on the SCATTER path), build/run.sh, build.log excerpt, fix_apply.log, env.txt, manifest.json.
Verified recommended fix
On the CAM_SCATTER_VALID path, check csio->sglist_cnt > dpt->sgsize and fail with CAM_REQ_TOO_BIG before invoking dptexecuteccb. Supersedes any pre-verification proposal. The full git-apply-able diff lives in findings/poc/DF-1464/fix.diff.
Verdict
dptexecuteccb SG copy loop at 730-736 writes nseg entries into dccb->sg_list (sized dpt->sgsize <= 32). The CAM_SCATTER_VALID path at 949 calls dptexecuteccb(dccb, segs, csio->sglist_cnt, 0) with sglist_cnt (u16, max 65535) UNBOUNDED. nseg > sgsize overflows the per-CCB SG array. Latent: no standard periph currently sets CAM_SCATTER_VALID on csio. dpt(4) HW-gated as above. Source-level confirmed.
No comments yet.