-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Use after free in core::iter::repeat_n #130140
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Labels
A-iterators
Area: Iterators
C-bug
Category: This is a bug.
I-unsound
Issue: A soundness hole (worst kind of bug), see: https://en.wikipedia.org/wiki/Soundness
P-critical
Critical priority
T-libs
Relevant to the library team, which will review and decide on the PR/issue.
Comments
same issue with its fn main() {
let x = std::iter::repeat_n(String::from("use after free"), 0);
println!("{x:?}");
} |
cc @scottmcm, I think you implemented this. ^^ |
WG-prioritization assigning priority (Zulip discussion). @rustbot label -I-prioritize +P-critical |
5 tasks
GuillaumeGomez
added a commit
to GuillaumeGomez/rust
that referenced
this issue
Sep 26, 2024
…homcc,traviscross Document subtleties of `ManuallyDrop` After seeing rust-lang#130140 and rust-lang#130141, I figured that `ManuallyDrop` needs documentation explaining its subtleties, hence this PR. See also rust-lang/unsafe-code-guidelines#245
rust-timer
added a commit
to rust-lang-ci/rust
that referenced
this issue
Sep 27, 2024
Rollup merge of rust-lang#130279 - theemathas:manually-drop-docs, r=thomcc,traviscross Document subtleties of `ManuallyDrop` After seeing rust-lang#130140 and rust-lang#130141, I figured that `ManuallyDrop` needs documentation explaining its subtleties, hence this PR. See also rust-lang/unsafe-code-guidelines#245
# for free
to join this conversation on GitHub.
Already have an account?
# to comment
Labels
A-iterators
Area: Iterators
C-bug
Category: This is a bug.
I-unsound
Issue: A soundness hole (worst kind of bug), see: https://en.wikipedia.org/wiki/Soundness
P-critical
Critical priority
T-libs
Relevant to the library team, which will review and decide on the PR/issue.
core::iter::repeat_n
currently unconditionally derivesClone
. However,it will also drop its inner object if
n
is 0, which can cause a UAF if it's cloned afterwards.Running the above program segfaults:
Edit: Made the segfault quicker/more reliable.
The text was updated successfully, but these errors were encountered: