Repository navigation
fix(hy-check): check move projection index/slice subexpr uses and reject unrooted own-handle field moves (fixes #4006) - #4007
Open
pa-khan wants to merge 1 commit into
Conversation
…ect unrooted own-handle field moves (fixes limitlessprojects#4006)
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.
Fixes #4006
Summary
Fixes two P0 soundness holes in
Expr::Moveprojection handling acrosswalk.rs,freeze.rs, andsendability.rs(GUARANTEES.mdRows 1, 2, 6, and 7 —HYB-E3003,HYB-E3004,HYB-E3102,HYB-E3104):Walk index and slice-bound subexpressions along rooted
moveprojection chains (compiler/crates/hy-check/src/walk.rs):expr_move_chain_subexpr_usesand calls it from theExpr::Field | Expr::Index | Expr::Slicearm ofExpr::Moveinexpr_useswhenoperand.root_ident()isSome(root).via_move: trueuse onrootwhile recording all identifier uses insideindex,lo, andhisubexpressions along the projection chain so use-after-move (HYB-E3003), same-statement move/consume (HYB-E3003, A7/O13), A3 map-slot loanlast_usewindows (HYB-E3102), and T24 address-of-loan checks (HYB-E3104) cannot be bypassed.Require a rooted binding (
root_ident().is_some()) for the O5.4 own-handle field move allowance and freeze underlying reference roots (compiler/crates/hy-check/src/freeze.rs,compiler/crates/hy-check/src/sendability.rs):Expr::Field+TypeShape::OwnHandle(_)exemption inmark_move_in_value,check_o54_non_ident_move, andcheck_send_or_spawnonop.root_ident().is_some().op.root_ident() == None(e.g.move (holder{doc: h.doc}).doc,move passthrough(&h).doc,move ([]holder{h}[0]).doc), emitsHYB-E3004and freezes underlying non-sendable reference roots collected viacollect_ref_rootsso subsequent uses also triggerHYB-E3003.Verification
compiler/crates/hy-check/tests/move_projection_index_uses_and_unrooted_handle_field_soundness.rscovering:HYB-E3003for use-after-move insidemoveprojection index and slice bounds at local define,taskspawn, andch <-send sites.HYB-E3003for same-statement move + read and same-statement consume (flate2.writer.finish) + use insidemoveprojection index.HYB-E3102when a map is mutated before a final read of an A3 map-slot loan (slot := &m["a"]) insidemove s.holders[slot.idx].doc, andHYB-E3104when taking&slotinside amoveprojection index.HYB-E3004+HYB-E3003when moving.docout of unrooted struct literals, pointer-passthrough call results, and slice literals acrosstask,chan, and local define sites.cargo test -p hy-checksuite: all test binaries pass with 0 regressions.Settlement Coordinates
@pa-khan0x45Ecf534fD00bb3179D34E6a3FDdE084cBfBc9FbEek8wHTmTCjQoVtKw4ZATQLiTqwURR2LBdfTmxmuD4D8