Lane B Findings — lock-recursion verdict #
TL;DR #
The lock-recursion question, as posed, is moot. Lock 0xc1910 is never
re-entered from the code that runs while it's held — proven by a
depth-bounded reachability scan over 89 firmware functions, no symbolic
execution required. The return-into-dispatcher design is sound on this axis.
The actual concern that survives is different (and already mitigated): see
"What the claim should have asked" below.
This is Lane B of the formal-methods experiment. The plan was to build a
symexec harness on 0xc1910; the smallest-proof principle (prove the
smallest stable subassembly that closes the question) closed it before
symexec was warranted. That is the finding, and the lesson.
The claim, as written #
0xc1464holds lock0xc1910across thebl 0x5e846dispatch. In the freeze model the kernel spins inside that lock-held frame...0xc1910is not recursive — recon didn't prove a counter.
The assumption to validate: that re-entering 0xc1910 while held would
deadlock. Symexec was scoped to model the lock body's state machine under
re-entry.
What reading the bytes actually showed #
0xc1464 (the dispatch-driver) — proven from disassembly #
0xc1480: bl 0x59fbc ; primask save → IRQs DISABLED from here
0xc1484: adds r4, r0, #0 ; r4 = saved primask
0xc1486: movs r0, #2 ; arg = 2 (bit1 set)
0xc1488: bl 0xc1910 ; ← call 1
0xc148c: bl 0xc1a28 ; process pending packets
0xc1494: bl 0xc18f8 ; ring-buffer pending check ([+0x24] vs [+0x20])
0xc149c: bl 0x5e846 ; DISPATCHER (→ handler → shim)
0xc14a0: movs r0, #1 ; arg = 1 (bit0 set)
0xc14a2: bl 0xc1910 ; ← call 2
0xc14b0: movs r0, #0
0xc14b2: strb r0, [r5]
0xc14b4: pop {r4,r5,r7,pc}
Two 0xc1910 calls bracket the dispatcher — selected by arg bits (2=bit1,
1=bit0). The body's branch on lsls r0,r4,#0x1e (bit1) vs lsls r0,r4,#0x1f
(bit0) confirms bit-selection of the path.
0xc1910 (the "lock") — proven from disassembly #
The low bits of the ARGUMENT select the operation, not a lock-object field:
0xc191a: lsls r0,r4,#0x1f; bpl +8— bit0 clear: skip the bit0 path0xc191e: bl 0xc1714— bit0 set: run the release/drain path (table walk)0xc1922: lsls r0,r4,#0x1e; bmi +6— bit1 set: run the real-acquire path0xc1926-28: adds r0,r4,#0; pop {...pc}— fast path: return the arg
This is NOT a pthread-style mutex with an owner field. The acquire path
(0xc192a+) reads ring-buffer indexes ([r5]→[+0x10]→[+0x30] count,
[+0x3a] u16) — it looks like a queue/event primitive. The "lock" framing
was an inference; the primitive may be a critical-section + queue op.
The reachability scan (the load-bearing proof) #
tools/reach_scan.py — depth-bounded BFS over the dispatcher's reachable
call graph. 89 functions visited, zero transitive calls to 0xc1910.
The held region = {0xc1a28, 0xc18f8, 0x5e846 (dispatcher), 0x5f04e (handler, stock), 0xc1db4 (SPP_EMIT), ...} and every fn they reach. None of
them call 0xc1910. The patched shim replaces the handler with kernel code
that (by inspection of build_spp_shim) also does not call 0xc1910.
Re-entry is a necessary condition for recursive-deadlock. Re-entry is provably absent. Therefore the deadlock surface is provably absent.
What the claim should have asked (the concern that survives) #
Reading the bytes reveals the actual risk the design must handle, and it's not recursion:
0xc1464disables IRQs (bl 0x59fbc@0xc1480) for the ENTIRE bracketed region — acquire, dispatcher, release. The shim's INTERPRET runs with IRQs off. An unbounded or long-running INTERPRET would starve interrupt handling (BT stack heartbeats, timers).
The S7 return-into-dispatcher design already mitigates this: the shim runs
one INTERPRET pass per packet and returns (the S7 shim contract),
bounding the IRQ-disabled window per packet. The freeze model
(S6's b.w into an infinite QUIT) did NOT bound it — that's the real reason
S7 replaced S6, not the recursion concern.
So: the design decision (return-into-dispatcher over freeze) is correct, but for a different reason than the handoff stated. The mitigated risk is IRQ-starvation, not lock-recursion.
Proven vs. inferred (faithful, not overstated) #
PROVEN from bytes:
0xc1464disables IRQs before any locking (primask save @ 0xc1480).0xc1464calls0xc1910(2)and0xc1910(1), bracketing the dispatcher.- The dispatcher
0x5e846body contains nobl 0xc1910. - 89 functions reachable from the dispatcher path contain no transitive
bl 0xc1910(the reachability scan). 0xc18f8is a ring-buffer pending check (produce/consume index compare), not a lock.- Our shim (
build_spp_shim, by source inspection) does not call0xc1910.
INFERRED (not proven, and now lower-stakes):
- That
0xc1910(2)/0xc1910(1)is exactly a paired acquire/release. The bit0 path (0xc1714) does table-walking — could be "release + drain waiters," could be a different op. Does not affect the conclusion: re-entry is absent regardless of what the primitive is. - That IRQs stay disabled across the release call. The release path returns
through
0xc14a6 → 0xc14b0 (strb) → pop, and0x59fbc's counterpart (primask restore) isn't visible in this frame — likely restored by the caller of0xc1464. Worth a follow-up read but not design-blocking.
Why no symexec harness shipped #
The plan called for a tools/sym_shim.py (Unicorn+capstone, escalate to angr)
that was never written — reachability closed the question first (below), so
the tool stays a named intent, never built.
Building it would have modeled 0xc1910's internal state machine under
hypothetical re-entry — answering a question that doesn't arise. The
watchmaker principle: prove the smallest stable subassembly that closes the
question. Reachability closed it; symexec would have been the right
escalation IF reachability had found a re-entry path.
This is the meta-finding: formal methods earn their keep where the question is genuinely open. The claim looked open but was conditionally closed by a cheaper proof. Lane A's static checker was the better FM investment (it found real modeling gaps in the kernel); Lane B's reachability scan was the right tool, and it's 95 lines of capstone + BFS.
╰( ✖┳✖ )╯🔥 The claim is closed — not by symexec, but by reading the call graph. The return-into-dispatcher design is sound on the recursion axis (re-entry provably absent); the real risk (IRQ starvation) is already mitigated by the per-packet return model. The lesson lands: pick the smallest proof that closes the question, and let reachability veto the heavier machinery. ( ˘ ³˘)♥