-
Notifications
You must be signed in to change notification settings - Fork 64
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: deserialization issue of FamStructWrapper with serde
An issue was discovered in the Serde::deserialize implementation of the FamStructWrapper that can lead to out-of-bounds memory access via safe Rust code. When dserializing a FamStructWrapper we reconstruct the header of the type from the saved state and then reconstruct the flexible array part in a separate step. The header includes information about the length of the flexible array part. However, during deserialization, we do not check that the length included in the header matches with the length of the deserialized flexible array. The safety of FamStructWrapper methods accessing the underlying memory of the flexible array depends on the header length reflects the memory size of the flexible array. If the saved state was malformed in way that this condition is not true, and even worse, the header length implies a flexible array buffer bigger than what we allocated memory for, a user can trigger out-bounds access via Rust-safe code. This commit introduces a check that the header length matches the length of the flexible array deserialized from the saved state. If it doesn't, deserialization returns an Error. Moreover, we mark the method that can change the header length as unsafe and make the as_mut_fam_struct method private, so that it is not possible for a consumer of the library to break this invariant from safe code. Signed-off-by: Babis Chalios <[email protected]>
- Loading branch information
Showing
2 changed files
with
59 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
[package] | ||
name = "vmm-sys-util" | ||
version = "0.11.2" | ||
version = "0.12.0" | ||
authors = ["Intel Virtualization Team <[email protected]>"] | ||
description = "A system utility set" | ||
repository = "https://github.com/rust-vmm/vmm-sys-util" | ||
|
@@ -26,3 +26,4 @@ bitflags = "1.0" | |
|
||
[dev-dependencies] | ||
serde_json = "1.0.9" | ||
bincode = "1.3.3" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters