Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix pointer provenance in <[T]>::copy_within #85610

Merged
merged 1 commit into from
May 26, 2021

Conversation

SkiFire13
Copy link
Contributor

Previously the self.as_mut_ptr() invalidated the pointer created by the first self.as_ptr(). This also triggered miri when run with -Zmiri-track-raw-pointers

@rust-highfive
Copy link
Collaborator

r? @Mark-Simulacrum

(rust-highfive has picked a reviewer for you, use r? to override)

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label May 23, 2021
@SkiFire13 SkiFire13 force-pushed the fix-copy-within-provenance branch 2 times, most recently from 5995594 to 8dfc24d Compare May 23, 2021 19:52
@oli-obk
Copy link
Contributor

oli-obk commented May 25, 2021

r? @oli-obk

@bors r+

@bors
Copy link
Contributor

bors commented May 25, 2021

📌 Commit d7341f3 has been approved by oli-obk

@bors bors 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 May 25, 2021
JohnTitor added a commit to JohnTitor/rust that referenced this pull request May 25, 2021
…e, r=oli-obk

Fix pointer provenance in <[T]>::copy_within

Previously the `self.as_mut_ptr()` invalidated the pointer created by the first `self.as_ptr()`. This also triggered miri when run with `-Zmiri-track-raw-pointers`
JohnTitor added a commit to JohnTitor/rust that referenced this pull request May 26, 2021
…e, r=oli-obk

Fix pointer provenance in <[T]>::copy_within

Previously the `self.as_mut_ptr()` invalidated the pointer created by the first `self.as_ptr()`. This also triggered miri when run with `-Zmiri-track-raw-pointers`
bors added a commit to rust-lang-ci/rust that referenced this pull request May 26, 2021
Rollup of 12 pull requests

Successful merges:

 - rust-lang#84048 (Avoid CJK legacy fonts in Windows)
 - rust-lang#85529 (doc: clarify Mutex::try_lock, etc. errors)
 - rust-lang#85590 (Fix bootstrap using host exe suffix for cargo)
 - rust-lang#85610 (Fix pointer provenance in <[T]>::copy_within)
 - rust-lang#85623 (Remove stray .stderr files)
 - rust-lang#85645 (Demote `ControlFlow::{from|into}_try` to `pub(crate)`)
 - rust-lang#85647 (Revert "Move llvm submodule updates to rustbuild")
 - rust-lang#85666 (Document shared_from_cow functions)
 - rust-lang#85668 (Fix tasklist example in rustdoc book.)
 - rust-lang#85672 (Move stability attribute for items under the `ip` feature)
 - rust-lang#85699 (Update books)
 - rust-lang#85701 (Update cargo)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit b7b9ce3 into rust-lang:master May 26, 2021
@rustbot rustbot added this to the 1.54.0 milestone May 26, 2021
@SkiFire13 SkiFire13 deleted the fix-copy-within-provenance branch May 26, 2021 10:39
bors added a commit to rust-lang/miri that referenced this pull request Jun 3, 2021
regression tests for pointer invalidation in core library slice methods

A fix for a pointer invalidation bug in `<[T]>::copy_within` has [landed](rust-lang/rust#85610) on the Rust master branch. This PR updates the `rust-version` file to the latest master commit hash and adds extra tests to the Miri test suite to ensure that regressions of this type of bug can be detected for various slice methods with the `-Zmiri-track-raw-pointers` flag.

I took the liberty of adding 2 extra  `#![feature]` attributes at the top of `slices.rs`, since there already was one unstable feature. I hope this is okay 😄

One thing I noticed when running the entire Miri test suite with `MIRIFLAGS="-Zmiri-track-raw-pointers" ./miri test` is that there are currently failing tests on the master branch:

```
failures:
    [ui] run-pass/align.rs
    [ui] run-pass/box.rs
    [ui] run-pass/concurrency/simple.rs
    [ui] run-pass/libc.rs
    [ui] run-pass/ptr_int_casts.rs
    [ui] run-pass/stacked-borrows/int-to-ptr.rs

test result: FAILED. 199 passed; 6 failed; 1 ignored; 0 measured; 0 filtered out; finished in 12.95s
```

These failures were not fixed in this PR and already existed prior to this PR. I haven't investigated these yet, but am interested in helping out if possible!

Thanks!
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.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants