Skip to content

[kani] Prove conditional transmute restoration - #3653

Open
joshlf wants to merge 1 commit into
Gzi6kdmiqx3hi24gccqw5f6pebmv47idcfrom
Gyiyzmayequ5ugyjdxzkhyjwnp6pggabj
Open

[kani] Prove conditional transmute restoration#3653
joshlf wants to merge 1 commit into
Gzi6kdmiqx3hi24gccqw5f6pebmv47idcfrom
Gyiyzmayequ5ugyjdxzkhyjwnp6pggabj

Conversation

@joshlf

@joshlf joshlf commented Sep 7, 2026

Copy link
Copy Markdown
Member

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


Latest Update: v52 — Compare vs v51

📚 Full Patch History

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

Version v51 v50 v49 v48 v47 v46 v45 v44 v43 v42 v41 v40 v39 v38 v37 v36 v35 v34 v33 v32 v31 v30 v29 v28 v27 v26 v25 v24 v23 v22 v21 v20 v19 v18 v17 v16 v15 v14 v13 v12 v11 v10 v9 v8 v7 v6 v5 v4 v3 v2 v1 Base
v52 v51 v50 v49 v48 v47 v46 v45 v44 v43 v42 v41 v40 v39 v38 v37 v36 v35 v34 v33 v32 v31 v30 v29 v28 v27 v26 v25 v24 v23 v22 v21 v20 v19 v18 v17 v16 v15 v14 v13 v12 v11 v10 v9 v8 v7 v6 v5 v4 v3 v2 v1 Base
v51 v50 Base
v50 v49 Base
v49 v48 Base
v48 v47 Base
v47 v46 Base
v46 v45 Base
v45 v44 Base
v44 v43 Base
v43 v42 Base
v42 v41 Base
v41 v40 Base
v40 v39 Base
v39 v38 Base
v38 v37 Base
v37 v36 Base
v36 v35 Base
v35 v34 Base
v34 v33 Base
v33 v32 Base
v32 v31 Base
v31 v30 Base
v30 v29 Base
v29 v28 Base
v28 v27 Base
v27 v26 Base
v26 v25 Base
v25 v24 Base
v24 v23 Base
v23 v22 Base
v22 v21 Base
v21 v20 Base
v20 v19 Base
v19 v18 Base
v18 v17 Base
v17 v16 Base
v16 v15 Base
v15 v14 Base
v14 v13 Base
v13 v12 Base
v12 v11 Base
v11 v10 Base
v10 v9 Base
v9 v8 Base
v8 v7 Base
v7 v6 Base
v6 v5 Base
v5 v4 Base
v4 v3 Base
v3 v2 Base
v2 v1 Base
v1 Base
⬇️ Download this PR

Branch

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

Checkout

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

Cherry Pick

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

Pull

git pull origin refs/heads/Gyiyzmayequ5ugyjdxzkhyjwnp6pggabj

Stacked PRs enabled by GHerrit.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 7, 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:07.440197Z fd3b420 Manual request
🔒 Security Review Completed 2026-09-08T21:36:10.934344Z 464bbae 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 7, 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.

@codecov-commenter

codecov-commenter commented Sep 7, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 91.89%. Comparing base (4c03bd0) to head (fd3b420).

Additional details and impacted files
@@                        Coverage Diff                         @@
##           Gzi6kdmiqx3hi24gccqw5f6pebmv47idc    #3653   +/-   ##
==================================================================
  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 Gzi6kdmiqx3hi24gccqw5f6pebmv47idc branch from e8753b0 to 88a28f5 Compare September 7, 2026 17:14
@joshlf
joshlf force-pushed the Gyiyzmayequ5ugyjdxzkhyjwnp6pggabj branch 2 times, most recently from 5bdc725 to a802f42 Compare September 7, 2026 17:47
@joshlf
joshlf force-pushed the Gzi6kdmiqx3hi24gccqw5f6pebmv47idc branch 2 times, most recently from 82d27ac to c0a2e4c Compare September 7, 2026 18:13
@joshlf
joshlf force-pushed the Gyiyzmayequ5ugyjdxzkhyjwnp6pggabj branch from a802f42 to 170146b Compare September 7, 2026 18:13
@joshlf

joshlf commented Sep 7, 2026

Copy link
Copy Markdown
Member Author

@codex review

Please review current head 170146b1b960c9ac3d161c569c08a3bb1b649843; in particular, challenge the documented proof domain and exclusions, and verify that expected behavior comes from an independent safe Rust, standard-library, language, or explicitly labeled policy oracle.

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

@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: 170146b1b9

ℹ️ 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/macros.rs Outdated
Comment on lines +1274 to +1277
// These are end-to-end proofs only for the `u8`-to-`bool` instantiations,
// not generic proofs of other type pairs, sizes, alignments, or macro arms.
// Kani does not fully model Rust aliasing, pointer provenance, invalid
// values, or uninitialized memory.

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 Limit the proof claim to Kani's target

The stated domain limits types, sizes, alignments, and macro arms, but not the compilation target, even though the checked Kani job in .github/workflows/ci.yml:740 verifies only Kani's selected target and model. Since the reference cases exercise pointer casts and layout-sensitive machinery, this result cannot establish the same behavior for every target and toolchain supported by the crate. Describe the domain as u8-to-bool on Kani's target and explicitly include other/non-Kani targets in the exclusions, as the surrounding proof modules do.

Useful? React with 👍 / 👎.

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 the current revision. The macro proof scope now names the exact shared Kani CI target/toolchain, features, function-contract flag, and sampled-layout configuration, and excludes other targets/toolchains and configurations.

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

@chatgpt-codex-connector

Copy link
Copy Markdown

Security review completed. No security issues were found in this pull request.

Reviewed commit: 170146b1b9

View security finding report

Only the user who started this review can view the report in Codex.

ℹ️ About Codex security reviews in GitHub

This is an experimental Codex feature. Security reviews are triggered when:

  • You comment "@codex security review"
  • A regular code review gets triggered (for example, "@codex review" or when a PR is opened), and you’re opted in so security review runs alongside code review

Once complete, Codex will leave suggestions, or a comment if no findings are found.

@joshlf
joshlf force-pushed the Gzi6kdmiqx3hi24gccqw5f6pebmv47idc branch from c0a2e4c to 48967ac Compare September 7, 2026 19:04
@joshlf
joshlf force-pushed the Gyiyzmayequ5ugyjdxzkhyjwnp6pggabj branch from 170146b to 017f40b Compare September 7, 2026 19:04
@joshlf

joshlf commented Sep 7, 2026

Copy link
Copy Markdown
Member Author

@codex review

Please review current head 017f40ba50e220f893a9df9041890742eae0e3c2; in particular, challenge the documented proof domain and exclusions, and verify that expected behavior comes from an independent safe Rust, standard-library, language, or explicitly labeled policy oracle.

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

@chatgpt-codex-connector

Copy link
Copy Markdown

Security review completed. No security issues were found in this pull request.

Reviewed commit: 017f40ba50

View security finding report

Only the user who started this review can view the report in Codex.

ℹ️ About Codex security reviews in GitHub

This is an experimental Codex feature. Security reviews are triggered when:

  • You comment "@codex security review"
  • A regular code review gets triggered (for example, "@codex review" or when a PR is opened), and you’re opted in so security review runs alongside code review

Once complete, Codex will leave suggestions, or a comment if no findings are found.

@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: 017f40ba50

ℹ️ 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/macros.rs Outdated
match result {
Ok(pointer) => {
assert!(expected_valid);
assert!(pointer.is_null());

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 Ground the zero-to-null expectation in a safe oracle

When src has an all-zero representation, this assertion treats the resulting pointer as null, but the only cited Reference rule establishes that integer-to-thin-pointer production is valid—not that zero maps to null. Consequently, this expected result currently comes from Kani's pointer model rather than an independent language or standard-library oracle. Compare against a safely constructed core::ptr::null() and cite its zero-initialization guarantee, as the neighboring pointer proofs do.

AGENTS.md reference: zerocopy/AGENTS.md:L67-L71

Useful? React with 👍 / 👎.

Comment thread zerocopy/src/macros.rs Outdated
Comment on lines +1279 to +1283
// The non-materializing validator proof exhausts all 256 `u8` values on
// Kani's target. `bool_from_byte` is the shared Rust-Reference-based oracle
// and never constructs an invalid `bool`. The value and reference macros
// are invoked only for the two independently valid representations; they
// check the decoded value, address identity, and mutation propagation.

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 Record the concrete proof bounds in the source scope

The checked-in scope describes the symbolic values but omits the fixed stack-allocation sizes and the pointer policy loop bound; although #[kani::unwind(9)] selects a limit, the documentation never states that the target has an eight-byte usize, that .all performs eight iterations, or why nine unwindings cover it. It also does not state that the harnesses make no assumptions. agent_docs/validation.md requires these dimensions to be documented independently so future changes can be checked against the actual modeled state space; add the one-byte/eight-byte allocation, loop/unwind, and no-assumption bounds here.

AGENTS.md reference: zerocopy/AGENTS.md:L67-L71

Useful? React with 👍 / 👎.

@joshlf
joshlf force-pushed the Gzi6kdmiqx3hi24gccqw5f6pebmv47idc branch from 2c90dd3 to 42b2995 Compare September 9, 2026 00:45
@joshlf
joshlf force-pushed the Gyiyzmayequ5ugyjdxzkhyjwnp6pggabj branch from e2010a6 to 7930a08 Compare September 9, 2026 00:48
@joshlf

joshlf commented Sep 9, 2026

Copy link
Copy Markdown
Member Author

@codex review

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. Breezy!

Reviewed commit: 7930a08265

ℹ️ 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".

@joshlf
joshlf force-pushed the Gzi6kdmiqx3hi24gccqw5f6pebmv47idc branch from 2c90dd3 to 8ed9170 Compare September 9, 2026 01:35
@joshlf
joshlf force-pushed the Gyiyzmayequ5ugyjdxzkhyjwnp6pggabj branch from 7930a08 to d72291e Compare September 9, 2026 01:35
@joshlf

joshlf commented Sep 9, 2026

Copy link
Copy Markdown
Member Author

@codex review

Please review current head d72291e48b85bbc5482b390f9c36c5659c45c54b; in particular, challenge the documented proof domain and exclusions, and verify that expected behavior comes from an independent safe Rust, standard-library, language, or explicitly labeled policy oracle.

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: d72291e48b

ℹ️ 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/macros.rs Outdated
}
Err(error) => {
assert!(!expected_valid);
assert_eq!(error.src, src);

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 Document the direct recovery oracle

When a nonzero usize reaches the Err branch, the expected recovered value is the src binding retained after passing src by value, but the proof documentation explains only the pointer policy and direct error-field projection. Unlike the padded harness, it does not state the normative Copy/value-expression basis that preserves this pre-call value, the basis for usize equality, why those operations are independent of the target, or their limitations. Record those contracts or use the already documented snapshot and observation helpers so this recovery result has an auditable independent safe-Rust oracle.

AGENTS.md reference: zerocopy/AGENTS.md:L67-L71

Useful? React with 👍 / 👎.

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. The pointer-policy harness now snapshots the usize source before the target call with the shared safe copy_snapshot oracle and compares error recovery through assert_same_usize. The proof text maps that independent snapshot and equality observation and states their limitations.

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

Comment thread zerocopy/src/macros.rs Outdated
//
// Destination validity and accepted value: Rust guarantees that every
// integer representation can validly produce a thin raw pointer [3];
// destination padding imposes no validity requirement. Thus an erroneous

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 Ground destination-padding validity in a language rule

For the padded harness's arbitrary [u8; 16] domain, the claim that even erroneous acceptance cannot materialize an invalid PaddedPointer depends on bytes 8–15 imposing no validity constraint. Citation [3] establishes only the pointer field's validity, while [10] and [11] establish layout and offsets; none supplies the asserted bit-validity rule for destination padding, and the later Kani padding premise is limited to recovery behavior. Cite an independent language contract for arbitrary padding bytes or explicitly retain this as a TOOL/TCB premise so the safety of materializing every accepted candidate is not inferred from the target derive or verifier model.

AGENTS.md reference: zerocopy/AGENTS.md:L67-L71

Useful? React with 👍 / 👎.

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. The proof now cites the Rust 1.93 invalid-values rule that explicitly permits uninitialized memory in padding, maps the layout citations showing bytes 8–15 are destination tail padding, and records the language-to-Kani padding behavior as a TOOL/TCB premise rather than inferring it from the target derive.

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

Comment thread zerocopy/src/macros.rs Outdated
Ok(dst) => {
assert_eq!((dst as *mut bool).cast::<u8>(), src_ptr);
assert_eq!(*dst, expected);
*dst = !*dst;

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 Derive the mutation value independently

On each valid mutable-bool path, the value written back is computed as !*dst, so the mutation stimulus consults the reference returned by the implementation under proof rather than coming solely from expected. The preceding equality assertion helps the whole harness catch an incorrect initial decoding, but it does not satisfy the repository's requirement that oracle construction avoid consulting the target result, and the documentation also gives no normative basis for the negation/dereference/assignment observation chain. Assign the independently derived !expected instead and document the safe language operations used to observe the resulting source byte.

AGENTS.md reference: zerocopy/AGENTS.md:L67-L71

Useful? React with 👍 / 👎.

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. The harness computes expected_after_mutation = !expected before calling the target and assigns that independent value through the returned reference. The proof account now maps Boolean negation, dereference/place evaluation, assignment, and the final u8 observation.

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

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. 🚀

Reviewed commit: ae63fa3fc8

ℹ️ 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".

@joshlf

joshlf commented Sep 9, 2026

Copy link
Copy Markdown
Member Author

@codex review

Please review exact head e88c05266250419c144fb06c3cf2d8e491c36ca1.

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. 🚀

Reviewed commit: e88c052662

ℹ️ 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".

@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: 6f81d91

@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. 👍

Reviewed commit: 6f81d91ab1

ℹ️ 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".

@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: 6fe1450

@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. Keep it up!

Reviewed commit: 6fe145024c

ℹ️ 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".

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

gherrit-pr-id: Gyiyzmayequ5ugyjdxzkhyjwnp6pggabj
@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: fd3b420

@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 fd3b42055b273b4efa6c6e5b088f267a66f19320 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