Skip to content

[kani] Tighten slice and Ref proof scopes - #3663

Open
joshlf wants to merge 1 commit into
G868f72aa79c4e2c0240a06b3f1151fc9from
G31fb58e3f6c48d287ce6208bb1b061e4
Open

[kani] Tighten slice and Ref proof scopes#3663
joshlf wants to merge 1 commit into
G868f72aa79c4e2c0240a06b3f1151fc9from
G31fb58e3f6c48d287ce6208bb1b061e4

Conversation

@joshlf

@joshlf joshlf commented Sep 9, 2026

Copy link
Copy Markdown
Member

Factor the bounded slice and sized Ref proof accounts around safe Rust observations, including first_chunk and checked_sub oracles. State the universal input domains, final-state frames, transient-write exclusions, and Kani input-model premises next to the harness families.

Pin the remaining layout citations to Rust 1.93. This follow-up deliberately excludes the separately tracked custom-DST layout bug in #3630.

Authored by an AI agent acting on Josh Liebow-Feeser's behalf.


Latest Update: v4 — Compare vs v3

📚 Full Patch History

Links show the diff between the row version and the column version.

Version v3 v2 v1 Base
v4 vs v3 vs v2 vs v1 vs Base
v3 vs v2 vs v1 vs Base
v2 vs v1 vs Base
v1 vs Base
⬇️ Download this PR

Branch

git fetch origin refs/heads/G31fb58e3f6c48d287ce6208bb1b061e4 && git checkout -b pr-G31fb58e3f6c48d287ce6208bb1b061e4 FETCH_HEAD

Checkout

git fetch origin refs/heads/G31fb58e3f6c48d287ce6208bb1b061e4 && git checkout FETCH_HEAD

Cherry Pick

git fetch origin refs/heads/G31fb58e3f6c48d287ce6208bb1b061e4 && git cherry-pick FETCH_HEAD

Pull

git pull origin refs/heads/G31fb58e3f6c48d287ce6208bb1b061e4

Stacked PRs enabled by GHerrit.

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for security reviews. Please try again later.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 9, 2026

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ⚠️ Failed 2026-09-09T17:21:13.225730Z 92d5e03 Manual request
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@google-cla

google-cla Bot commented Sep 9, 2026

Copy link
Copy Markdown

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

@joshlf

joshlf commented Sep 9, 2026

Copy link
Copy Markdown
Member Author

Reviewer guide: exact scope

This follow-up factors and documents three bounded proof families around safe Rust/std observations: slice::first_chunk/last_chunk_mut for IntoBytes, safe splitting and snapshots for split producers/consumers, and usize::checked_sub for the one-byte-short sized-Ref boundary. Producer and consumer proofs remain separate so compensating defects cannot satisfy each other.

IntoBytes domain: as_bytes covers every u32. as_mut_bytes covers every [u32; 3] and every four-byte replacement while exposing only the middle element. The three write_to* harnesses separately cover every u32, every six-byte destination value, and every logical destination length 0–6; each passes only the offset-zero prefix of that logical length.

Sized Ref<u32> domain: constructor classification covers all 45 ranges of an aligned eight-byte backing object. Error restoration covers every policy-rejected range and every replacement u8; immutable dereference and the three mutation operations cover every constructible range and their stated replacement domains. Each of those five operation harnesses quantifies over two setup modes: an end-to-end public Ref::from_bytes path and a direct path which bypasses that constructor. Covers require both modes to reach normal return.

Direct-setup premises: The versioned source-body/Rust-move payload lemma applies to both direct paths. For the four constructible-range operation harnesses, the direct path rechecks size and alignment with safe Rust observations, uses the exact Ref::new_unchecked expression, and additionally relies on the concrete &mut [u8] ByteSlice/IntoByteSlice stability implementations as an explicit unsafe-trait TCB premise. For error restoration, the direct path uses the independently classified exact error constructor and payload lemma; it does not rely on byte-slice stability. Neither path derives an operation result by composing the weaker constructor frame.

Non-goals: These are not generic theorems over other types/backings, nonzero-start destinations, invalid or uninitialized values, the unsafe byte-slice trait contracts themselves, provenance, aliasing, reference identity/lifetimes, or drop behavior. Frames observe normal-return final state and cannot exclude transient writes restored before observation. Custom/nested DST layout, including the known issue in #3630, is excluded. Kani input generation and translation remain documented TOOL/TCB premises.

Evidence: the full pinned run verified 332/332 harnesses and all 896 covers; the five operation harnesses have ten setup-mode reachability covers. Repository pre-push validation passes.

Authored by an AI agent acting on Josh Liebow-Feeser's behalf.

@joshlf

joshlf commented Sep 9, 2026

Copy link
Copy Markdown
Member Author

@codex review

Please review exact current head 222841b3614034f9793168c6d8edc710422c14e5. Challenge every stated proof bound, final-state/transient-write exclusion, and TOOL premise. Check that safe Rust/std oracles are independent of the zerocopy operations they specify and that #3630 remains excluded.

Authored by an AI agent acting on Josh Liebow-Feeser's behalf.

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for security reviews. Please try again later.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 222841b361

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread zerocopy/src/ref.rs Outdated
Comment on lines +1214 to +1219
// The constructor harness quantifies over a superset of each operation
// harness's original-buffer and view domain under the same configuration.
// Its unchanged final frame can therefore be instantiated for each setup
// case and composed with the operation harness's sequence frame. This
// composition separates the setup's final-state contribution from the
// subsequent operation's stated final-state result; it still neither rules

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Avoid attributing the composed frame to the named operation

When Ref::from_bytes and a later operation have compensating defects, the constructor harness only proves result classification and unchanged backing bytes after forgetting the payload; it does not establish the returned Ref or error payload's internal source/address state. Consequently, combining that result with a proof of the sequence operation(from_bytes(input)) cannot isolate the operation's final-state behavior as claimed here. Construct an independently known-good wrapper for the operation harnesses, or first prove the exact returned payload invariant needed by the operation.

Useful? React with 👍 / 👎.

@joshlf joshlf Sep 9, 2026

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Addressed in exact current head 6f016f6ad382118998ef6479b706003679661bfb. Each of the five Ref operation harnesses now checks a fresh symbolic public-constructor mode and a direct mode, with two covers requiring both modes to reach normal return. The direct mode bypasses Ref::from_bytes. For the four constructible-range operations, it rechecks size/alignment with safe Rust observations and uses new_unchecked under the source-payload lemma plus the concrete &mut [u8] unsafe-trait stability premise. For into_src, it instead uses the independently classified exact error constructor and payload lemma, with no byte-slice-stability premise. The constructor frame is no longer composed into the named-operation theorem. The full run verifies 332/332 harnesses and all 896 covers.

Authored by an AI agent acting on Josh Liebow-Feeser's behalf.

@joshlf
joshlf force-pushed the G31fb58e3f6c48d287ce6208bb1b061e4 branch from 222841b to e750fbc Compare September 9, 2026 03:39
@joshlf
joshlf force-pushed the G868f72aa79c4e2c0240a06b3f1151fc9 branch from 7509f06 to 4d90a86 Compare September 9, 2026 03:39
@codecov-commenter

codecov-commenter commented Sep 9, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 91.89%. Comparing base (16ec4d0) to head (92d5e03).

Additional details and impacted files
@@                        Coverage Diff                         @@
##           G868f72aa79c4e2c0240a06b3f1151fc9    #3663   +/-   ##
==================================================================
  Coverage                              91.89%   91.89%           
==================================================================
  Files                                     20       20           
  Lines                                   6118     6118           
==================================================================
  Hits                                    5622     5622           
  Misses                                   496      496           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@joshlf
joshlf force-pushed the G31fb58e3f6c48d287ce6208bb1b061e4 branch from e750fbc to 6f016f6 Compare September 9, 2026 03:42
@joshlf
joshlf force-pushed the G868f72aa79c4e2c0240a06b3f1151fc9 branch from 4d90a86 to 16c135c Compare September 9, 2026 03:42
@joshlf

joshlf commented Sep 9, 2026

Copy link
Copy Markdown
Member Author

@codex review

Please review exact current head 6f016f6ad382118998ef6479b706003679661bfb. Challenge every stated proof bound and oracle. In particular, verify that each named Ref operation is isolated by its direct setup, that the source-body payload lemma and concrete unsafe byte-slice TCB premise suffice and are stated conditionally, and that both setup modes have non-vacuity covers. Check the final-state/transient-write, TOOL, and #3630 exclusions.

Authored by an AI agent acting on Josh Liebow-Feeser's behalf.

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for security reviews. Please try again later.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Hooray!

Reviewed commit: 6f016f6ad3

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Factor the bounded slice and sized Ref proof accounts around safe Rust observations, including first_chunk and checked_sub oracles. State the universal input domains, final-state frames, transient-write exclusions, and Kani input-model premises next to the harness families.

Pin the remaining layout citations to Rust 1.93. This follow-up deliberately excludes the separately tracked custom-DST layout bug in #3630.

*Authored by an AI agent acting on Josh Liebow-Feeser's behalf.*

gherrit-pr-id: G31fb58e3f6c48d287ce6208bb1b061e4
@joshlf
joshlf force-pushed the G31fb58e3f6c48d287ce6208bb1b061e4 branch from 6f016f6 to 92d5e03 Compare September 9, 2026 17:18
@joshlf

joshlf commented Sep 9, 2026

Copy link
Copy Markdown
Member Author

Authored by an AI agent acting on Josh Liebow-Feeser's behalf.

@codex review

Exact-head review request: 92d5e03

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for security reviews. Please try again later.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Something went wrong. Try again later by commenting “@codex review”.

Provided git ref 92d5e037e6477297a13b24b11585c0c363453559 does not exist
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants