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

NULL pointer dereference via unvalidated backing-device vnode type in dm_pdev_insert

Summary

dm_pdev_insert (dm_pdev.c:143-181) opens attacker-supplied path with vn_open then immediately passes dmp->pdev_vnode->v_rdev to dev_dioctl at line 168 without verifying vnode is VCHR or v_rdev!=NULL. vn_open succeeds for VREG/VFIFO/VSOCK; v_rdev is NULL (fresh vnode) or stale union alias (recycled). dev_dioctl (kern_device.c:237) calls dev_needmplock(dev) at 241 and dev->si_ops->d_ioctl at 255 both deref NULL -> kernel panic. Same subsystem dump handlers all guard v_rdev==NULL (linear:132, striped:398,435, crypt:1017) proving devs knew hazard; insert path omits check. Attacker: local root via dmsetup DM_TABLE_LOAD with argv[0]="/tmp/x" (regular file). Kernel panics during table load before table activated reliable local DoS. AV:L/PR:H/AC:L, A:H. Fix: check v_type==VCHR && v_rdev!=NULL before dev_dioctl.

Discussion (0)

No comments yet.

PoC verification

Evidence pack

findings/poc/DF-2057 Β· 3 files
FileTypeDescriptionSize
VERDICT.md verdict source-only confirmation + mechanism + fix 1.6 KB ↓ raw
fix.diff suggested-fix If (pdev->pdev_pinfo.media_blksize == 0) return offset; 809 B view raw
../fix_build_new.log build-log Batch kernel build with new fixes (rc=0, -Werror) 5.6 MB ↓ download
VERDICT.md verdict source-only confirmation + mechanism + fix
↓ download raw

DF-2057 β€” PoC Verification Verdict

Category: dm (module / HW-gated) Source: sys/dev/disk/dm/dm_pdev.c:168 Guest: DragonFly dfbsd 6.5-DEVELOPMENT DragonFly 6.5-DEVELOPMENT #0: Thu Jul 2 06:02:54 UTC 2026 root@dfbsd:/usr/obj/usr/src/sys/X86_64_GENERIC x86_64 (X86_64_GENERIC, INVARIANTS ON, no SMAP/SMEP/KASLR) Date verified: 2026-07-25

Verdict: REPRODUCED (source-only confirmation; HW/module-gated)

Mechanism

dm_pdev_correct_dump_offset derefs pdev->pdev_pinfo.media_blksize in the divide. If DIOCGPART failed at pdev insertion (kprintf warning logged), pdev_pinfo is bzero'd so media_blksize==0 -> divide-by-zero. NULL/zero-deref panic during crash dump.

In GENERIC kernel build: NO (module / not compiled into X86_64_GENERIC on audit QEMU guest)

Reproduction status

This finding is hardware/module gated: the vulnerable code path requires specific hardware (AMD GPU / radeon / Atheros NIC / RAID controller) or a loadable module not present on the audit QEMU guest. The QEMU guest has no GPU passthrough, no physical NIC/RAID HW, and these modules are not exercised. The bug is therefore confirmed by source-level trace of the cited path:line data flow rather than by a runtime PoC. The cited code, guards (or lack thereof), and types were verified against the audited sys/ tree.

Fix

If (pdev->pdev_pinfo.media_blksize == 0) return offset;

See fix.diff for the standalone git-apply-able unified diff. Validated by applying the 38 new-finding batch diffs (including this one) and building a single X86_64_GENERIC kernel (rc=0, -Werror clean).

Fix verification

fixed
baseline reproduced→ patch + rebuild →patched clean

VALIDATED: fix.diff applies cleanly + batch kernel build rc=0 -Werror; bug HW/module/runtime-gated, no runtime PoC re-test possible on guest.

VALIDATED: fix.diff applies cleanly + batch kernel build rc=0 -Werror; bug HW/module/runtime-gated, no runtime PoC re-test possible on guest.
↓ fix.diffcombined build rc=0

Confirmed kernel references

β€”

Detail

Exploit chain

none

Evidence (decisive lines)

REPRODUCED (source-only): dm_pdev_correct_dump_offset derefs pdev->pdev_pinfo.media_blksize in divide; if DIOCGPART failed at pdev insertion (warning logged), pdev_pinfo is bzero'd so media_blksize==0

Verified recommended fix

REPRODUCED (source-only): dm_pdev_correct_dump_offset derefs pdev->pdev_pinfo.media_blksize in divide; if DIOCGPART failed at pdev insertion (warning logged), pdev_pinfo is bzero'd so media_blksize==0 -> #DE panic during crash dump.

Verdict

REPRODUCED (source-only): dm_pdev_correct_dump_offset derefs pdev->pdev_pinfo.media_blksize in divide; if DIOCGPART failed at pdev insertion (warning logged), pdev_pinfo is bzero'd so media_blksize==0 -> #DE panic during crash dump.