Repository navigation
[PROPOSAL] angr-who-condensing-opt-reversion-72e518: SAILR CrossJumpReverter (non-return cross-jump tail) to revert ISC condensing - #89
Closed
mahaloz wants to merge 1 commit into
Conversation
…a non-return cross-jump tail scan_entries (who.o) emits one residual goto where angr's full preset emits zero. The goto is compiler Irreducible Statement Condensing: two identical `v1 = *a1;` tails condensed into one shared block reached by `goto label_4012b5`. Reverting requires SAILR's CrossJumpReverter — duplicating a NON-return, fall-through cross-jump tail back into the goto source. Scoped LARGE by a decider subagent (Hard Rule 7): needs new structured-tree surgery (kuna_inline_crossjump_tail) + a tree-level convergence/post-dominance precondition that gotoreduce lacks, and the angr test names a multi-pass (ReturnDuplicatorLow + CrossJumpReverter) + edge-virtualization-ordering dependency. Parked as a draft proposal for human go/no-go; no engine code. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Contributor
Author
|
Closing this analysis-only proposal — implemented in #92 (crossjumprevert, merged). |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
[PROPOSAL] CrossJumpReverter: revert ISC condensing of a non-return cross-jump tail
Opportunity:
test_who_condensing_opt_reversion :: scan_entriesBinary:
who.o(x86_64), functionscan_entries(entry0x401250)Proposed option:
crossjumpreverter(default-OFF, opt-in while developing)angr reference: SAILR
CrossJumpReverter(+ReturnDuplicatorLow),angr/analyses/decompiler/optimization_passes/cross_jump_reverter.py,Basque et al., USENIX Security 2024 ("SAILR").
The problem
kuna emits one
gotoinscan_entries; angr's "full" preset emits zero. The gotois a residual of compiler Irreducible Statement Condensing (ISC): two identical
v1 = *a1;tails (theneed_deadprocscase's and the cascade's skip/else path's) werecondensed by the compiler into one shared basic block reached by a
goto:The SAILR de-optimization reverts the condensing by duplicating the shared tail back
into the goto source, so both paths fall straight through and the goto/label vanish.
This is the CrossJumpReverter case — a duplication of a NON-return, fall-through
cross-jump tail. It is distinct from the already-shipped
gotoreduceoption, whosereturn_tail_chain()only fires when the tail ends inreturn. Measured: no existingkuna option (
gotoreduce,regionstructure,loopbreak_recovery,foldcallret, in anycombination) removes this goto — it stays at 1. See
analysis.mdfor the table and thefull side-by-side (
angr-vs-kuna.txt).Why this is LARGE (the proposal gate)
A scope-decider subagent ruled this large (verdict + justification recorded verbatim in
record.json). It trips Hard Rule 7 on three counts:gotoreduce'skuna_inline_return_tailappends duplicatedBlockCopyleaves to aniftrue-clausefor a tail that ends in
return— a closed path, no fall-through to reconcile, noedge rewiring. A cross-jump tail falls through to a shared successor (
if (v1 == 2)),so the reverter needs a new surgery (
kuna_inline_crossjump_tail) that duplicates anon-return block and reconciles the fall-through — machinery
gotoreducedeliberatelylacks.
goto-source if-block's own structured fall-through already converges on the same
successor as the target's fall-through. Establishing that is a real dominator/convergence
analysis over the structured tree, not the bounded single-successor bblock walk
return_tail_chainperforms. A wrong precondition silently emits incorrect C — acorrectness defect far worse than the single harmless goto it removes.
scan_entriesreaches zero gotos only via two passes (ReturnDuplicatorLow+CrossJumpReverter) and a specific edge-virtualization ordering (post-order givestwo gotos; virtualizing
0x401361 -> 0x4012b5gives one, which the reverter thenremoves). kuna's verbatim
CollapseStructure/TraceDAGstructurer does not virtualizeedges the way angr's region structurer does, so the goto shape kuna hands a reverter is
not the shape angr's reverter consumes — there is no guarantee a single bounded Action
lands on this exact goto.
This is the same SAILR tail-duplication family already parked as a proposal for the
return-tail gotoreduce gap (
docs/baseline/PROGRESS history; sibling in-flight workerbranches
feat/angr-*ret-dup*,feat/angr-incorrect-duplication-chcon-*). TheCrossJumpReverter (non-return) variant is the missing third leg.
Proposed implementation plan (for human go/no-go)
kuna_crossjumpreverter.rs(S8, anActionCrossJumpRevertermodeled onkuna_gotoreduce.rs), gated by a newcrossjumpreverteroption(
revert_cross_jumpsflag on the seamArchitecture, default-off; gated early-return sodefault output is byte-identical).
if (cond) goto TwhereTis a small (≤ N ops, noCALL/STORE) non-return block that falls through to asuccessor
S.exactly
S(a post-dominator/convergence check on the structured tree). Declineotherwise — this is the correctness-critical step.
kuna_inline_crossjump_tail. DuplicateT's ops (print-treeBlockCopyleaves — no p-code cloned, SSA untouched) into the
iftrue-clause in place of thegoto; clearT's label when no unstructured edge still targets it.presents the right single-goto shape; if not, scope the additional ordering work (this is
the part that may force a second gated pass and is the chief risk to a clean default-ON
ablation).
tests/stages/ghangr-who-condensing-opt-reversion-72e518.xml(two-pass: off ⇒ the goto, default/on ⇒ zero gotos), full
kuna test --allablation,speed measurement on
scan_entries, and adocs/divergences.mdDIV entry only if theablation is clean and the option ships default-ON.
Speed / risk assessment
doubt; bound tail size; never duplicate side-effecting ops.
above) may mean one Action does not reach zero gotos on this function, requiring follow-up.
gotoreduce); to be measured during implementation. Ships default-OFF opt-in untilthe ablation is proven clean and within the speed budget.
Proposed option name
crossjumpreverter(change_kind = structure-recovery,inspiration = "test_who_condensing_opt_reversion; CrossJumpReverter/ReturnDuplicatorLow; scan_entries").On approval, re-dispatch an implementation worker on this branch
(
feat/angr-who-condensing-opt-reversion-72e518).