Repository navigation
crossjumprevert: revert cross-jump tail condensing (angr CrossJumpReverter) - #92
Merged
Merged
Conversation
…erter) Port angr's SAILR CrossJumpReverter (Basque et al., USENIX Security 2024) as a new S8 goto-reduction pass, gated by `--option crossjumprevert` (default-OFF, opt-in). It reverts compiler Irreducible Statement Condensing (cross jumping): when a non-return tail block is shared by several predecessors and reached by a goto, the pass duplicates that tail back into the goto source so both paths fall straight through and the goto/label vanish. Sibling of the existing `gotoreduce` option: gotoreduce duplicates *return* tails (a closed path); crossjumprevert duplicates a *non-return, fall-through* tail, which additionally requires a convergence precondition. The gap (proposal #89, who.o::scan_entries): kuna emits one residual `goto label_4012b5`; angr emits zero. The `need_deadprocs && v1 == 8` case and the skip/else path share an identical `v1 = *a1;` reload tail condensed into one block reached by a goto. With crossjumprevert on, kuna duplicates the tail back into the deadprocs arm, the goto/label disappear, and scan_entries reaches zero gotos. Implementation (s8_structure/kuna_crossjumpreverter.rs, runs after gotoreduce per the angr docstring): over the structured tree, find every unstructured BlockGoto whose target is a single-successor non-return BlockCopy tail (angr out_degree==1), bounded (one tail block, <=8 printed ops, no STORE, <=1 call), counting only printed ops so SSA MULTIEQUAL/INDIRECT markers don't inflate the bound. The correctness-critical convergence precondition uses BlockGraph::next_flow_after (the structured-tree post-dominance primitive): the place flow reaches after the goto's body must be exactly the tail's own fall-through successor, so goto-T-then-S and the inlined-T-then-S' land on the same successor. Declines on any doubt. The surgery (BlockGraph::kuna_inline_crossjump_tail) appends fresh BlockCopy leaves (no p-code cloned, SSA untouched) after the goto body and switches the node kind Goto->Ls. Each duplication is logged via Funcdata::warning. Default-OFF: leaves all 675 datatests byte-identical (baseline untouched). New option fully registered (stages.toml row + count 49->50, options.rs, architecture flag + ctor + reset_defaults + set_kuna_option + seam copy + seams.rs; ElementId 4103; action in universalaction.rs). New two-pass stage test ghangr-who-condensing-opt-reversion-72e518.xml (off: cross-jump goto+label; on: duplicated tail + log + zero gotos). docs/assertions.md regenerated; catalog/ action-tree/corpus-count test oracles updated for the new leaf/settable. Gates: make test PARITY OK (675/675); make test-stages PARITY OK (207/207); kuna catalog --check OK; make rust-test green except the pre-existing unrelated constseq should-panic test. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01PBrckq3YYAzBLq5k4KpWac
Union-resolve so crossjumprevert (opt-in default-off) coexists with #90's noreturn_extern and #91's noreturn_externmatch on main. Deconflicted: - ElementId 4103 -> 4105 (4103=noreturn_extern, 4104=noreturn_externmatch on main) - stages.toml header surface=95, settable=57 (34 stage-model knobs); +1 settable - kuna_stages/tests.rs: settable 57, surface 95, json-comma 56, live-value 25 (crossjumprevert has no live reader, in the suppressed allowlist); test fns renamed (settable_count_is_57 / live_value_present_for_25_suppressed_for_32) - catalog_bytecompat.rs: fixture_has_all_57_settables - kuna-base/xml.rs corpus count 148 (83 datatests + 65 stage tests) - kuna-catalog.xml: source_decompiler angr 17, change_kind structure-recovery 9 (both add crossjumprevert) - verify_w8_fw_universalaction.rs auto-merged: 262 leaves (252 C++ + branchflip + gotoreduce + crossjumprevert + 7 headers); universalaction/seams/architecture/block wiring of revert_cross_jumps preserved alongside the noreturn_extern* additions - regenerated stage_catalog.json fixture, docs/assertions.md, baseline-stages.json (212 keys) Gates green: kuna catalog --check OK; make test 675/675 PARITY OK; make test-stages 212/212 PARITY OK. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01PBrckq3YYAzBLq5k4KpWac
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.
What
Ports angr's SAILR
CrossJumpReverter(Basque et al., USENIX Security 2024) as anew S8 goto-reduction pass, gated by a new
--option crossjumprevert(default-OFF,opt-in). It reverts compiler Irreducible Statement Condensing (cross jumping): when a
non-return tail block is shared by several predecessors and reached by a
goto, the passduplicates that tail back into the goto source so both paths fall straight through and
the goto/label vanish.
This is the sibling of the existing
gotoreduceoption:gotoreduceduplicates returntails (a closed path);
crossjumprevertduplicates a non-return, fall-through tail,which additionally requires a convergence precondition.
The gap (proposal #89,
who.o::scan_entries)kuna emits one residual
goto label_4012b5inscan_entries; angr's full preset emitszero. The
need_deadprocs && v1 == 8case and the skip/else path share an identicalv1 = *a1;reload tail that the compiler condensed into one block reached by a goto. Withcrossjumprevert on, kuna duplicates the tail back into the deadprocs arm(
print_deadprocs(a1); v1 = *a1;), the goto/label disappear, and the function reacheszero gotos — matching angr.
Target fn:
who.o::scan_entries(x86-64). ON-vs-OFF goto delta: 1 -> 0.How
A new
ActionCrossJumpReverter(s8_structure/kuna_crossjumpreverter.rs) runs afterActionFinalStructureand afterActionGotoReduce(per the angr docstring,CrossJumpReverter is the last deoptimization). Over the structured (sblocks) tree it finds
every unstructured
BlockGotowhose target is:BlockCopytail (angrout_degree(T) == 1), bounded(one tail block, <=8 printed ops, no
STORE, <=1 call — angrmax_call_duplications),counting only printed ops so SSA
MULTIEQUAL/INDIRECTmarkers don't inflate the bound;(
BlockGraph::next_flow_after, the structured-tree post-dominance primitive) is exactlythe tail's own fall-through successor. This is the correctness-critical precondition: it
guarantees
goto T; T; -> Sand the inlinedT; -> S'land on the same successor(
S == S'). The pass declines on any doubt (e.g. when the goto is nested such thatremoving it would fall into a sibling case).
The surgery (
BlockGraph::kuna_inline_crossjump_tail) appends freshBlockCopyleaves(re-emitting the same ops — no p-code cloned, SSA/def-use untouched) after the goto's body
and switches the node kind from
GototoLs(plain list), so the goto/label vanish. Eachduplication is logged via
Funcdata::warning(crossjumprevert: duplicated cross-jump tail to remove goto). Edges are not rewired (this runs after final structuring; the Cprinter walks components/copy pointers, not edges).
Default decision
Default-OFF, opt-in. Per the standing rule (default-ON only if 0/675 and within
budget): the option leaves all 675 datatests byte-identical (default-off early-return), so
docs/baseline.jsonis untouched. Cross-jump duplication is a structure-alteringde-optimization with a correctness-critical precondition; shipping it opt-in (like its
sibling
gotoreduceandbranchflip) is the conservative choice until a clean default-ONablation is proven.
Validation / gates
make test— PARITY OK, 675/675 (default-off => byte-identical, baseline untouched).make test-stages— PARITY OK, 207/207 (newtests/stages/ghangr-who-condensing-opt-reversion-72e518.xml: a minimal hand-assembledx86-64 bytechunk faithful to scan_entries' CFG; pass 1 off => the cross-jump goto + label,
pass 2 on => duplicated tail + the log + zero gotos).
make rust-test— green (action-tree leaf-count/order oracle + catalog byte-compatfixture updated for the new leaf/settable; settable count 49 -> 50).
kuna catalog --check— OK;docs/assertions.mdregenerated.change on
scan_entries(timings dominated by subprocess spawn, OFF/ON in the same range).Registration (standing-rules checklist)
New
crossjumprevertoption fully wired:stages.tomlrow + count,options.rsKUNA_OPTION_NAMES, architecture flag + ctor +reset_defaults+set_kuna_optionarm +seam copy in
build_arch_handle+seams.rsfield/default; ElementId 4101 (4000+range); action registered in
universalaction.rs.🤖 Generated with Claude Code
https://claude.ai/code/session_01PBrckq3YYAzBLq5k4KpWac