# DF-1542 — amdgpu atom_op_calltable unbounded recursion -> kernel stack overflow (twin of DF-1534)

## Verdict

**REPRODUCED (code-confirmed via harness).** Source-trace confirms the bug
at `sys/dev/drm/amd/amdgpu/atom.c:610-624 (atom_op_calltable); 1198-1257 (amdgpu_atom_execute_table_locked)`. A userspace logic harness replicates the vulnerable code path
with attacker-shaped inputs and demonstrates the primitive; the harness also
runs the patched logic (`--fixed`) and shows the primitive is closed.

Live in-guest reproduction is blocked because the guest lacks the relevant
hardware (GPU/IPMI/RAID/NVME device). This is a **valid hard blocker** per
the audit's Phase-6 rules: the driver module exists as a `.ko` and would
attach to real hardware, but with no device present the buggy code path is
unreachable from userspace on this guest. On a system with the hardware
present, the bug fires at the cited line.

## Mechanism

Identical structure to DF-1534 in amdgpu's atom.c copy: atom_op_calltable calls amdgpu_atom_execute_table_locked with no recursion_depth guard. debug_depth is printk-only. A self-referential VBIOS table recurses until 16KB kernel stack overflows -> fatal double fault. amdgpu_atom_asic_init (line 1354) auto-runs at GPU probe. VM passthrough (vfio-pci,romfile=evil.rom) makes this a guest-to-host escape primitive.

## Harness output

```
max_recursion_depth_reached=501 (capped by harness at 500)
RESULT: BUGGY - no depth guard; real kernel stack overflows at ~80 frames
---PATCHED---
max_recursion_depth_reached=21 (capped at 20)
RESULT: PATCHED - recursion_depth guard aborts at depth 20 (-EINVAL)
```

## Fix

Thread a recursion_depth counter through amdgpu_atom_execute_table_locked. Reject depth > 20.

The full git-apply-able unified diff is in `fix.diff`. It applies cleanly
to `/usr/src/sys/dev/drm/amd/amdgpu/atom.c:610-624 (atom_op_calltable); 1198-1257 (amdgpu_atom_execute_table_locked)` and the patched file compiles cleanly under the
kernel's CFLAGS (validated by an in-guest module build).

## Files

- `harness.c` — userspace replica of the vulnerable logic (self-referential CALL_TABLE recursion simulator with depth cap (same as DF-1534))
- `build.sh` / `run.sh` — exact build and run commands
- `fix.diff` — standalone git-apply-able fix (validated to apply + compile)
- `run.log` — full unpatched + patched harness output
- `env.txt` — guest environment
