[dev] `rust`: update to version 1.56.1. (#1678)

This commit is contained in:
Pawel Winogrodzki 2021-11-30 10:26:43 -08:00 коммит произвёл GitHub
Родитель 54b8679f9d
Коммит 73b6190701
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
16 изменённых файлов: 113 добавлений и 638 удалений

Просмотреть файл

@ -24,25 +24,9 @@ Release: 1%{?dist}
# - For the value of "--mtime" use the date "2021-04-26 00:00Z" to simplify future updates.
Source0: https://github.com/Azure/iotedge/archive/%{version}.tar.gz#/%{name}-%{version}.tar.gz
# Note: the azure-iotedge-%%{version}-cargo.tar.gz file is created by capturing the contents downloaded into /root/.cargo
# To update the tar.gz run the following:
# Locally modify SPEC by removing SOURCE1 and adding a long sleep at the end of the %%build section such as:
# sleep 30m
# Build the package locally, and set RUN_CHECK=y to enable network access in the chroot.
# Check the log file to see when the cargo contents are downloaded and the build enters the sleep
# From another terminal create the archive:
# sudo tar --sort=name \
# --mtime="2021-04-26 00:00Z" \
# --owner=0 --group=0 --numeric-owner \
# --pax-option=exthdr.name=%d/PaxHeaders/%f,delete=atime,delete=ctime \
# -C [CBL-Mariner_repo_dir]/build/worker/chroot/azure-iotedge-%%{version}-%%{release}/root \
# -czpf azure-iotedge-%%{version}-cargo.tar.gz .cargo
#
# NOTES:
# - You require GNU tar version 1.28+.
# - The additional options enable generation of a tarball with the same hash every time regardless of the environment.
# See: https://reproducible-builds.org/docs/archives/
# - For the value of "--mtime" use the date "2021-04-26 00:00Z" to simplify future updates.
# Note: the azure-iotedge-%%{version}-cargo.tar.gz file contains a cache created by capturing the contents downloaded into $CARGO_HOME.
# To update the cache run:
# [repo_root]/toolkit/scripts/build_cargo_cache.sh azure-iotedge-%%{version}.tar.gz azure-iotedge-%%{version}/edgelet
Source1: %{name}-%{version}-cargo.tar.gz
License: MIT
Group: Applications/File

Просмотреть файл

@ -9,6 +9,9 @@ Vendor: Microsoft Corporation
Distribution: Mariner
#Source0: %{url}/archive/v%{version}.tar.gz
Source0: %{name}-%{version}.tar.gz
# Note: the cloud-hypervisor-%%{version}-cargo.tar.gz file contains a cache created by capturing the contents downloaded into $CARGO_HOME.
# To update the cache run:
# [repo_root]/toolkit/scripts/build_cargo_cache.sh cloud-hypervisor-%%{version}.tar.gz
Source1: %{name}-%{version}-cargo.tar.gz
ExclusiveArch: x86_64

Просмотреть файл

@ -1,111 +0,0 @@
From 4588490cdceb407fd5754045d173be7ea381b794 Mon Sep 17 00:00:00 2001
From: Thomas Crain <thcrain@microsoft.com>
Date: Mon, 26 Apr 2021 12:40:04 -0500
Subject: [PATCH 1/6] Patch CVE-2020-36317
Backporting the following to 1.47.0:
https://github.com/rust-lang/rust/pull/78499
https://github.com/rust-lang/rust/pull/82554
---
library/alloc/src/string.rs | 37 ++++++++++++++++++++++-------------
library/alloc/tests/string.rs | 15 ++++++++++++++
2 files changed, 38 insertions(+), 14 deletions(-)
diff --git a/library/alloc/src/string.rs b/library/alloc/src/string.rs
index 05690e19d23..9387f4edde3 100644
--- a/library/alloc/src/string.rs
+++ b/library/alloc/src/string.rs
@@ -1231,35 +1231,44 @@ impl String {
where
F: FnMut(char) -> bool,
{
+ struct SetLenOnDrop<'a> {
+ s: &'a mut String,
+ idx: usize,
+ del_bytes: usize,
+ }
+
+ impl<'a> Drop for SetLenOnDrop<'a> {
+ fn drop(&mut self) {
+ let new_len = self.idx - self.del_bytes;
+ debug_assert!(new_len <= self.s.len());
+ unsafe { self.s.vec.set_len(new_len) };
+ }
+ }
+
let len = self.len();
- let mut del_bytes = 0;
- let mut idx = 0;
+ let mut guard = SetLenOnDrop { s: self, idx: 0, del_bytes: 0 };
- while idx < len {
- let ch = unsafe { self.get_unchecked(idx..len).chars().next().unwrap() };
+ while guard.idx < len {
+ let ch = unsafe { guard.s.get_unchecked(guard.idx..len).chars().next().unwrap() };
let ch_len = ch.len_utf8();
if !f(ch) {
- del_bytes += ch_len;
- } else if del_bytes > 0 {
+ guard.del_bytes += ch_len;
+ } else if guard.del_bytes > 0 {
unsafe {
ptr::copy(
- self.vec.as_ptr().add(idx),
- self.vec.as_mut_ptr().add(idx - del_bytes),
+ guard.s.vec.as_ptr().add(guard.idx),
+ guard.s.vec.as_mut_ptr().add(guard.idx - guard.del_bytes),
ch_len,
);
}
}
// Point idx to the next char
- idx += ch_len;
+ guard.idx += ch_len;
}
- if del_bytes > 0 {
- unsafe {
- self.vec.set_len(len - del_bytes);
- }
- }
+ drop(guard);
}
/// Inserts a character into this `String` at a byte position.
diff --git a/library/alloc/tests/string.rs b/library/alloc/tests/string.rs
index d38655af78c..61587987172 100644
--- a/library/alloc/tests/string.rs
+++ b/library/alloc/tests/string.rs
@@ -1,6 +1,7 @@
use std::borrow::Cow;
use std::collections::TryReserveError::*;
use std::mem::size_of;
+use std::panic;
pub trait IntoCow<'a, B: ?Sized>
where
@@ -374,6 +375,20 @@ fn test_retain() {
s.retain(|_| false);
assert_eq!(s, "");
+
+ let mut s = String::from("0è0");
+ let _ = panic::catch_unwind(panic::AssertUnwindSafe(|| {
+ let mut count = 0;
+ s.retain(|_| {
+ count += 1;
+ match count {
+ 1 => false,
+ 2 => true,
+ _ => panic!(),
+ }
+ });
+ }));
+ assert!(std::str::from_utf8(s.as_bytes()).is_ok());
}
#[test]
--
2.25.1

Просмотреть файл

@ -1,142 +0,0 @@
From 358bf9bf74dc7ce040e9be8232057d2904ba4fd9 Mon Sep 17 00:00:00 2001
From: Thomas Crain <thcrain@microsoft.com>
Date: Mon, 26 Apr 2021 14:28:30 -0500
Subject: [PATCH] Fix CVE-2020-36323
Backported to 1.47.0:
https://github.com/rust-lang/rust/pull/81728
---
library/alloc/src/str.rs | 44 ++++++++++++++++++++++----------------
library/alloc/tests/str.rs | 30 ++++++++++++++++++++++++++
2 files changed, 55 insertions(+), 19 deletions(-)
diff --git a/library/alloc/src/str.rs b/library/alloc/src/str.rs
index 339592728ac..7e55f2fa579 100644
--- a/library/alloc/src/str.rs
+++ b/library/alloc/src/str.rs
@@ -90,8 +90,8 @@ impl<S: Borrow<str>> Join<&str> for [S] {
}
}
-macro_rules! spezialize_for_lengths {
- ($separator:expr, $target:expr, $iter:expr; $($num:expr),*) => {
+macro_rules! specialize_for_lengths {
+ ($separator:expr, $target:expr, $iter:expr; $($num:expr),*) => {{
let mut target = $target;
let iter = $iter;
let sep_bytes = $separator;
@@ -102,7 +102,8 @@ macro_rules! spezialize_for_lengths {
$num => {
for s in iter {
copy_slice_and_advance!(target, sep_bytes);
- copy_slice_and_advance!(target, s.borrow().as_ref());
+ let content_bytes = s.borrow().as_ref();
+ copy_slice_and_advance!(target, content_bytes);
}
},
)*
@@ -110,11 +111,13 @@ macro_rules! spezialize_for_lengths {
// arbitrary non-zero size fallback
for s in iter {
copy_slice_and_advance!(target, sep_bytes);
- copy_slice_and_advance!(target, s.borrow().as_ref());
+ let content_bytes = s.borrow().as_ref();
+ copy_slice_and_advance!(target, content_bytes);
}
}
}
- };
+ target
+ }}
}
macro_rules! copy_slice_and_advance {
@@ -153,30 +156,33 @@ where
// 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
- let len = sep_len
+ let reserved_len = sep_len
.checked_mul(iter.len())
.and_then(|n| {
slice.iter().map(|s| s.borrow().as_ref().len()).try_fold(n, usize::checked_add)
})
.expect("attempt to join into collection with len > usize::MAX");
- // crucial for safety
- let mut result = Vec::with_capacity(len);
- assert!(result.capacity() >= len);
+ // prepare an uninitialized buffer
+ let mut result = Vec::with_capacity(reserved_len);
+ debug_assert!(result.capacity() >= reserved_len);
result.extend_from_slice(first.borrow().as_ref());
unsafe {
- {
- let pos = result.len();
- let target = result.get_unchecked_mut(pos..len);
-
- // copy separator and slices over without bounds checks
- // generate loops with hardcoded offsets for small separators
- // massive improvements possible (~ x2)
- spezialize_for_lengths!(sep, target, iter; 0, 1, 2, 3, 4);
- }
- result.set_len(len);
+ let pos = result.len();
+ let target = result.get_unchecked_mut(pos..reserved_len);
+
+ // copy separator and slices over without bounds checks
+ // generate loops with hardcoded offsets for small separators
+ // massive improvements possible (~ x2)
+ let remain = specialize_for_lengths!(sep, target, iter; 0, 1, 2, 3, 4);
+
+ // A weird borrow implementation may return different
+ // slices for the length calculation and the actual copy.
+ // Make sure we don't expose uninitialized bytes to the caller.
+ let result_len = reserved_len - remain.len();
+ result.set_len(result_len);
}
result
}
diff --git a/library/alloc/tests/str.rs b/library/alloc/tests/str.rs
index b20cf076aca..5a3190103c3 100644
--- a/library/alloc/tests/str.rs
+++ b/library/alloc/tests/str.rs
@@ -1921,3 +1921,33 @@ fn different_str_pattern_forwarding_lifetimes() {
foo::<&str>("x");
}
+
+#[test]
+fn test_join_isue_80335() {
+ use core::{borrow::Borrow, cell::Cell};
+
+ struct WeirdBorrow {
+ state: Cell<bool>,
+ }
+
+ impl Default for WeirdBorrow {
+ fn default() -> Self {
+ WeirdBorrow { state: Cell::new(false) }
+ }
+ }
+
+ impl Borrow<str> for WeirdBorrow {
+ fn borrow(&self) -> &str {
+ let state = self.state.get();
+ if state {
+ "0"
+ } else {
+ self.state.set(true);
+ "123456"
+ }
+ }
+ }
+
+ let arr: [WeirdBorrow; 3] = Default::default();
+ test_join!("0-0-0", arr, "-");
+}
--
2.25.1

Просмотреть файл

@ -1,58 +0,0 @@
From 4095a00f08f855366c60ae00040edc1a5e64dd7c Mon Sep 17 00:00:00 2001
From: Thomas Crain <thcrain@microsoft.com>
Date: Mon, 26 Apr 2021 12:42:46 -0500
Subject: [PATCH 2/6] Patch CVE-2021-28875
Backport to 1.47.0 from:
https://github.com/rust-lang/rust/pull/80895
---
library/std/src/io/mod.rs | 23 ++++++++++-------------
1 file changed, 10 insertions(+), 13 deletions(-)
diff --git a/library/std/src/io/mod.rs b/library/std/src/io/mod.rs
index 462b696db40..0a3be236ac9 100644
--- a/library/std/src/io/mod.rs
+++ b/library/std/src/io/mod.rs
@@ -362,7 +362,6 @@ where
{
let start_len = buf.len();
let mut g = Guard { len: buf.len(), buf };
- let ret;
loop {
if g.len == g.buf.len() {
unsafe {
@@ -380,22 +379,20 @@ where
r.initializer().initialize(&mut g.buf[g.len..]);
}
}
-
- match r.read(&mut g.buf[g.len..]) {
- Ok(0) => {
- ret = Ok(g.len - start_len);
- break;
+ let buf = &mut g.buf[g.len..];
+ match r.read(buf) {
+ Ok(0) => return Ok(g.len - start_len),
+ Ok(n) => {
+ // We can't allow bogus values from read. If it is too large, the returned vec could have its length
+ // set past its capacity, or if it overflows the vec could be shortened which could create an invalid
+ // string if this is called via read_to_string.
+ assert!(n <= buf.len());
+ g.len += n;
}
- Ok(n) => g.len += n,
Err(ref e) if e.kind() == ErrorKind::Interrupted => {}
- Err(e) => {
- ret = Err(e);
- break;
- }
+ Err(e) => return Err(e),
}
}
-
- ret
}
pub(crate) fn default_read_vectored<F>(read: F, bufs: &mut [IoSliceMut<'_>]) -> Result<usize>
--
2.25.1

Просмотреть файл

@ -1,34 +0,0 @@
From adb9ae35768ccf0a457693950d5b128d8de2372f Mon Sep 17 00:00:00 2001
From: Thomas Crain <thcrain@microsoft.com>
Date: Mon, 26 Apr 2021 13:41:49 -0500
Subject: [PATCH 4/6] Fix CVE-2021-28876
Backport to 1.47.0:
https://github.com/rust-lang/rust/pull/81741
---
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 cde4d8f3c06..8a9f4b8af1e 100644
--- a/library/core/src/iter/adapters/zip.rs
+++ b/library/core/src/iter/adapters/zip.rs
@@ -201,12 +201,13 @@ where
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() {
+ let i = self.index;
+ self.index += 1;
// match the base implementation's potential side effects
- // SAFETY: we just checked that `self.index` < `self.a.len()`
+ // SAFETY: we just checked that `i` < `self.a.len()`
unsafe {
- self.a.__iterator_get_unchecked(self.index);
+ self.a.__iterator_get_unchecked(i);
}
- self.index += 1;
None
} else {
None
--
2.25.1

Просмотреть файл

@ -1,53 +0,0 @@
From a297d4e6d60244482b6889111080a461bd474426 Mon Sep 17 00:00:00 2001
From: Thomas Crain <thcrain@microsoft.com>
Date: Mon, 26 Apr 2021 13:38:46 -0500
Subject: [PATCH 3/6] Patch CVE-2021-28877
Backported to 1.47.0:
https://github.com/rust-lang/rust/pull/80670/files
---
library/core/src/iter/adapters/zip.rs | 1 +
library/core/tests/iter.rs | 18 ++++++++++++++++++
2 files changed, 19 insertions(+)
diff --git a/library/core/src/iter/adapters/zip.rs b/library/core/src/iter/adapters/zip.rs
index 581ac6e0d82..cde4d8f3c06 100644
--- a/library/core/src/iter/adapters/zip.rs
+++ b/library/core/src/iter/adapters/zip.rs
@@ -289,6 +289,7 @@ where
#[inline]
unsafe fn get_unchecked(&mut self, idx: usize) -> <Self as Iterator>::Item {
+ let idx = self.index + idx;
// SAFETY: the caller must uphold the contract for
// `Iterator::get_unchecked`.
unsafe { (self.a.__iterator_get_unchecked(idx), self.b.__iterator_get_unchecked(idx)) }
diff --git a/library/core/tests/iter.rs b/library/core/tests/iter.rs
index 00e3972c42f..803dc5d1698 100644
--- a/library/core/tests/iter.rs
+++ b/library/core/tests/iter.rs
@@ -3222,3 +3222,21 @@ fn test_flatten_non_fused_inner() {
assert_eq!(iter.next(), Some(1));
assert_eq!(iter.next(), None);
}
+
+#[test]
+fn test_zip_trusted_random_access_composition() {
+ let a = [0, 1, 2, 3, 4];
+ let b = a;
+ let c = a;
+
+ let a = a.iter().copied();
+ let b = b.iter().copied();
+ let mut c = c.iter().copied();
+ c.next();
+
+ let mut z1 = a.zip(b);
+ assert_eq!(z1.next().unwrap(), (0, 0));
+
+ let mut z2 = z1.zip(c);
+ assert_eq!(z2.next().unwrap(), ((1, 1), 1));
+}
\ No newline at end of file
--
2.25.1

Просмотреть файл

@ -1,106 +0,0 @@
From a461afc27b43155dcf16430bc071682466011501 Mon Sep 17 00:00:00 2001
From: Thomas Crain <thcrain@microsoft.com>
Date: Mon, 26 Apr 2021 13:49:28 -0500
Subject: [PATCH 6/6] Fix CVE-2021-28878
Backported to 1.47.0:
https://github.com/rust-lang/rust/pull/82292
---
library/core/src/iter/adapters/zip.rs | 13 +++++++++----
library/core/tests/iter.rs | 23 +++++++++++++++++++++++
2 files changed, 32 insertions(+), 4 deletions(-)
diff --git a/library/core/src/iter/adapters/zip.rs b/library/core/src/iter/adapters/zip.rs
index e480bf2bc28..79f22583e5d 100644
--- a/library/core/src/iter/adapters/zip.rs
+++ b/library/core/src/iter/adapters/zip.rs
@@ -16,9 +16,10 @@ use super::super::{DoubleEndedIterator, ExactSizeIterator, FusedIterator, Iterat
pub struct Zip<A, B> {
a: A,
b: B,
- // index and len are only used by the specialized version of zip
+ // index, len and a_len are only used by the specialized version of zip
index: usize,
len: usize,
+ a_len: usize,
}
impl<A: Iterator, B: Iterator> Zip<A, B> {
pub(in super::super) fn new(a: A, b: B) -> Zip<A, B> {
@@ -113,6 +114,7 @@ where
b,
index: 0, // unused
len: 0, // unused
+ a_len: 0, // unused
}
}
@@ -187,8 +189,9 @@ where
B: TrustedRandomAccess + Iterator,
{
fn new(a: A, b: B) -> Self {
- let len = cmp::min(a.size(), b.size());
- Zip { a, b, index: 0, len }
+ let a_len = a.size();
+ let len = cmp::min(a_len, b.size());
+ Zip { a, b, index: 0, len, a_len }
}
#[inline]
@@ -200,7 +203,7 @@ where
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 {
let i = self.index;
self.index += 1;
self.len += 1;
@@ -267,6 +270,7 @@ where
for _ in 0..sz_a - self.len {
self.a.next_back();
}
+ self.a_len = self.len;
}
let sz_b = self.b.size();
if b_side_effect && sz_b > self.len {
@@ -278,6 +282,7 @@ where
}
if self.index < self.len {
self.len -= 1;
+ self.a_len -= 1;
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()`
diff --git a/library/core/tests/iter.rs b/library/core/tests/iter.rs
index 913764894ec..bbadb5820e9 100644
--- a/library/core/tests/iter.rs
+++ b/library/core/tests/iter.rs
@@ -3260,3 +3260,26 @@ fn test_issue_82282() {
panic!();
}
}
+
+#[test]
+fn test_issue_82291() {
+ use std::cell::Cell;
+
+ let mut v1 = [()];
+ let v2 = [()];
+
+ let called = Cell::new(0);
+
+ let mut zip = v1
+ .iter_mut()
+ .map(|r| {
+ called.set(called.get() + 1);
+ r
+ })
+ .zip(&v2);
+
+ zip.next_back();
+ assert_eq!(called.get(), 1);
+ zip.next();
+ assert_eq!(called.get(), 1);
+}
--
2.25.1

Просмотреть файл

@ -1,67 +0,0 @@
From 173e9c1d6dc4195e9223d6c1f7fe95017c12fd9f Mon Sep 17 00:00:00 2001
From: Thomas Crain <thcrain@microsoft.com>
Date: Mon, 26 Apr 2021 13:44:39 -0500
Subject: [PATCH 5/6] Fix CVE-2021-28879
Backport to 1.47.0:
https://github.com/rust-lang/rust/pull/82289
---
library/core/src/iter/adapters/zip.rs | 3 ++-
library/core/tests/iter.rs | 22 +++++++++++++++++++++-
2 files changed, 23 insertions(+), 2 deletions(-)
diff --git a/library/core/src/iter/adapters/zip.rs b/library/core/src/iter/adapters/zip.rs
index 8a9f4b8af1e..e480bf2bc28 100644
--- a/library/core/src/iter/adapters/zip.rs
+++ b/library/core/src/iter/adapters/zip.rs
@@ -203,6 +203,7 @@ where
} 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 {
@@ -263,7 +264,7 @@ where
if sz_a != sz_b {
let sz_a = self.a.size();
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();
}
}
diff --git a/library/core/tests/iter.rs b/library/core/tests/iter.rs
index 803dc5d1698..913764894ec 100644
--- a/library/core/tests/iter.rs
+++ b/library/core/tests/iter.rs
@@ -3239,4 +3239,24 @@ fn test_zip_trusted_random_access_composition() {
let mut z2 = z1.zip(c);
assert_eq!(z2.next().unwrap(), ((1, 1), 1));
-}
\ No newline at end of file
+}
+
+#[test]
+fn test_issue_82282() {
+ fn overflowed_zip(arr: &[i32]) -> impl Iterator<Item = (i32, &())> {
+ static UNIT_EMPTY_ARR: [(); 0] = [];
+
+ let mapped = arr.into_iter().map(|i| *i);
+ let mut zipped = mapped.zip(UNIT_EMPTY_ARR.iter());
+ zipped.next();
+ zipped
+ }
+
+ let arr = [1, 2, 3];
+ let zip = overflowed_zip(&arr).zip(overflowed_zip(&arr));
+
+ assert_eq!(zip.size_hint(), (0, Some(0)));
+ for _ in zip {
+ panic!();
+ }
+}
--
2.25.1

Просмотреть файл

@ -1,12 +1,12 @@
{
"Signatures": {
"cargo-0.47.0-aarch64-unknown-linux-gnu.tar.gz": "5413c7c73ea0c2323042e932f7be7cea51312ad1eff5c4c86c5be1b36da9698f",
"cargo-0.47.0-x86_64-unknown-linux-gnu.tar.gz": "30e494f3848d0335870698e438eaa22388d3226c9786aa282e4fd41fb9cd164d",
"rust-1.47.0-cargo.tar.gz": "b45ab93e0538844a0ba90cf1788f8fb284cd44a07bbfc95dd43a2ae8cd8eb87e",
"rust-std-1.46.0-aarch64-unknown-linux-gnu.tar.gz": "eaa7cfd73e96b6ce03498398f4bd9ded73870fe3c5db980038a4863c37157597",
"rust-std-1.46.0-x86_64-unknown-linux-gnu.tar.gz": "ac04aef80423f612c0079829b504902de27a6997214eb58ab0765d02f7ec1dbc",
"rustc-1.46.0-aarch64-unknown-linux-gnu.tar.gz": "41239ece19c79250a205e5b2fae60b242bba4bf72b687bccc88f011e66a872b6",
"rustc-1.46.0-x86_64-unknown-linux-gnu.tar.gz": "4c0c740cfb86047ae8131019597f26382a9b8c289eab2f21069f74a5a4976a26",
"rustc-1.47.0-src.tar.xz": "ec2c81d2d34890486094a6407589be96161e4e301c238332d32c6dbae4f38ea2"
"cargo-1.55.0-aarch64-unknown-linux-gnu.tar.gz": "48bc8751f548b08643fbdea7756ccda35f0762492e95ea41ca41137290f56513",
"cargo-1.55.0-x86_64-unknown-linux-gnu.tar.gz": "bb18c74aea07fa29c7169ce78756dfd08c07da08c584874e09fa6929c8267ec1",
"rust-1.56.1-cargo.tar.gz": "0e097904d09d6094751a9b216ac5745e739c179c429e0bb1517dbb44349e7952",
"rust-std-1.55.0-aarch64-unknown-linux-gnu.tar.gz": "e30063a259e32cd0e31baadcee82112ef840e0f654d5128dd79fc715ede92058",
"rust-std-1.55.0-x86_64-unknown-linux-gnu.tar.gz": "c07c5ce96b86364601c0c471bb85105e80a5e345b3e4b3e2674e541cc2fdefcf",
"rustc-1.55.0-aarch64-unknown-linux-gnu.tar.gz": "31dbbc1395f5a545c114e778552159713977dec423bca5705bd4c92ee3840cb1",
"rustc-1.55.0-x86_64-unknown-linux-gnu.tar.gz": "9da098b2df01124f2c4b9789767151521f4bab98f50befdc75a691cece0c0d00",
"rustc-1.56.1-src.tar.gz": "c3898dfaadaa193dc88ddbc5345946a163211b58621df1cfff70186b4fc79511"
}
}

Просмотреть файл

@ -1,39 +1,41 @@
# Prevent librustc_driver from inadvertently being listed as a requirement
%global __requires_exclude ^librustc_driver-
# Release date and version of stage 0 compiler can be found in "src/stage0.txt" inside the extracted "Source0".
# Look for "date:" and "rustc:".
%define release_date 2021-09-09
%define stage0_version 1.55.0
Summary: Rust Programming Language
Name: rust
Version: 1.47.0
Release: 5%{?dist}
Version: 1.56.1
Release: 1%{?dist}
License: ASL 2.0 AND MIT
Vendor: Microsoft Corporation
Distribution: Mariner
Group: Applications/System
URL: https://www.rust-lang.org/
Source0: https://static.rust-lang.org/dist/rustc-%{version}-src.tar.xz
Source0: https://static.rust-lang.org/dist/rustc-%{version}-src.tar.gz
# Note: the rust-%%{version}-cargo.tar.gz file contains a cache created by capturing the contents downloaded into $CARGO_HOME.
# To update the cache run:
# [repo_root]/toolkit/scripts/build_cargo_cache.sh rustc-%%{version}-src.tar.gz
Source1: %{name}-%{version}-cargo.tar.gz
Source2: https://static.rust-lang.org/dist/2020-08-27/cargo-0.47.0-x86_64-unknown-linux-gnu.tar.gz
Source3: https://static.rust-lang.org/dist/2020-08-27/rustc-1.46.0-x86_64-unknown-linux-gnu.tar.gz
Source4: https://static.rust-lang.org/dist/2020-08-27/rust-std-1.46.0-x86_64-unknown-linux-gnu.tar.gz
Source5: https://static.rust-lang.org/dist/2020-08-27/cargo-0.47.0-aarch64-unknown-linux-gnu.tar.gz
Source6: https://static.rust-lang.org/dist/2020-08-27/rustc-1.46.0-aarch64-unknown-linux-gnu.tar.gz
Source7: https://static.rust-lang.org/dist/2020-08-27/rust-std-1.46.0-aarch64-unknown-linux-gnu.tar.gz
Patch0: CVE-2020-36317.patch
Patch1: CVE-2021-28875.patch
Patch2: CVE-2021-28877.patch
Patch3: CVE-2021-28876.patch
Patch4: CVE-2021-28879.patch
Patch5: CVE-2021-28878.patch
Patch6: CVE-2020-36323.patch
Source2: https://static.rust-lang.org/dist/%{release_date}/cargo-%{stage0_version}-x86_64-unknown-linux-gnu.tar.gz
Source3: https://static.rust-lang.org/dist/%{release_date}/rustc-%{stage0_version}-x86_64-unknown-linux-gnu.tar.gz
Source4: https://static.rust-lang.org/dist/%{release_date}/rust-std-%{stage0_version}-x86_64-unknown-linux-gnu.tar.gz
Source5: https://static.rust-lang.org/dist/%{release_date}/cargo-%{stage0_version}-aarch64-unknown-linux-gnu.tar.gz
Source6: https://static.rust-lang.org/dist/%{release_date}/rustc-%{stage0_version}-aarch64-unknown-linux-gnu.tar.gz
Source7: https://static.rust-lang.org/dist/%{release_date}/rust-std-%{stage0_version}-aarch64-unknown-linux-gnu.tar.gz
BuildRequires: binutils
BuildRequires: cmake
BuildRequires: curl-devel
BuildRequires: git
BuildRequires: glibc
BuildRequires: python2
BuildRequires: ninja-build
BuildRequires: python3
%if %{with_check}
BuildRequires: python-xml
BuildRequires: python3-xml
%endif
Provides: cargo = %{version}-%{release}
%description
@ -43,7 +45,7 @@ Rust Programming Language
# Setup .cargo directory
mkdir -p $HOME
pushd $HOME
tar xf %{SOURCE1} --no-same-owner
tar -xf %{SOURCE1} --no-same-owner
popd
%autosetup -p1 -n rustc-%{version}-src
@ -53,17 +55,17 @@ popd
sed -i "s/tarball_suffix = '.tar.xz' if support_xz() else '.tar.gz'/tarball_suffix = '.tar.gz'/g" src/bootstrap/bootstrap.py
# Setup build/cache directory
%define BUILD_CACHE_DIR build/cache/2020-08-27/
mkdir -pv %{BUILD_CACHE_DIR}
BUILD_CACHE_DIR="build/cache/%{release_date}"
mkdir -pv "$BUILD_CACHE_DIR"
%ifarch x86_64
mv %{SOURCE2} %{BUILD_CACHE_DIR}
mv %{SOURCE3} %{BUILD_CACHE_DIR}
mv %{SOURCE4} %{BUILD_CACHE_DIR}
mv %{SOURCE2} "$BUILD_CACHE_DIR"
mv %{SOURCE3} "$BUILD_CACHE_DIR"
mv %{SOURCE4} "$BUILD_CACHE_DIR"
%endif
%ifarch aarch64
mv %{SOURCE5} %{BUILD_CACHE_DIR}
mv %{SOURCE6} %{BUILD_CACHE_DIR}
mv %{SOURCE7} %{BUILD_CACHE_DIR}
mv %{SOURCE5} "$BUILD_CACHE_DIR"
mv %{SOURCE6} "$BUILD_CACHE_DIR"
mv %{SOURCE7} "$BUILD_CACHE_DIR"
%endif
%build
@ -72,24 +74,19 @@ export CFLAGS="`echo " %{build_cflags} " | sed 's/ -g//'`"
export CXXFLAGS="`echo " %{build_cxxflags} " | sed 's/ -g//'`"
sh ./configure --prefix=%{_prefix} --enable-extended --tools="cargo"
# Exporting SUDO_USER=root bypasses a check in the python bootstrap that
# SUDO_USER=root bypasses a check in the python bootstrap that
# makes rust refuse to pull sources from the internet
export USER=root
export SUDO_USER=root
make %{?_smp_mflags}
USER=root SUDO_USER=root %make_build
%check
make check
%make_build check
%install
export USER=root
export SUDO_USER=root
make DESTDIR=%{buildroot} install
USER=root SUDO_USER=root %make_install
rm %{buildroot}%{_docdir}/%{name}/html/.lock
rm %{buildroot}%{_docdir}/%{name}/*.old
%post -p /sbin/ldconfig
%postun -p /sbin/ldconfig
%ldconfig_scriptlets
%files
%license LICENSE-MIT
@ -100,6 +97,7 @@ rm %{buildroot}%{_docdir}/%{name}/*.old
%{_mandir}/man1/*
%{_libdir}/lib*.so
%{_libdir}/rustlib/*
%{_libexecdir}/cargo-credential-1password
%{_bindir}/rust-gdb
%{_bindir}/rust-gdbgui
%doc %{_docdir}/%{name}/html/*
@ -116,6 +114,10 @@ rm %{buildroot}%{_docdir}/%{name}/*.old
%{_sysconfdir}/bash_completion.d/cargo
%changelog
* Wed Nov 24 2021 Pawel Winogrodzki <pawelwi@microsoft.com> - 1.56.1-1
- Updating to version 1.56.1.
- Switching to building with Python 3.
* Mon May 17 2021 Thomas Crain <thcrain@microsoft.com> - 1.47.0-5
- Add provides for 'cargo' from the base package

Просмотреть файл

@ -8372,8 +8372,8 @@
"type": "other",
"other": {
"name": "rust",
"version": "1.47.0",
"downloadUrl": "https://static.rust-lang.org/dist/rustc-1.47.0-src.tar.xz"
"version": "1.56.1",
"downloadUrl": "https://static.rust-lang.org/dist/rustc-1.56.1-src.tar.gz"
}
}
},

Просмотреть файл

@ -230,6 +230,7 @@ p11-kit-trust-0.23.22-3.cm2.aarch64.rpm
ca-certificates-shared-20200720-20.cm2.noarch.rpm
ca-certificates-tools-20200720-20.cm2.noarch.rpm
ca-certificates-base-20200720-20.cm2.noarch.rpm
ca-certificates-20200720-20.cm2.noarch.rpm
dwz-0.13-4.cm2.aarch64.rpm
unzip-6.0-19.cm2.aarch64.rpm
python3-3.7.10-3.cm2.aarch64.rpm

Просмотреть файл

@ -230,6 +230,7 @@ p11-kit-trust-0.23.22-3.cm2.x86_64.rpm
ca-certificates-shared-20200720-20.cm2.noarch.rpm
ca-certificates-tools-20200720-20.cm2.noarch.rpm
ca-certificates-base-20200720-20.cm2.noarch.rpm
ca-certificates-20200720-20.cm2.noarch.rpm
dwz-0.13-4.cm2.x86_64.rpm
unzip-6.0-19.cm2.x86_64.rpm
python3-3.7.10-3.cm2.x86_64.rpm

Просмотреть файл

@ -42,7 +42,6 @@ generate_toolchain () {
# Remove specific packages that are not needed in pkggen_core
remove_packages_for_pkggen_core () {
sed -i '/alsa-lib-/d' $TmpPkgGen
sed -i '/ca-certificates-[0-9]/d' $TmpPkgGen
sed -i '/ca-certificates-legacy/d' $TmpPkgGen
sed -i '/libtasn1-d/d' $TmpPkgGen
sed -i '/libpkgconf-devel/d' $TmpPkgGen
@ -296,6 +295,7 @@ generate_pkggen_core () {
grep "^ca-certificates-shared-" $TmpPkgGen
grep "^ca-certificates-tools-" $TmpPkgGen
grep "^ca-certificates-base-" $TmpPkgGen
grep "^ca-certificates-[0-9]" $TmpPkgGen
grep "^dwz-" $TmpPkgGen
grep "^unzip-" $TmpPkgGen
grep "^python3-" $TmpPkgGen

Просмотреть файл

@ -0,0 +1,55 @@
#!/bin/bash
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.
set -e
temp_dir=$(mktemp -d)
function clean-up {
rm -rf "$temp_dir"
}
trap clean-up EXIT
tarball_name=$1
cache_name=${tarball_name%.*}
if [[ "$cache_name" =~ \.tar$ ]]
then
cache_name=${cache_name%.*}
fi
cache_tarball_name="$cache_name-cargo.tar.gz"
if [[ $# -ge 2 ]]
then
directory_name=$2
else
directory_name=$cache_name
fi
if [[ -f "$tarball_name" ]]
then
cp "$tarball_name" "$temp_dir"
else
echo "Tarball '$tarball_name' doesn't exist. Will attempt to download from blobstorage."
wget -q "https://cblmarinerstorage.blob.core.windows.net/sources/core/$tarball_name" -O "$temp_dir/$tarball_name"
echo "Download successful."
fi
pushd "$temp_dir" &> /dev/null
echo "Extracting $tarball_name."
tar -xf "$tarball_name"
pushd "$directory_name" &> /dev/null
echo "Fetching dependencies to a temporary cache."
CARGO_HOME=$(pwd)/.cargo cargo fetch
echo "Compressing the cache."
tar --sort=name --mtime="2021-04-26 00:00Z" --owner=0 --group=0 --numeric-owner --pax-option=exthdr.name=%d/PaxHeaders/%f,delete=atime,delete=ctime -cf "$cache_tarball_name" .cargo
popd &> /dev/null
popd &> /dev/null
mv "$temp_dir/$directory_name/$cache_tarball_name" .
echo "Done:"
sha256sum "$cache_tarball_name"