oxidecomputer / oxidecomputer/hubris

UB in ping task: pointer passed to read_volatile must not be null

Open
#276 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Rust
Stars
3.6k
Forks
239
Avg merge
1d 12h
Merged PRs (30d)
23

Description

This code executes undefined behavior:
https://github.com/oxidecomputer/hubris/blob/8833cc1dcfdbf107369e188a035a38651ba7ab46/task/ping/src/main.rs#L19

The std::ptr module documents:

A null pointer is never valid, not even for accesses of size zero.

And ptr::read_volatile repeats this:

Note that even if T has size 0, the pointer must be non-null and properly aligned.

I think this line should be replaced with inline assembly that does the faulting read.

Contributor guide

Open the contributing guide

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 task/ping/src/main.rs at line 19 and read the Rust documentation for ptr::read_volatile and the issue's linked context. Replace the null-pointer volatile read with the proposed faulting-read approach, then verify that the ping task builds and retains the intended fault behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
embedded-iot
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.