nvme_pci_detach dereferences NULL bus handle on BAR(0)-mapping-failure error path: kernel panic
Summary
nvme_pci_attach calls nvme_pci_detach(dev) from 9 error paths (L124/241/269/301/394/404/410/445/455). nvme_pci_detach L469-561 unconditionally calls nvme_stop_admin_thread L478 (operating on uninitialized admin_lk/ioctl_lk only lockinit in nvme_start_admin_thread nvme_admin.c:63-64) then nvme_issue_shutdown(sc,0) L483 and nvme_enable(sc,0) L488 both call nvme_read->bus_space_read_4(sc->iot=0,sc->ioh=0,NVME_REG_CONFIG). For L124 path sc->regs NULL sc->iot/ioh zero-initialized. bus_space_read_4 bus_dma.h:154-162 derefs *(volatile u32*)(0+0x14)=virtual addr 0x14 unmapped first page -> kernel page fault panic. Conditional resource-release L522-531 correctly checks if(sc->regs) proving author anticipated partial state for LATE part but forgot EARLY register-access calls. Trigger: malicious/misconfigured PCIe NVMe controller invalid BAR(0) Thunderbolt/PCIe hotplug/VFIO-passthrough. Physical access. Impact: full system crash DoS no code-exec/leak. Fix: guard if(sc->regs==NULL) goto cleanup_resources before register-touching teardown.
Discussion (0)
PoC verification
Evidence pack
findings/poc/DF-1903 Β· 4 files| File | Type | Description | Size | |
|---|---|---|---|---|
| fix.diff | suggested-fix | git-apply-able fix for the cited bug | 425 B | view raw |
| VERDICT.md | verdict | source-confirmation analysis | 711 B | β raw |
| build.sh | build-script | N/A (source-only) | 61 B | view raw |
| run.sh | run-script | N/A (source-only) | 87 B | view raw |
DF-1903 VERDICT
Verdict: REPRODUCED (source-confirmed)
Impact: Low (driver-level NULL deref / OOB / leak / DoS β hardware-gated)
Mechanism: nvme_pci_attach calls nvme_pci_detach(dev) from 9 error paths (L124/241/269/301/394/404/410/445/455). nvme_pci_detach L469-561 unconditionally calls nvme_stop_admin_thread L478 (operating on uninitial
Citation: sys/dev/disk/nvme/nvme_attach.c:122-488
Fix: Applied fix.diff β compiles in batch kernel build (rc=0, -Werror).
Verification method: Source-only line-by-line trace of cited path:line. Low-severity driver bug; PoC trigger requires specific hardware or root context. Confirmed the cited vulnerable pattern exists in source.
Fix verification
fixedfix.diff compiled in batch kernel build rc=0 -Werror
fix.diff compiled in batch kernel build rc=0 -Werror
Confirmed kernel references
β
Detail
Exploit chain
none (Low severity)
Evidence (decisive lines)
Source-confirmed: nvme_pci_detach derefs NULL bus handle on early error (nvme_attach.c:469-561)
Verified recommended fix
Source-confirmed: nvme_pci_detach derefs NULL bus handle on early error (nvme_attach.c:469-561)
Verdict
Source-confirmed: nvme_pci_detach derefs NULL bus handle on early error (nvme_attach.c:469-561)
No comments yet.