From 8b7ec4f72c7ecdac452c51247691aab05a541c21 Mon Sep 17 00:00:00 2001 From: Nicholas Bishop Date: Thu, 1 Aug 2024 15:17:58 -0400 Subject: [PATCH 1/4] uefi: Fix lifetimes in device_path TryFrom<&[u8]> impls The missing lifetime means that the &[u8] buffer could be freed while the &DevicePath still exists, which is UB. (cherry picked from commit a9e48c2760b082365612f7fe6f5ad36ccfb4ade4) --- uefi/CHANGELOG.md | 8 ++++++++ uefi/src/proto/device_path/mod.rs | 6 +++--- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/uefi/CHANGELOG.md b/uefi/CHANGELOG.md index c0cf43177..3f54ecbd8 100644 --- a/uefi/CHANGELOG.md +++ b/uefi/CHANGELOG.md @@ -1,6 +1,14 @@ # uefi - [Unreleased] + +# uefi - 0.30.0 (unreleased) +## Changed +- **Breaking:**: Fixed a bug in the impls of `TryFrom<&[u8]>` for + `&DevicePathHeader`, `&DevicePathNode` and `&DevicePath` that could lead to + memory unsafety. See . + + # uefi - 0.29.0 (2024-07-02) ## Added diff --git a/uefi/src/proto/device_path/mod.rs b/uefi/src/proto/device_path/mod.rs index 185a4e447..52ce35417 100644 --- a/uefi/src/proto/device_path/mod.rs +++ b/uefi/src/proto/device_path/mod.rs @@ -119,7 +119,7 @@ pub struct DevicePathHeader { pub length: u16, } -impl<'a> TryFrom<&[u8]> for &'a DevicePathHeader { +impl<'a> TryFrom<&'a [u8]> for &'a DevicePathHeader { type Error = ByteConversionError; fn try_from(bytes: &[u8]) -> Result { @@ -265,7 +265,7 @@ impl PartialEq for DevicePathNode { } } -impl<'a> TryFrom<&[u8]> for &'a DevicePathNode { +impl<'a> TryFrom<&'a [u8]> for &'a DevicePathNode { type Error = ByteConversionError; fn try_from(bytes: &[u8]) -> Result { @@ -516,7 +516,7 @@ impl PartialEq for DevicePath { } } -impl<'a> TryFrom<&[u8]> for &'a DevicePath { +impl<'a> TryFrom<&'a [u8]> for &'a DevicePath { type Error = ByteConversionError; fn try_from(bytes: &[u8]) -> Result { From 8b2e5ff9e8010c773fbf1deafec72143f42de08b Mon Sep 17 00:00:00 2001 From: Nicholas Bishop Date: Fri, 2 Aug 2024 11:20:35 -0400 Subject: [PATCH 2/4] release: uefi-0.30.0 This release contains a cherry-pick of https://github.com/rust-osdev/uefi-rs/pull/1282. --- Cargo.lock | 2 +- book/src/tutorial/app.md | 2 +- template/Cargo.toml | 2 +- uefi-raw/src/capsule.rs | 2 +- uefi/CHANGELOG.md | 3 +-- uefi/Cargo.toml | 2 +- 6 files changed, 6 insertions(+), 7 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index fecb0d9ec..386dc81ff 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -853,7 +853,7 @@ dependencies = [ [[package]] name = "uefi" -version = "0.29.0" +version = "0.30.0" dependencies = [ "bitflags 2.6.0", "cfg-if", diff --git a/book/src/tutorial/app.md b/book/src/tutorial/app.md index d4990eb26..e8b80832a 100644 --- a/book/src/tutorial/app.md +++ b/book/src/tutorial/app.md @@ -24,7 +24,7 @@ to your `Cargo.toml`. The resulting `Cargo.toml` should look like that: ```toml [dependencies] log = "0.4.21" -uefi = { version = "0.29.0", features = [ "panic_handler", "logger" ] } +uefi = { version = "0.30.0", features = [ "panic_handler", "logger" ] } ``` Replace the contents of `src/main.rs` with this: diff --git a/template/Cargo.toml b/template/Cargo.toml index 08cc62dee..d42653118 100644 --- a/template/Cargo.toml +++ b/template/Cargo.toml @@ -5,4 +5,4 @@ edition = "2021" publish = false [dependencies] -uefi = { version = "0.29.0", features = ["panic_handler"] } +uefi = { version = "0.30.0", features = ["panic_handler"] } diff --git a/uefi-raw/src/capsule.rs b/uefi-raw/src/capsule.rs index 7726a1598..38183058c 100644 --- a/uefi-raw/src/capsule.rs +++ b/uefi-raw/src/capsule.rs @@ -18,7 +18,7 @@ pub struct CapsuleBlockDescriptor { /// Either a data block pointer or a continuation pointer. /// /// * If `length` is non-zero, this is the physical address of the data - /// block. + /// block. /// * If `length` is zero: /// * If `addr` is non-zero, this is the physical address of another block /// of `CapsuleBlockDescriptor`. diff --git a/uefi/CHANGELOG.md b/uefi/CHANGELOG.md index 3f54ecbd8..8d997651c 100644 --- a/uefi/CHANGELOG.md +++ b/uefi/CHANGELOG.md @@ -1,8 +1,7 @@ # uefi - [Unreleased] - -# uefi - 0.30.0 (unreleased) +# uefi - 0.30.0 (2024-08-02) ## Changed - **Breaking:**: Fixed a bug in the impls of `TryFrom<&[u8]>` for `&DevicePathHeader`, `&DevicePathNode` and `&DevicePath` that could lead to diff --git a/uefi/Cargo.toml b/uefi/Cargo.toml index 2fe9e257b..597fb2a30 100644 --- a/uefi/Cargo.toml +++ b/uefi/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "uefi" -version = "0.29.0" +version = "0.30.0" readme = "README.md" description = "Safe and easy-to-use wrapper for building UEFI apps." From 7e2d0f631d2220f34c0c61c464ac4e1993b1f885 Mon Sep 17 00:00:00 2001 From: Philipp Schuster Date: Tue, 6 Aug 2024 16:54:53 +0200 Subject: [PATCH 3/4] doc: fix changelog fmt --- uefi/CHANGELOG.md | 6 ------ 1 file changed, 6 deletions(-) diff --git a/uefi/CHANGELOG.md b/uefi/CHANGELOG.md index 668f27053..24b3e020f 100644 --- a/uefi/CHANGELOG.md +++ b/uefi/CHANGELOG.md @@ -41,13 +41,7 @@ # uefi - 0.30.0 (2024-08-02) -## Changed -- **Breaking:**: Fixed a bug in the impls of `TryFrom<&[u8]>` for - `&DevicePathHeader`, `&DevicePathNode` and `&DevicePath` that could lead to - memory unsafety. See . - -# uefi - 0.30.0 (2024-08-02) ## Changed - **Breaking:**: Fixed a bug in the impls of `TryFrom<&[u8]>` for `&DevicePathHeader`, `&DevicePathNode` and `&DevicePath` that could lead to From 7c6a86c8ea35de8b88b59905de39116625cae86f Mon Sep 17 00:00:00 2001 From: Philipp Schuster Date: Tue, 6 Aug 2024 16:55:46 +0200 Subject: [PATCH 4/4] cargo: update Update transitive libs. --- Cargo.lock | 44 +++++++++++++++++++++++++++----------------- 1 file changed, 27 insertions(+), 17 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index a302b3b69..cb39b4c27 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -223,7 +223,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "534c5cf6194dfab3db3242765c03bbe257cf92f22b38f6bc0c58d59108a820ba" dependencies = [ "libc", - "windows-sys", + "windows-sys 0.52.0", ] [[package]] @@ -252,14 +252,14 @@ dependencies = [ "cfg-if", "libc", "redox_syscall", - "windows-sys", + "windows-sys 0.52.0", ] [[package]] name = "flate2" -version = "1.0.30" +version = "1.0.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5f54427cfd1c7829e2a139fcefea601bf088ebca651d2bf53ebc600eac295dae" +checksum = "7f211bbe8e69bbd0cfdea405084f128ae8b4aaa6b0b522fc8f2b009084797920" dependencies = [ "crc32fast", "miniz_oxide", @@ -444,7 +444,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ae99c7fa6dd38c7cafe1ec085e804f8f555a2f8659b0dbe03f1f9963a9b51092" dependencies = [ "log", - "windows-sys", + "windows-sys 0.52.0", ] [[package]] @@ -553,7 +553,7 @@ dependencies = [ "libc", "spin", "untrusted", - "windows-sys", + "windows-sys 0.52.0", ] [[package]] @@ -566,7 +566,7 @@ dependencies = [ "errno", "libc", "linux-raw-sys", - "windows-sys", + "windows-sys 0.52.0", ] [[package]] @@ -586,9 +586,9 @@ dependencies = [ [[package]] name = "rustls-pki-types" -version = "1.7.0" +version = "1.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "976295e77ce332211c0d24d92c0e83e50f5c5f046d11082cea19f3df13a3562d" +checksum = "fc0a2ce646f8655401bb81e7927b812614bd5d91dbc968696be50603510fcaf0" [[package]] name = "rustls-webpki" @@ -647,9 +647,9 @@ dependencies = [ [[package]] name = "serde_json" -version = "1.0.121" +version = "1.0.122" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4ab380d7d9f22ef3f21ad3e6c1ebe8e4fc7a2000ccba2e4d71fc96f15b2cb609" +checksum = "784b6203951c57ff748476b126ccb5e8e2959a5c19e5c617ab1956be3dbc68da" dependencies = [ "itoa", "memchr", @@ -730,14 +730,15 @@ dependencies = [ [[package]] name = "tempfile" -version = "3.10.1" +version = "3.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "85b77fafb263dd9d05cbeac119526425676db3784113aa9295c88498cbf8bff1" +checksum = "b8fcd239983515c23a32fb82099f97d0b11b8c72f654ed659363a95c3dad7a53" dependencies = [ "cfg-if", "fastrand", + "once_cell", "rustix", - "windows-sys", + "windows-sys 0.52.0", ] [[package]] @@ -991,11 +992,11 @@ dependencies = [ [[package]] name = "winapi-util" -version = "0.1.8" +version = "0.1.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4d4cc384e1e73b93bafa6fb4f1df8c41695c8a91cf9c4c64358067d15a7b6c6b" +checksum = "cf221c93e13a30d793f7645a0e7762c55d169dbb0a49671918a2319d289b10bb" dependencies = [ - "windows-sys", + "windows-sys 0.59.0", ] [[package]] @@ -1007,6 +1008,15 @@ dependencies = [ "windows-targets", ] +[[package]] +name = "windows-sys" +version = "0.59.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e38bc4d79ed67fd075bcc251a1c39b32a1776bbe92e5bef1f0bf1f8c531853b" +dependencies = [ + "windows-targets", +] + [[package]] name = "windows-targets" version = "0.52.6"