Skip to content

Disable retagging for variadic arguments in const-eval#157622

Merged
rust-bors[bot] merged 1 commit into
rust-lang:mainfrom
BorrowSanitizer:ignore-retags-variadics
Jun 12, 2026
Merged

Disable retagging for variadic arguments in const-eval#157622
rust-bors[bot] merged 1 commit into
rust-lang:mainfrom
BorrowSanitizer:ignore-retags-variadics

Conversation

@icmccorm

@icmccorm icmccorm commented Jun 8, 2026

Copy link
Copy Markdown
Contributor

Fixes #5058 in Miri.

Retags occur on typed copies, which happen when we pass variadic arguments to a function. At the moment, variadic arguments receive RetagMode::FnEntry retags, which protects their permissions for the duration of the call. However, protection needs to be based on callee-side information, and the callee has now way of knowing what's contained within its VaList.

This PR disables retagging entirely when copying variable arguments. It also adds a new, passing test case that would originally fail before this change.

cc: @RalfJung, @folkertdev

@rustbot

rustbot commented Jun 8, 2026

Copy link
Copy Markdown
Collaborator

Some changes occurred to the CTFE / Miri interpreter

cc @rust-lang/miri

miri is developed in its own repository. If possible, consider making this change to rust-lang/miri instead.

cc @rust-lang/miri

Some changes occurred to the CTFE machinery

cc @RalfJung, @oli-obk, @lcnr

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Jun 8, 2026
@rustbot

rustbot commented Jun 8, 2026

Copy link
Copy Markdown
Collaborator

r? @davidtwco

rustbot has assigned @davidtwco.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

Why was this reviewer chosen?

The reviewer was selected based on:

  • Owners of files modified in this PR: compiler, mir
  • compiler, mir expanded to 73 candidates
  • Random selection from 20 candidates

@folkertdev

Copy link
Copy Markdown
Contributor

r? me

Though I definitely want Ralf to have a look at this too

@rustbot rustbot assigned folkertdev and unassigned davidtwco Jun 8, 2026

@RalfJung RalfJung left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks. :) I have one question, the rest are nits.

@rustbot author

View changes since this review

Comment thread compiler/rustc_const_eval/src/interpret/call.rs Outdated
Comment thread src/tools/miri/tests/pass/both_borrows/c_variadics.rs

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Why is this just a TB test? It also applies to SB, doesn't it?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yup - I adjusted the test and moved it over to both_borrows.

@rustbot rustbot added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jun 9, 2026
@rustbot

rustbot commented Jun 9, 2026

Copy link
Copy Markdown
Collaborator

Reminder, once the PR becomes ready for a review, use @rustbot ready.

@icmccorm icmccorm force-pushed the ignore-retags-variadics branch from 885bef0 to 0c6954f Compare June 10, 2026 13:59
@rustbot

rustbot commented Jun 10, 2026

Copy link
Copy Markdown
Collaborator

This PR was rebased onto a different main commit. Here's a range-diff highlighting what actually changed.

Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers.

@icmccorm

Copy link
Copy Markdown
Contributor Author

@rustbot ready

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Jun 10, 2026

@folkertdev folkertdev left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@rustbot rustbot assigned RalfJung and unassigned folkertdev Jun 10, 2026
@rustbot

rustbot commented Jun 10, 2026

Copy link
Copy Markdown
Collaborator

RalfJung is not on the review rotation at the moment.
They may take a while to respond.

unsafe {
write_with_first_arg(&raw mut val, &val);
}
} No newline at end of file

@RalfJung RalfJung Jun 11, 2026

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Please add a trailing newline

View changes since the review

@RalfJung

Copy link
Copy Markdown
Member

This looks great, thanks! With the last nit resolved, please squash the commits, then we can land this. Please use the --keep-base flag when squashing so that the force-push diff is easier to review; do not rebase on the latest master branch. Then write @rustbot ready after you force-pushed the squashed PR.

@rustbot author

@rustbot rustbot added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jun 11, 2026
Co-authored-by: Ralf Jung <post@ralfj.de>
@icmccorm icmccorm force-pushed the ignore-retags-variadics branch from 0c6954f to cc89e06 Compare June 11, 2026 20:53
@icmccorm

Copy link
Copy Markdown
Contributor Author

@rustbot ready

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Jun 11, 2026
@RalfJung

Copy link
Copy Markdown
Member

@bors r=RalfJung,folkertdev rollup

@rust-bors

rust-bors Bot commented Jun 12, 2026

Copy link
Copy Markdown
Contributor

📌 Commit cc89e06 has been approved by RalfJung,folkertdev

It is now in the queue for this repository.

@rust-bors rust-bors Bot added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jun 12, 2026
GuillaumeGomez added a commit to GuillaumeGomez/rust that referenced this pull request Jun 12, 2026
…adics, r=RalfJung,folkertdev

Disable retagging for variadic arguments in const-eval

Fixes [rust-lang#5058](rust-lang/miri#5058) in Miri.

Retags occur on typed copies, which happen when we pass variadic arguments to a function. At the moment, variadic arguments receive `RetagMode::FnEntry` retags, which protects their permissions for the duration of the call. However, protection needs to be based on callee-side information, and the callee has now way of knowing what's contained within its `VaList`.

This PR disables retagging entirely when copying variable arguments. It also adds a new, passing test case that would originally fail before this change.

cc: @RalfJung, @folkertdev
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Jun 12, 2026
…adics, r=RalfJung,folkertdev

Disable retagging for variadic arguments in const-eval

Fixes [rust-lang#5058](rust-lang/miri#5058) in Miri.

Retags occur on typed copies, which happen when we pass variadic arguments to a function. At the moment, variadic arguments receive `RetagMode::FnEntry` retags, which protects their permissions for the duration of the call. However, protection needs to be based on callee-side information, and the callee has now way of knowing what's contained within its `VaList`.

This PR disables retagging entirely when copying variable arguments. It also adds a new, passing test case that would originally fail before this change.

cc: @RalfJung, @folkertdev
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Jun 12, 2026
…adics, r=RalfJung,folkertdev

Disable retagging for variadic arguments in const-eval

Fixes [rust-lang#5058](rust-lang/miri#5058) in Miri.

Retags occur on typed copies, which happen when we pass variadic arguments to a function. At the moment, variadic arguments receive `RetagMode::FnEntry` retags, which protects their permissions for the duration of the call. However, protection needs to be based on callee-side information, and the callee has now way of knowing what's contained within its `VaList`.

This PR disables retagging entirely when copying variable arguments. It also adds a new, passing test case that would originally fail before this change.

cc: @RalfJung, @folkertdev
rust-bors Bot pushed a commit that referenced this pull request Jun 12, 2026
…uwer

Rollup of 17 pull requests

Successful merges:

 - #156950 (Staticlib rename internal symbols)
 - #157322 (test pre-stabilization items on CI)
 - #157490 (Add field-wise CoerceShared reborrow tests)
 - #157655 (Make Share::share final and improve docs)
 - #157688 (Create experimental test job `aarch64-apple-macos-26` for evaluating `macos-26` runner images)
 - #157796 (rustdoc: Some more lazy formatting)
 - #157069 (Test that you can't implement Unpin for a compiler-generated future using TAIT)
 - #157202 (add #[rustc_no_writable] to slice::get_unchecked_mut)
 - #157622 (Disable retagging for variadic arguments in const-eval)
 - #157684 (-Zassumptions-on-binders: insert empty assumptions when entering binders in the solver)
 - #157695 (Extend capabilities of `TypeFoldable_Generic`)
 - #157752 (Rename `errors.rs` file to `diagnostics.rs` (6/N))
 - #157766 (interpret: avoid computing layout of sized raw pointee)
 - #157785 (fuchsia: Support AddressSanitizer on riscv64gc-unknown-fuchsia)
 - #157795 (revert 157013)
 - #157798 (Prevent approving PRs that wait for Crater or formal decisions)
 - #157803 (Rename `errors.rs` file to `diagnostics.rs` (7/N))
rust-bors Bot pushed a commit that referenced this pull request Jun 12, 2026
…uwer

Rollup of 17 pull requests

Successful merges:

 - #156950 (Staticlib rename internal symbols)
 - #157322 (test pre-stabilization items on CI)
 - #157490 (Add field-wise CoerceShared reborrow tests)
 - #157655 (Make Share::share final and improve docs)
 - #157688 (Create experimental test job `aarch64-apple-macos-26` for evaluating `macos-26` runner images)
 - #157796 (rustdoc: Some more lazy formatting)
 - #157069 (Test that you can't implement Unpin for a compiler-generated future using TAIT)
 - #157202 (add #[rustc_no_writable] to slice::get_unchecked_mut)
 - #157622 (Disable retagging for variadic arguments in const-eval)
 - #157684 (-Zassumptions-on-binders: insert empty assumptions when entering binders in the solver)
 - #157695 (Extend capabilities of `TypeFoldable_Generic`)
 - #157752 (Rename `errors.rs` file to `diagnostics.rs` (6/N))
 - #157766 (interpret: avoid computing layout of sized raw pointee)
 - #157785 (fuchsia: Support AddressSanitizer on riscv64gc-unknown-fuchsia)
 - #157795 (revert 157013)
 - #157798 (Prevent approving PRs that wait for Crater or formal decisions)
 - #157803 (Rename `errors.rs` file to `diagnostics.rs` (7/N))
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Jun 12, 2026
…adics, r=RalfJung,folkertdev

Disable retagging for variadic arguments in const-eval

Fixes [rust-lang#5058](rust-lang/miri#5058) in Miri.

Retags occur on typed copies, which happen when we pass variadic arguments to a function. At the moment, variadic arguments receive `RetagMode::FnEntry` retags, which protects their permissions for the duration of the call. However, protection needs to be based on callee-side information, and the callee has now way of knowing what's contained within its `VaList`.

This PR disables retagging entirely when copying variable arguments. It also adds a new, passing test case that would originally fail before this change.

cc: @RalfJung, @folkertdev
rust-bors Bot pushed a commit that referenced this pull request Jun 12, 2026
…uwer

Rollup of 23 pull requests

Successful merges:

 - #144220 (Add powerpc64-unknown-linux-gnuelfv2 target)
 - #153238 (debuginfo: slices are DW_TAG_array_type's)
 - #157112 (Update aarch64-unknown-freebsd target description)
 - #157322 (test pre-stabilization items on CI)
 - #157348 (Don't track cwd for `-Zremap-cwd-prefix` in incremental compilation)
 - #157490 (Add field-wise CoerceShared reborrow tests)
 - #157655 (Make Share::share final and improve docs)
 - #157672 (Region inference: Simplify initialisation of region values)
 - #157680 (Require `#[pin_v2]` for explicit pin-projection patterns)
 - #157688 (Create experimental test job `aarch64-apple-macos-26` for evaluating `macos-26` runner images)
 - #157796 (rustdoc: Some more lazy formatting)
 - #157818 (miri subtree update)
 - #157069 (Test that you can't implement Unpin for a compiler-generated future using TAIT)
 - #157079 (Don't recover `&raw EXPR` as a missing comma)
 - #157202 (add #[rustc_no_writable] to slice::get_unchecked_mut)
 - #157622 (Disable retagging for variadic arguments in const-eval)
 - #157684 (-Zassumptions-on-binders: insert empty assumptions when entering binders in the solver)
 - #157695 (Extend capabilities of `TypeFoldable_Generic`)
 - #157766 (interpret: avoid computing layout of sized raw pointee)
 - #157785 (fuchsia: Support AddressSanitizer on riscv64gc-unknown-fuchsia)
 - #157795 (revert 157013)
 - #157798 (Prevent approving PRs that wait for Crater or formal decisions)
 - #157803 (Rename `errors.rs` file to `diagnostics.rs` (7/N))

Failed merges:

 - #157752 (Rename `errors.rs` file to `diagnostics.rs` (6/N))
@rust-bors rust-bors Bot merged commit 4203236 into rust-lang:main Jun 12, 2026
12 checks passed
@rustbot rustbot added this to the 1.98.0 milestone Jun 12, 2026
rust-timer added a commit that referenced this pull request Jun 12, 2026
Rollup merge of #157622 - BorrowSanitizer:ignore-retags-variadics, r=RalfJung,folkertdev

Disable retagging for variadic arguments in const-eval

Fixes [#5058](rust-lang/miri#5058) in Miri.

Retags occur on typed copies, which happen when we pass variadic arguments to a function. At the moment, variadic arguments receive `RetagMode::FnEntry` retags, which protects their permissions for the duration of the call. However, protection needs to be based on callee-side information, and the callee has now way of knowing what's contained within its `VaList`.

This PR disables retagging entirely when copying variable arguments. It also adds a new, passing test case that would originally fail before this change.

cc: @RalfJung, @folkertdev
pull Bot pushed a commit to xtqqczze/rust-lang-miri that referenced this pull request Jun 13, 2026
…uwer

Rollup of 23 pull requests

Successful merges:

 - rust-lang/rust#144220 (Add powerpc64-unknown-linux-gnuelfv2 target)
 - rust-lang/rust#153238 (debuginfo: slices are DW_TAG_array_type's)
 - rust-lang/rust#157112 (Update aarch64-unknown-freebsd target description)
 - rust-lang/rust#157322 (test pre-stabilization items on CI)
 - rust-lang/rust#157348 (Don't track cwd for `-Zremap-cwd-prefix` in incremental compilation)
 - rust-lang/rust#157490 (Add field-wise CoerceShared reborrow tests)
 - rust-lang/rust#157655 (Make Share::share final and improve docs)
 - rust-lang/rust#157672 (Region inference: Simplify initialisation of region values)
 - rust-lang/rust#157680 (Require `#[pin_v2]` for explicit pin-projection patterns)
 - rust-lang/rust#157688 (Create experimental test job `aarch64-apple-macos-26` for evaluating `macos-26` runner images)
 - rust-lang/rust#157796 (rustdoc: Some more lazy formatting)
 - rust-lang/rust#157818 (miri subtree update)
 - rust-lang/rust#157069 (Test that you can't implement Unpin for a compiler-generated future using TAIT)
 - rust-lang/rust#157079 (Don't recover `&raw EXPR` as a missing comma)
 - rust-lang/rust#157202 (add #[rustc_no_writable] to slice::get_unchecked_mut)
 - rust-lang/rust#157622 (Disable retagging for variadic arguments in const-eval)
 - rust-lang/rust#157684 (-Zassumptions-on-binders: insert empty assumptions when entering binders in the solver)
 - rust-lang/rust#157695 (Extend capabilities of `TypeFoldable_Generic`)
 - rust-lang/rust#157766 (interpret: avoid computing layout of sized raw pointee)
 - rust-lang/rust#157785 (fuchsia: Support AddressSanitizer on riscv64gc-unknown-fuchsia)
 - rust-lang/rust#157795 (revert 157013)
 - rust-lang/rust#157798 (Prevent approving PRs that wait for Crater or formal decisions)
 - rust-lang/rust#157803 (Rename `errors.rs` file to `diagnostics.rs` (7/N))

Failed merges:

 - rust-lang/rust#157752 (Rename `errors.rs` file to `diagnostics.rs` (6/N))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Unexpected UB: retagging of variadic arguments

5 participants