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

atomctrl_get_voltage_evv dereferences hwmgr->dyn_state.vddc_dependency_on_sclk without a NULL check (parser contract allows NULL)

Summary

The pre-Tonga EVV getter dereferences the dependency-table pointer that the parser explicitly NULL-inits and only fills when the VBIOS carries a non-zero offset - a VBIOS omitting that sub-table panics at attach. The parser itself NULL-guards the same field; this consumer does not. NULL-check fix.

Discussion (0)

No comments yet.

PoC verification

Evidence pack

findings/poc/DF-4291 Β· 6 files
FileTypeDescriptionSize
README.md β€” 2.0 KB ↓ raw
VERDICT.md β€” 1.9 KB ↓ raw
fix.diff β€” 1.3 KB view raw
manifest.json β€” 879 B view raw
verdict.json β€” 2.5 KB view raw
env.txt β€” 962 B view raw

DF-4291 β€” atomctrl_get_voltage_evv() dereferences hwmgr->dyn_state.vddc_dependency_on_sclk without a NULL check

Pass-2 finding for sys/dev/drm/amd/powerplay/hwmgr/ppatomctrl.c (the "(e) powerplay table glue β€” the hwmgr dyn_state field fills" item of the pass-2 brief). Not DF-1497 (that is the svi2 lookup NULL deref in this same file) β€” this is the dyn_state table pointer NULL deref.

The bug (ppatomctrl.c:1131, 1138, 1147)

int atomctrl_get_voltage_evv(struct pp_hwmgr *hwmgr, ...)
{
        ...
        for (entry_id = 0;
             entry_id < hwmgr->dyn_state.vddc_dependency_on_sclk->count;   /* :1131 */
             entry_id++) {
                if (hwmgr->dyn_state.vddc_dependency_on_sclk
                        ->entries[entry_id].v == virtual_voltage_id) {     /* :1132 */

hwmgr->dyn_state.vddc_dependency_on_sclk is initialized to NULL by the powerplay-table parser (processpptables.c:1213) and only filled when the VBIOS powerplay table v4+ carries a non-zero usVddcDependencyOnSCLKOffset (processpptables.c:1304-1310). The parser itself treats the field as nullable (processpptables.c:1341-1342: if (result == 0 && (NULL != hwmgr->dyn_state.vddc_dependency_on_sclk) && ...)), but atomctrl_get_voltage_evv does not.

Reachability: phm_get_voltage_evv_on_sclk() dispatches here for chip_id < CHIP_TONGA (smu_helper.c:571-572); its only caller is smu7_get_evv_voltages() (smu7_hwmgr.c:1760), invoked from smu7_hwmgr_backend_init() (smu7_hwmgr.c:2551) at driver attach β€” reached whenever the powerplay table is V0 or the lookup path fails (smu7_hwmgr.c:1742). A CI/KV-class card whose VBIOS powerplay table omits the VDDC-on-SCLK dependency sub-table β‡’ NULL->count β‡’ Fatal trap 12 kernel panic at attach/boot (CWE-476).

Reproduce

Not runnable on this guest (no AMD dGPU β€” env.txt). On hardware: VBIOS powerplay table with usVddcDependencyOnSCLKOffset == 0 on a pre-Tonga (CI/KV) part, boot β†’ panic at amdgpu attach.

VERDICT.md
↓ download raw

DF-4291 VERDICT β€” dyn_state.vddc_dependency_on_sclk NULL deref

Status: inconclusive (code-trace certain; guest has no AMD dGPU)

Trace

  • ppatomctrl.c:1131 hwmgr->dyn_state.vddc_dependency_on_sclk->count β€” first deref, no NULL check anywhere in atomctrl_get_voltage_evv (ppatomctrl.c:1121-1160). Re-derefs at :1132, :1138, :1147.
  • Parser contract proving NULL is expected:
  • processpptables.c:1213 hwmgr->dyn_state.vddc_dependency_on_sclk = NULL;
  • processpptables.c:1304-1310 filled only if 0 != powerplay_table4->usVddcDependencyOnSCLKOffset
  • processpptables.c:1341-1342 the parser itself NULL-guards the same pointer (NULL != hwmgr->dyn_state.vddc_dependency_on_sclk) β€” the invariant "may be NULL" is established in-tree.
  • Dispatch chain (chip < CHIP_TONGA only): smu7_hwmgr_backend_init (smu7_hwmgr.c:2535) β†’ smu7_get_evv_voltages (smu7_hwmgr.c:2551β†’1693) β†’ :1742 pp_table_version == PP_TABLE_V0 || !phm_get_sclk_for_voltage_evv(...) β†’ :1760 phm_get_voltage_evv_on_sclk (smu_helper.c:565-582) β†’ :571-572 chip_id < CHIP_TONGA β‡’ atomctrl_get_voltage_evv β‡’ NULL deref when the table pointer is NULL.
  • Contrast: the sibling function in the same file, atomctrl_get_voltage_evv_on_sclk (ppatomctrl.c:1085), does not touch dyn_state β€” only the pre-Tonga EVV variant does.

Impact

Boot/module-load Fatal trap 12 NULL-deref panic (CWE-476) with a crafted/defective VBIOS on CI/KV-class hardware; Medium, DF-1497 band. Not runnable on this guest (no AMD dGPU) β‡’ inconclusive, trace-certain.

Fix status (batch validation)

Applied with the 36 sibling fix.diffs of this batch in findings/poc/_batch41/all_fixes.patch; single in-guest make -j6 nativekernel KERNCONF=X86_64_GENERIC completed RC=0 with zero errors under -Werror (full log: findings/poc/_batch41/fix_build8.log). Behavior A/B intentionally skipped for this Info-tier item.

Fix verification

not_testable
baseline no→ patch + rebuild →patched clean

Baseline behavior not reproducible on this guest (no AMD dGPU) -> no fixed-kernel build possible. fix.diff authored from trace.

findings/poc/DF-4291/fix.diff (not applied to sys/; authored post-verification from line-accurate trace)
↓ fix.diffper-fix-DF-4291

Confirmed kernel references

Detail

Evidence (decisive lines)

VERDICT.md (parser-contract + dispatch trace); README.md; fix.diff (NULL guard); env.txt

PoC changes

n/a β€” no AMD dGPU on guest; code-trace evidence pack

Verified recommended fix

NULL-check hwmgr->dyn_state.vddc_dependency_on_sclk at the top of atomctrl_get_voltage_evv and return -EINVAL

Verdict

atomctrl_get_voltage_evv() (ppatomctrl.c:1121-1160) dereferences hwmgr->dyn_state.vddc_dependency_on_sclk->count at :1131 (and :1132/:1138/:1147) with no NULL check. The powerplay-table parser initializes the pointer to NULL (processpptables.c:1213) and only fills it when the VBIOS powerplay table v4+ has a non-zero usVddcDependencyOnSCLKOffset (processpptables.c:1304-1310); the parser itself NULL-guards the same field at processpptables.c:1341-1342, establishing that NULL is an expected state. Dispatch: smu7_hwmgr_backend_init (smu7_hwmgr.c:2551) -> smu7_get_evv_voltages (:1760) -> phm_get_voltage_evv_on_sclk (smu_helper.c:571-572, chip_id < CHIP_TONGA) -> this function; a CI/KV-class VBIOS omitting the VDDC-on-SCLK sub-table yields Fatal trap 12 NULL-deref kernel panic at driver attach (CWE-476). Crafted-VBIOS threat model, Medium (DF-1497 band). Not runnable on this guest (no AMD dGPU β€” env.txt); trace-certain.