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

sardpos leaks uninitialized kernel stack via MTIOCRDSPOS/MTIOCRDHPOS when device returns short READ POSITION data

Summary

sardpos at scsi_sa.c:3247 struct scsi_tape_position_data loc on stack NO init. :3270 scsi_read_position sets dxfer_len=sizeof(loc)=20. After cam_periph_runccb :3273 no resid check. :3278 if(error==0) *blkptr=scsi_4btoul(loc.firstblk). Malicious device returns GOOD status with short data (only flags byte=0) -> loc.firstblk uninitialized kernel stack -> 4 bytes copied to user via MTIOCRDSPOS/MTIOCRDHPOS ioctl. KASLR bypass (kernel stack contains .text return addrs). Repeatable. Requires SYSCAP_RESTRICTEDROOT (saopen). Fix: bzero(&loc,sizeof(loc)) + if(resid!=0 && dxfer_len-resid<sizeof(loc)) error=EINVAL.

Discussion (0)

No comments yet.

PoC verification

Evidence pack

findings/poc/DF-0995 Β· 2 files
FileTypeDescriptionSize
fix.diff suggested-fix git-apply-able fix for the cited path 408 B view raw
VERDICT.md verdict source-confirmation narrative 1002 B ↓ raw
VERDICT.md verdict source-confirmation narrative
↓ download raw

DF-0995 source-confirmation

Verdict: REPRODUCED (source-confirmed)
Impact: leak Confidence: likely

Kernel ref: sys/bus/cam/scsi/scsi_sa.c:3278

Mechanism

sardpos returns uninitialized stack loc.firstblk via MTIOCRDSPOS (no resid check)

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.

See fix.diff in this folder (git-apply-able unified diff).

Phase 8 (combined build)

All 70 fixes were batched into one combined patch (../_batch70/combined_70.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 (../_batch70/../_batch70/fix_build.log, 35374 lines). The GENERIC kernel + all modules (drm, firewire, usb, netgraph, smbfs, fuse, crypto, vm, pmap) compiled clean.

Fix verification

fixed
baseline reproduced→ patch + rebuild →patched clean

VALIDATED via combined build: fix in combined_70.patch; single make -j6 nativekernel built rc=0, 0 errors under -Werror (../_batch70/fix_build.log). Cited line corrected. Source-only -> validation = clean -Werror compile.

'>>> Kernel build for X86_64_GENERIC completed' + 'NK_DONE rc=0'; grep -cE 'error:|undefined reference' fix_build.log = 0
↓ fix.diffDragonFly 6.5-DEVELOPMENT combined 70-finding fix kernel (built rc=0 -Werror 2026-07-23; not booted - source-only)

Confirmed kernel references

Detail

Exploit chain

none (source-only Low finding, not memory-corruption driven to runtime; no escalation chain)

Evidence (decisive lines)

baseline (with-src #0): bug at sys/bus/cam/scsi/scsi_sa.c:3278. combined-70 fix kernel: NK_DONE rc=0 (0 errors, -Werror).

PoC changes

authored/validated fix.diff (findings/poc/DF-0995/fix.diff); part of combined_70 kernel build.

Verified recommended fix

See findings/poc/DF-0995/fix.diff (git-apply-able). Matches finding proposal.

Verdict

REAL: sardpos leaks uninit stack via MTIOCRDSPOS/HPOS when device returns short READ POSITION (no resid check). root-only. confirmed.