β¬’ DragonFlyBSD Kernel Audit
← triage Β· dashboard
DF-1454

Heap buffer overflow in autosense data copy - missing sizeof(sense_data) bound

Summary

pvscsi_process_completion at pvscsi.c:945-948: memcpy(&csio->sense_data, hcb->sense_buffer, MIN(csio->sense_len, e->sense_len)). sense_data is 32 bytes (SSD_FULL_SIZE). sense_len u8 max 255 from user pass(4). e->sense_len u32 from hypervisor DMA. memset at :943 correctly uses sizeof(sense_data). Overwrites adjacent CCB fields (cdb_ptr, resid, etc.) up to 223B. Operator/root via pass(4) or malicious hypervisor. Fix: MIN(MIN(sense_len,e->sense_len),sizeof(sense_data)).

Discussion (0)

No comments yet.

PoC verification

Evidence pack

findings/poc/DF-1454 Β· 10 files
FileTypeDescriptionSize
README.md readme human-readable summary 1.9 KB ↓ raw
VERDICT.md verdict full source-level analysis + fix-validation result 2.9 KB ↓ raw
fix.diff suggested-fix git-apply-able minimal fix; compiles -Werror clean 506 B view raw
build.sh build-script echoes the module/kernel rebuild command 391 B view raw
run.sh run-script no live trigger on this guest 299 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 342 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
README.md readme human-readable summary
↓ download raw

PoC DF-1454: pvscsi autosense memcpy overflows 32-byte sense_data

Class: stack/heap OOB write Cited site: sys/dev/virtual/vmware/pvscsi/pvscsi.c:945-948

Reproduction status

HW/module gated β€” cannot be live-triggered on the audit QEMU guest.

No β€” pvscsi(4) is in GENERIC but only attaches inside a VMware VM with a PVSCSI controller (PCI ID 15ad:07c0). The audit QEMU guest is not VMware; trigger is a malicious VMware hypervisor returning sense_len > 32 in the completion event.

The bug is confirmed at the source level by tracing the cited path:line in sys/dev/virtual/vmware/pvscsi/pvscsi.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 945-948 memcpy(&ccb->csio.sense_data, hcb->sense_buffer, MIN(csio->sense_len, e->sense_len)). sense_data is struct scsi_sense_data = SSD_FULL_SIZE = 32 bytes (scsi_all.h:953). csio->sense_len is u8 (max 255) from user pass(4); e->sense_len is u32 from hypervisor DMA. The MIN can be up to 255, overflowing the 32-byte buffer. The memset at 943 correctly uses sizeof(sense_data) β€” the memcpy at 945 does not.

Realistic impact ceiling

corruption (DoS, latent privesc)

Fix

Wrap the MIN in another MIN with sizeof(ccb->csio.sense_data) so the copy is bounded by the destination size.

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-1454.diff
ssh -F dfbsd-qemu/config dfbsd 'cd /usr/src && patch -p1 < /root/DF-1454.diff'

# 2. Rebuild the affected module (preferred) or a single-fix kernel:
ssh -F dfbsd-qemu/config dfbsd 'cd /usr/src/sys/sys/dev/virtual/vmware/pvscsi && make'

# 3. The compile must succeed with -Werror (it does β€” see build.log).
VERDICT.md verdict full source-level analysis + fix-validation result
↓ download raw

VERDICT β€” DF-1454: pvscsi autosense memcpy overflows 32-byte sense_data

Verdict

INCONCLUSIVE (HW/module gated) β€” source-level confirmed, fix validated.

The bug is real and present in master DEV source at sys/dev/virtual/vmware/pvscsi/pvscsi.c:945-948, 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 945-948 memcpy(&ccb->csio.sense_data, hcb->sense_buffer, MIN(csio->sense_len, e->sense_len)). sense_data is struct scsi_sense_data = SSD_FULL_SIZE = 32 bytes (scsi_all.h:953). csio->sense_len is u8 (max 255) from user pass(4); e->sense_len is u32 from hypervisor DMA. The MIN can be up to 255, overflowing the 32-byte buffer. The memset at 943 correctly uses sizeof(sense_data) β€” the memcpy at 945 does not.

Reachability on this guest

No β€” pvscsi(4) is in GENERIC but only attaches inside a VMware VM with a PVSCSI controller (PCI ID 15ad:07c0). The audit QEMU guest is not VMware; trigger is a malicious VMware hypervisor returning sense_len > 32 in the completion event.

Phase 6 β€” escalation potential

This is a stack/heap OOB write 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 in fix_apply.log).
  • Compiled with -Werror as part of make -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 -Werror cflags β€” rc=0.

Wrap the MIN in another MIN with sizeof(ccb->csio.sense_data) so the copy is bounded by the destination size.

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

Detail

Exploit chain

none β€” pvscsi(4) HW/env-gated (no VMware PVSCSI controller in guest). Primitive is OOB-write corruption class on VMware; no live escalation possible on this guest.

Evidence (decisive lines)

Source-level confirmation at sys/dev/virtual/vmware/pvscsi/pvscsi.c:945, sys/dev/virtual/vmware/pvscsi/pvscsi.c:948, sys/bus/cam/scsi/scsi_all.h:953. 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: wrap MIN in MIN(...,sizeof(sense_data))), build/run.sh, build.log excerpt, fix_apply.log, env.txt, manifest.json.

Verified recommended fix

Change length to MIN(MIN(csio->sense_len, e->sense_len), sizeof(ccb->csio.sense_data)) so the copy is bounded by the destination size. Supersedes any pre-verification proposal. The full git-apply-able diff lives in findings/poc/DF-1454/fix.diff.

Verdict

pvscsi_process_completion memcpy at 945-948 uses MIN(csio->sense_len, e->sense_len) as length, but sense_data is struct scsi_sense_data = SSD_FULL_SIZE = 32 bytes (scsi_all.h:953). csio->sense_len is u8 from user pass(4) (up to 255); e->sense_len is u32 from hypervisor DMA. MIN can be up to 255, overflowing the 32-byte buffer. The memset at 943 correctly uses sizeof(sense_data) β€” the memcpy at 945 does not. pvscsi(4) is in GENERIC but only attaches inside VMware VMs (PCI 15ad:07c0) β€” the audit QEMU guest is not VMware. Source-level confirmed.