oreboot / oreboot/oreboot

Serialize and deserialize structs safely

Open
#436 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Code Health Help Wanted
Dominant language
Rust
Stars
1.8k
Forks
113
PR merge metrics
No merged PRs in 30d

Description

There are a few places where we unnecessarily use unsafe blocks to serialize and deserialize structs:

In particular see https://github.com/oreboot/oreboot/blob/main/src/lib/uefi/src/lib.rs. For example:

let fveh: efi::EFI_FIRMWARE_VOLUME_EXT_HEADER =
                unsafe { core::ptr::read(fveh_bytes.as_ptr() as *const _) };

Instead, we should be using some Rust macros to achieve this safely. There are a number of crates built for this task:

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in src/lib/uefi/src/lib.rs, especially the EFI_FIRMWARE_VOLUME_EXT_HEADER conversion shown in the issue, then locate the other unsafe struct serialization and deserialization sites. Compare the listed Rust crates for packed C-struct compatibility and determine the required byte layout and endianness. Done means the applicable conversions no longer use unsafe pointer reads while preserving the existing struct format.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
operating-systems
Issue type
Refactor
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.