From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by finch.gentoo.org (Postfix) with ESMTPS id 86C841382C5 for ; Sun, 18 Apr 2021 10:30:23 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id D183DE077C; Sun, 18 Apr 2021 10:30:22 +0000 (UTC) Received: from smtp.gentoo.org (dev.gentoo.org [IPv6:2001:470:ea4a:1:5054:ff:fec7:86e4]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id A7D39E077C for ; Sun, 18 Apr 2021 10:30:22 +0000 (UTC) Received: from oystercatcher.gentoo.org (oystercatcher.gentoo.org [148.251.78.52]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id 3C38E335C7E for ; Sun, 18 Apr 2021 10:30:21 +0000 (UTC) Received: from localhost.localdomain (localhost [IPv6:::1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id 998535C9 for ; Sun, 18 Apr 2021 10:30:19 +0000 (UTC) From: "Georgy Yakovlev" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Georgy Yakovlev" Message-ID: <1618741763.c9982cad131a4c026810796850ccb60243ff9406.gyakovlev@gentoo> Subject: [gentoo-commits] repo/gentoo:master commit in: dev-lang/rust/, dev-lang/rust/files/ X-VCS-Repository: repo/gentoo X-VCS-Files: dev-lang/rust/files/1.51.0-CVE-2020-36323.patch dev-lang/rust/files/1.51.0-CVE-2021-28876.patch dev-lang/rust/files/1.51.0-CVE-2021-28878.patch dev-lang/rust/files/1.51.0-CVE-2021-28879.patch dev-lang/rust/files/1.51.0-CVE-2021-31162.patch dev-lang/rust/files/rustc-1.51.0-backport-pr81728.patch dev-lang/rust/files/rustc-1.51.0-backport-pr81741.patch dev-lang/rust/files/rustc-1.51.0-backport-pr82289.patch dev-lang/rust/files/rustc-1.51.0-backport-pr82292.patch dev-lang/rust/files/rustc-1.51.0-backport-pr83629.patch dev-lang/rust/rust-1.51.0-r1.ebuild dev-lang/rust/rust-1.51.0-r2.ebuild X-VCS-Directories: dev-lang/rust/ dev-lang/rust/files/ X-VCS-Committer: gyakovlev X-VCS-Committer-Name: Georgy Yakovlev X-VCS-Revision: c9982cad131a4c026810796850ccb60243ff9406 X-VCS-Branch: master Date: Sun, 18 Apr 2021 10:30:19 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org X-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply X-Archives-Salt: 3480f74e-71d4-4116-b98d-d4df597de457 X-Archives-Hash: e0145f88deae4cda0494935ee69ac12b commit: c9982cad131a4c026810796850ccb60243ff9406 Author: Georgy Yakovlev gentoo org> AuthorDate: Sun Apr 18 10:28:48 2021 +0000 Commit: Georgy Yakovlev gentoo org> CommitDate: Sun Apr 18 10:29:23 2021 +0000 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=c9982cad dev-lang/rust: security revbump with 2 more patches switched to fedora's rebased patches Bug: https://bugs.gentoo.org/782367 Package-Manager: Portage-3.0.18, Repoman-3.0.3 Signed-off-by: Georgy Yakovlev gentoo.org> ...3.patch => rustc-1.51.0-backport-pr81728.patch} | 26 ++++--- ...6.patch => rustc-1.51.0-backport-pr81741.patch} | 11 ++- ...9.patch => rustc-1.51.0-backport-pr82289.patch} | 32 +++++--- ...8.patch => rustc-1.51.0-backport-pr82292.patch} | 36 +++++---- ...2.patch => rustc-1.51.0-backport-pr83629.patch} | 89 +++++----------------- ...rust-1.51.0-r1.ebuild => rust-1.51.0-r2.ebuild} | 10 +-- 6 files changed, 91 insertions(+), 113 deletions(-) diff --git a/dev-lang/rust/files/1.51.0-CVE-2020-36323.patch b/dev-lang/rust/files/rustc-1.51.0-backport-pr81728.patch similarity index 89% rename from dev-lang/rust/files/1.51.0-CVE-2020-36323.patch rename to dev-lang/rust/files/rustc-1.51.0-backport-pr81728.patch index b4f2215cc23..20373f42d30 100644 --- a/dev-lang/rust/files/1.51.0-CVE-2020-36323.patch +++ b/dev-lang/rust/files/rustc-1.51.0-backport-pr81728.patch @@ -1,4 +1,4 @@ -From 6d43225bfb08ec91f7476b76c7fec632c4a096ef Mon Sep 17 00:00:00 2001 +From 70f17ca715d3d7e2fd79cc909b95fd3a6357c13e Mon Sep 17 00:00:00 2001 From: Yechan Bae Date: Wed, 3 Feb 2021 16:36:33 -0500 Subject: [PATCH 1/2] Fixes #80335 @@ -9,10 +9,10 @@ Subject: [PATCH 1/2] Fixes #80335 2 files changed, 54 insertions(+), 18 deletions(-) diff --git a/library/alloc/src/str.rs b/library/alloc/src/str.rs -index 70e0c7dba5eab..a7584c6b65100 100644 +index 70e0c7dba5ea..a7584c6b6510 100644 --- a/library/alloc/src/str.rs +++ b/library/alloc/src/str.rs -@@ -90,8 +90,8 @@ impl> Join<&str> for [S] { +@@ -90,8 +90,8 @@ fn join(slice: &Self, sep: &str) -> String { } } @@ -49,7 +49,7 @@ index 70e0c7dba5eab..a7584c6b65100 100644 } macro_rules! copy_slice_and_advance { -@@ -153,7 +156,7 @@ where +@@ -153,7 +156,7 @@ fn join_generic_copy(slice: &[S], sep: &[T]) -> Vec // if the `len` calculation overflows, we'll panic // we would have run out of memory anyway and the rest of the function requires // the entire Vec pre-allocated for safety @@ -58,7 +58,7 @@ index 70e0c7dba5eab..a7584c6b65100 100644 .checked_mul(iter.len()) .and_then(|n| { slice.iter().map(|s| s.borrow().as_ref().len()).try_fold(n, usize::checked_add) -@@ -161,22 +164,25 @@ where +@@ -161,22 +164,25 @@ fn join_generic_copy(slice: &[S], sep: &[T]) -> Vec .expect("attempt to join into collection with len > usize::MAX"); // crucial for safety @@ -97,7 +97,7 @@ index 70e0c7dba5eab..a7584c6b65100 100644 result } diff --git a/library/alloc/tests/str.rs b/library/alloc/tests/str.rs -index 604835e6cc4a6..6df8d8c2f354f 100644 +index 604835e6cc4a..6df8d8c2f354 100644 --- a/library/alloc/tests/str.rs +++ b/library/alloc/tests/str.rs @@ -160,6 +160,36 @@ fn test_join_for_different_lengths_with_long_separator() { @@ -137,8 +137,11 @@ index 604835e6cc4a6..6df8d8c2f354f 100644 #[test] #[cfg_attr(miri, ignore)] // Miri is too slow fn test_unsafe_slice() { +-- +2.31.1 -From 26a62701e42d10c03ce5f2f911e7d5edeefa2f0f Mon Sep 17 00:00:00 2001 + +From 10020817d2e6756be1ff2ac3c182af97cf7fe904 Mon Sep 17 00:00:00 2001 From: Yechan Bae Date: Sat, 20 Mar 2021 13:42:54 -0400 Subject: [PATCH 2/2] Update the comment @@ -148,10 +151,10 @@ Subject: [PATCH 2/2] Update the comment 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/library/alloc/src/str.rs b/library/alloc/src/str.rs -index a7584c6b65100..4d1e876457b8e 100644 +index a7584c6b6510..4d1e876457b8 100644 --- a/library/alloc/src/str.rs +++ b/library/alloc/src/str.rs -@@ -163,7 +163,7 @@ where +@@ -163,7 +163,7 @@ fn join_generic_copy(slice: &[S], sep: &[T]) -> Vec }) .expect("attempt to join into collection with len > usize::MAX"); @@ -160,7 +163,7 @@ index a7584c6b65100..4d1e876457b8e 100644 let mut result = Vec::with_capacity(reserved_len); debug_assert!(result.capacity() >= reserved_len); -@@ -178,9 +178,9 @@ where +@@ -178,9 +178,9 @@ fn join_generic_copy(slice: &[S], sep: &[T]) -> Vec // massive improvements possible (~ x2) let remain = specialize_for_lengths!(sep, target, iter; 0, 1, 2, 3, 4); @@ -173,3 +176,6 @@ index a7584c6b65100..4d1e876457b8e 100644 let result_len = reserved_len - remain.len(); result.set_len(result_len); } +-- +2.31.1 + diff --git a/dev-lang/rust/files/1.51.0-CVE-2021-28876.patch b/dev-lang/rust/files/rustc-1.51.0-backport-pr81741.patch similarity index 85% rename from dev-lang/rust/files/1.51.0-CVE-2021-28876.patch rename to dev-lang/rust/files/rustc-1.51.0-backport-pr81741.patch index 3a0af024143..8ef22eea56f 100644 --- a/dev-lang/rust/files/1.51.0-CVE-2021-28876.patch +++ b/dev-lang/rust/files/rustc-1.51.0-backport-pr81741.patch @@ -1,4 +1,4 @@ -From 86a4b27475aab52b998c15f5758540697cc9cff0 Mon Sep 17 00:00:00 2001 +From 40d3f2d7ef5835317fe9df9ecc01f4c363def4fd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Dr=C3=B6ge?= Date: Thu, 4 Feb 2021 10:23:01 +0200 Subject: [PATCH] Increment `self.index` before calling @@ -12,15 +12,17 @@ allowed according to the API contract of `TrustedRandomAccess` for `!Clone`. Fixes https://github.com/rust-lang/rust/issues/81740 + +(cherry picked from commit 86a4b27475aab52b998c15f5758540697cc9cff0) --- library/core/src/iter/adapters/zip.rs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/library/core/src/iter/adapters/zip.rs b/library/core/src/iter/adapters/zip.rs -index 98b8dca961407..9f98353452006 100644 +index 98b8dca96140..9f9835345200 100644 --- a/library/core/src/iter/adapters/zip.rs +++ b/library/core/src/iter/adapters/zip.rs -@@ -198,12 +198,13 @@ where +@@ -198,12 +198,13 @@ fn next(&mut self) -> Option<(A::Item, B::Item)> { Some((self.a.__iterator_get_unchecked(i), self.b.__iterator_get_unchecked(i))) } } else if A::may_have_side_effect() && self.index < self.a.size() { @@ -37,3 +39,6 @@ index 98b8dca961407..9f98353452006 100644 None } else { None +-- +2.31.1 + diff --git a/dev-lang/rust/files/1.51.0-CVE-2021-28879.patch b/dev-lang/rust/files/rustc-1.51.0-backport-pr82289.patch similarity index 75% rename from dev-lang/rust/files/1.51.0-CVE-2021-28879.patch rename to dev-lang/rust/files/rustc-1.51.0-backport-pr82289.patch index 3407a2ddf2f..5cf54331977 100644 --- a/dev-lang/rust/files/1.51.0-CVE-2021-28879.patch +++ b/dev-lang/rust/files/rustc-1.51.0-backport-pr82289.patch @@ -1,37 +1,42 @@ -From 66a260617a88ed1ad55a46f03c5a90d5ad3004d3 Mon Sep 17 00:00:00 2001 +From 5222e2ba2d97cd716a379b4ae6bc62c5f7c2dd36 Mon Sep 17 00:00:00 2001 From: Giacomo Stevanato Date: Fri, 19 Feb 2021 12:15:37 +0100 Subject: [PATCH 1/3] Increment self.len in specialized ZipImpl to avoid underflow in size_hint +(cherry picked from commit 66a260617a88ed1ad55a46f03c5a90d5ad3004d3) --- library/core/src/iter/adapters/zip.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/library/core/src/iter/adapters/zip.rs b/library/core/src/iter/adapters/zip.rs -index 9d0f4e3618fc5..ce48016afcd50 100644 +index 9f9835345200..f08bfac837fe 100644 --- a/library/core/src/iter/adapters/zip.rs +++ b/library/core/src/iter/adapters/zip.rs -@@ -200,6 +200,7 @@ where - } else if A::MAY_HAVE_SIDE_EFFECT && self.index < self.a.size() { +@@ -200,6 +200,7 @@ fn next(&mut self) -> Option<(A::Item, B::Item)> { + } else if A::may_have_side_effect() && self.index < self.a.size() { let i = self.index; self.index += 1; + self.len += 1; // match the base implementation's potential side effects // SAFETY: we just checked that `i` < `self.a.len()` unsafe { +-- +2.31.1 -From 8b9ac4d4155c74db5b317046033ab9c05a09e351 Mon Sep 17 00:00:00 2001 + +From d39669fc8282830a374d19d204f7b4ee8eb1e381 Mon Sep 17 00:00:00 2001 From: Giacomo Stevanato Date: Fri, 19 Feb 2021 12:16:12 +0100 Subject: [PATCH 2/3] Add test for underflow in specialized Zip's size_hint +(cherry picked from commit 8b9ac4d4155c74db5b317046033ab9c05a09e351) --- library/core/tests/iter/adapters/zip.rs | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/library/core/tests/iter/adapters/zip.rs b/library/core/tests/iter/adapters/zip.rs -index 1fce0951e365e..a597710392952 100644 +index 1fce0951e365..a59771039295 100644 --- a/library/core/tests/iter/adapters/zip.rs +++ b/library/core/tests/iter/adapters/zip.rs @@ -245,3 +245,23 @@ fn test_double_ended_zip() { @@ -58,27 +63,34 @@ index 1fce0951e365e..a597710392952 100644 + panic!(); + } +} +-- +2.31.1 + -From aeb4ea739efb70e0002a4a9c4c7b8027dd0620b3 Mon Sep 17 00:00:00 2001 +From 4b382167dd5ed5a6eac0cf314bfb86e3704b6e76 Mon Sep 17 00:00:00 2001 From: Giacomo Stevanato Date: Fri, 19 Feb 2021 12:17:48 +0100 Subject: [PATCH 3/3] Remove useless comparison since now self.index <= self.len is an invariant +(cherry picked from commit aeb4ea739efb70e0002a4a9c4c7b8027dd0620b3) --- library/core/src/iter/adapters/zip.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library/core/src/iter/adapters/zip.rs b/library/core/src/iter/adapters/zip.rs -index ce48016afcd50..817fc2a51e981 100644 +index f08bfac837fe..dcbcb1ce7200 100644 --- a/library/core/src/iter/adapters/zip.rs +++ b/library/core/src/iter/adapters/zip.rs -@@ -259,7 +259,7 @@ where +@@ -261,7 +261,7 @@ fn next_back(&mut self) -> Option<(A::Item, B::Item)> if sz_a != sz_b { let sz_a = self.a.size(); - if A::MAY_HAVE_SIDE_EFFECT && sz_a > self.len { + if a_side_effect && sz_a > self.len { - for _ in 0..sz_a - cmp::max(self.len, self.index) { + for _ in 0..sz_a - self.len { self.a.next_back(); } } +-- +2.31.1 + diff --git a/dev-lang/rust/files/1.51.0-CVE-2021-28878.patch b/dev-lang/rust/files/rustc-1.51.0-backport-pr82292.patch similarity index 74% rename from dev-lang/rust/files/1.51.0-CVE-2021-28878.patch rename to dev-lang/rust/files/rustc-1.51.0-backport-pr82292.patch index f319ab5e8c4..4baf72a2619 100644 --- a/dev-lang/rust/files/1.51.0-CVE-2021-28878.patch +++ b/dev-lang/rust/files/rustc-1.51.0-backport-pr82292.patch @@ -1,18 +1,19 @@ -From 2371914a05f8f2763dffe6e2511d0870bcd6b461 Mon Sep 17 00:00:00 2001 +From 0babb88efc4d36f3defafc3c3c0343793fa05d52 Mon Sep 17 00:00:00 2001 From: Giacomo Stevanato Date: Wed, 3 Mar 2021 21:09:01 +0100 Subject: [PATCH 1/2] Prevent Zip specialization from calling __iterator_get_unchecked twice with the same index after calling next_back +(cherry picked from commit 2371914a05f8f2763dffe6e2511d0870bcd6b461) --- library/core/src/iter/adapters/zip.rs | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/library/core/src/iter/adapters/zip.rs b/library/core/src/iter/adapters/zip.rs -index 817fc2a51e981..ea7a809c6badb 100644 +index dcbcb1ce7200..7dac0c63ca2d 100644 --- a/library/core/src/iter/adapters/zip.rs +++ b/library/core/src/iter/adapters/zip.rs -@@ -13,9 +13,10 @@ use crate::iter::{InPlaceIterable, SourceIter, TrustedLen}; +@@ -13,9 +13,10 @@ pub struct Zip { a: A, b: B, @@ -24,7 +25,7 @@ index 817fc2a51e981..ea7a809c6badb 100644 } impl Zip { pub(in crate::iter) fn new(a: A, b: B) -> Zip { -@@ -110,6 +111,7 @@ where +@@ -110,6 +111,7 @@ impl ZipImpl for Zip b, index: 0, // unused len: 0, // unused @@ -32,7 +33,7 @@ index 817fc2a51e981..ea7a809c6badb 100644 } } -@@ -184,8 +186,9 @@ where +@@ -184,8 +186,9 @@ impl ZipImpl for Zip B: TrustedRandomAccess + Iterator, { fn new(a: A, b: B) -> Self { @@ -44,24 +45,24 @@ index 817fc2a51e981..ea7a809c6badb 100644 } #[inline] -@@ -197,7 +200,7 @@ where +@@ -197,7 +200,7 @@ fn next(&mut self) -> Option<(A::Item, B::Item)> { unsafe { Some((self.a.__iterator_get_unchecked(i), self.b.__iterator_get_unchecked(i))) } -- } else if A::MAY_HAVE_SIDE_EFFECT && self.index < self.a.size() { -+ } else if A::MAY_HAVE_SIDE_EFFECT && self.index < self.a_len { +- } else if A::may_have_side_effect() && self.index < self.a.size() { ++ } else if A::may_have_side_effect() && self.index < self.a_len { let i = self.index; self.index += 1; self.len += 1; -@@ -262,6 +265,7 @@ where +@@ -264,6 +267,7 @@ fn next_back(&mut self) -> Option<(A::Item, B::Item)> for _ in 0..sz_a - self.len { self.a.next_back(); } + self.a_len = self.len; } let sz_b = self.b.size(); - if B::MAY_HAVE_SIDE_EFFECT && sz_b > self.len { -@@ -273,6 +277,7 @@ where + if b_side_effect && sz_b > self.len { +@@ -275,6 +279,7 @@ fn next_back(&mut self) -> Option<(A::Item, B::Item)> } if self.index < self.len { self.len -= 1; @@ -69,21 +70,25 @@ index 817fc2a51e981..ea7a809c6badb 100644 let i = self.len; // SAFETY: `i` is smaller than the previous value of `self.len`, // which is also smaller than or equal to `self.a.len()` and `self.b.len()` +-- +2.31.1 -From c1bfb9a78db6d481be1d03355672712c766e20b0 Mon Sep 17 00:00:00 2001 + +From 19af66a6f3e2bbb4780bb9eae7eb53bd13e3dd0f Mon Sep 17 00:00:00 2001 From: Giacomo Stevanato Date: Fri, 19 Feb 2021 15:25:09 +0100 Subject: [PATCH 2/2] Add relevant test +(cherry picked from commit c1bfb9a78db6d481be1d03355672712c766e20b0) --- library/core/tests/iter/adapters/zip.rs | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/library/core/tests/iter/adapters/zip.rs b/library/core/tests/iter/adapters/zip.rs -index a597710392952..000c15f72c886 100644 +index a59771039295..000c15f72c88 100644 --- a/library/core/tests/iter/adapters/zip.rs +++ b/library/core/tests/iter/adapters/zip.rs -@@ -265,3 +265,26 @@ fn test_issue_82282() { +@@ -265,3 +265,26 @@ fn overflowed_zip(arr: &[i32]) -> impl Iterator { panic!(); } } @@ -110,3 +115,6 @@ index a597710392952..000c15f72c886 100644 + zip.next(); + assert_eq!(called.get(), 1); +} +-- +2.31.1 + diff --git a/dev-lang/rust/files/1.51.0-CVE-2021-31162.patch b/dev-lang/rust/files/rustc-1.51.0-backport-pr83629.patch similarity index 61% rename from dev-lang/rust/files/1.51.0-CVE-2021-31162.patch rename to dev-lang/rust/files/rustc-1.51.0-backport-pr83629.patch index fd9165ea3c5..7f68d95cc7f 100644 --- a/dev-lang/rust/files/1.51.0-CVE-2021-31162.patch +++ b/dev-lang/rust/files/rustc-1.51.0-backport-pr83629.patch @@ -1,7 +1,7 @@ -From fa89c0fbcfa8f4d44f153b1195ec5a305540ffc4 Mon Sep 17 00:00:00 2001 +From 3834e7b7393bf1a0d7df02ccd1d2e896c1465769 Mon Sep 17 00:00:00 2001 From: The8472 Date: Mon, 29 Mar 2021 04:22:34 +0200 -Subject: [PATCH 1/3] add testcase for double-drop during Vec in-place +Subject: [PATCH 1/2] add testcase for double-drop during Vec in-place collection --- @@ -9,10 +9,10 @@ Subject: [PATCH 1/3] add testcase for double-drop during Vec in-place 1 file changed, 37 insertions(+), 1 deletion(-) diff --git a/library/alloc/tests/vec.rs b/library/alloc/tests/vec.rs -index c142536cd2dfb..b926c697d58ab 100644 +index 5c7ff67bc621..4cdb7eefcdf1 100644 --- a/library/alloc/tests/vec.rs +++ b/library/alloc/tests/vec.rs -@@ -1027,7 +1027,7 @@ fn test_from_iter_specialization_head_tail_drop() { +@@ -954,7 +954,7 @@ fn test_from_iter_specialization_head_tail_drop() { } #[test] @@ -21,7 +21,7 @@ index c142536cd2dfb..b926c697d58ab 100644 let drop_count: Vec<_> = (0..=2).map(|_| Rc::new(())).collect(); let src: Vec<_> = drop_count.iter().cloned().collect(); let iter = src.into_iter(); -@@ -1050,6 +1050,42 @@ fn test_from_iter_specialization_panic_drop() { +@@ -977,6 +977,42 @@ fn test_from_iter_specialization_panic_drop() { ); } @@ -64,11 +64,14 @@ index c142536cd2dfb..b926c697d58ab 100644 #[test] fn test_cow_from() { let borrowed: &[_] = &["borrowed", "(slice)"]; +-- +2.31.1 -From 421f5d282a51e130d3ca7c4524d8ad6753437da9 Mon Sep 17 00:00:00 2001 + +From 8e2706343e1ce1c5a2d3a2ceaaaa010aaeb21d93 Mon Sep 17 00:00:00 2001 From: The8472 Date: Mon, 29 Mar 2021 04:22:48 +0200 -Subject: [PATCH 2/3] fix double-drop in in-place collect specialization +Subject: [PATCH 2/2] fix double-drop in in-place collect specialization --- library/alloc/src/vec/into_iter.rs | 27 ++++++++++++++------- @@ -76,10 +79,10 @@ Subject: [PATCH 2/3] fix double-drop in in-place collect specialization 2 files changed, 20 insertions(+), 11 deletions(-) diff --git a/library/alloc/src/vec/into_iter.rs b/library/alloc/src/vec/into_iter.rs -index bcbdffabc7fbe..324e894bafd23 100644 +index f131d06bb18f..74adced53f6d 100644 --- a/library/alloc/src/vec/into_iter.rs +++ b/library/alloc/src/vec/into_iter.rs -@@ -85,20 +85,29 @@ impl IntoIter { +@@ -85,20 +85,29 @@ fn as_raw_mut_slice(&mut self) -> *mut [T] { ptr::slice_from_raw_parts_mut(self.ptr as *mut T, self.len()) } @@ -119,10 +122,10 @@ index bcbdffabc7fbe..324e894bafd23 100644 } diff --git a/library/alloc/src/vec/source_iter_marker.rs b/library/alloc/src/vec/source_iter_marker.rs -index 50882fc17673e..e857d284d3ab6 100644 +index 8c0e95559fa1..9301f7a5184e 100644 --- a/library/alloc/src/vec/source_iter_marker.rs +++ b/library/alloc/src/vec/source_iter_marker.rs -@@ -69,9 +69,9 @@ where +@@ -78,9 +78,9 @@ impl SpecFromIter for Vec } // drop any remaining values at the tail of the source @@ -132,64 +135,8 @@ index 50882fc17673e..e857d284d3ab6 100644 + // if the drop panics then we also leak any elements collected into dst_buf + src.forget_allocation_drop_remaining(); - let vec = unsafe { Vec::from_raw_parts(dst_buf, len, cap) }; - - -From 328a5e040780984c60dde2db300dad4f1323c39d Mon Sep 17 00:00:00 2001 -From: The8472 -Date: Fri, 2 Apr 2021 23:06:05 +0200 -Subject: [PATCH 3/3] cleanup leak after test to make miri happy - ---- - library/alloc/tests/vec.rs | 16 +++++++++++++--- - 1 file changed, 13 insertions(+), 3 deletions(-) + let vec = unsafe { + let len = dst.offset_from(dst_buf) as usize; +-- +2.31.1 -diff --git a/library/alloc/tests/vec.rs b/library/alloc/tests/vec.rs -index b926c697d58ab..b9fe07c73e55e 100644 ---- a/library/alloc/tests/vec.rs -+++ b/library/alloc/tests/vec.rs -@@ -1,3 +1,4 @@ -+use alloc::boxed::Box; - use std::borrow::Cow; - use std::cell::Cell; - use std::collections::TryReserveError::*; -@@ -1056,14 +1057,14 @@ fn test_from_iter_specialization_panic_during_drop_leaks() { - - #[derive(Debug)] - enum Droppable { -- DroppedTwice(Box), -+ DroppedTwice, - PanicOnDrop, - } - - impl Drop for Droppable { - fn drop(&mut self) { - match self { -- Droppable::DroppedTwice(_) => { -+ Droppable::DroppedTwice => { - unsafe { - DROP_COUNTER += 1; - } -@@ -1078,12 +1079,21 @@ fn test_from_iter_specialization_panic_during_drop_leaks() { - } - } - -+ let mut to_free: *mut Droppable = core::ptr::null_mut(); -+ let mut cap = 0; -+ - let _ = std::panic::catch_unwind(AssertUnwindSafe(|| { -- let v = vec![Droppable::DroppedTwice(Box::new(123)), Droppable::PanicOnDrop]; -+ let mut v = vec![Droppable::DroppedTwice, Droppable::PanicOnDrop]; -+ to_free = v.as_mut_ptr(); -+ cap = v.capacity(); - let _ = v.into_iter().take(0).collect::>(); - })); - - assert_eq!(unsafe { DROP_COUNTER }, 1); -+ // clean up the leak to keep miri happy -+ unsafe { -+ Vec::from_raw_parts(to_free, 0, cap); -+ } - } - - #[test] diff --git a/dev-lang/rust/rust-1.51.0-r1.ebuild b/dev-lang/rust/rust-1.51.0-r2.ebuild similarity index 98% rename from dev-lang/rust/rust-1.51.0-r1.ebuild rename to dev-lang/rust/rust-1.51.0-r2.ebuild index e2f25109d3e..2212ce60518 100644 --- a/dev-lang/rust/rust-1.51.0-r1.ebuild +++ b/dev-lang/rust/rust-1.51.0-r2.ebuild @@ -136,11 +136,11 @@ PATCHES=( "${FILESDIR}"/1.47.0-ignore-broken-and-non-applicable-tests.patch "${FILESDIR}"/1.49.0-gentoo-musl-target-specs.patch "${FILESDIR}"/1.51.0-bootstrap-panic.patch - "${FILESDIR}"/1.51.0-CVE-2020-36323.patch - "${FILESDIR}"/1.51.0-CVE-2021-28876.patch - #"${FILESDIR}"/1.51.0-CVE-2021-28878.patch - #"${FILESDIR}"/1.51.0-CVE-2021-28879.patch - "${FILESDIR}"/1.51.0-CVE-2021-31162.patch + "${FILESDIR}"/rustc-1.51.0-backport-pr81728.patch + "${FILESDIR}"/rustc-1.51.0-backport-pr81741.patch + "${FILESDIR}"/rustc-1.51.0-backport-pr82289.patch + "${FILESDIR}"/rustc-1.51.0-backport-pr82292.patch + "${FILESDIR}"/rustc-1.51.0-backport-pr83629.patch ) S="${WORKDIR}/${MY_P}-src"