Skip to content

Fix multiple soundness issues#103

Merged
likebreath merged 1 commit intorust-vmm:mainfrom
DemiMarie:soundness
Feb 6, 2026
Merged

Fix multiple soundness issues#103
likebreath merged 1 commit intorust-vmm:mainfrom
DemiMarie:soundness

Conversation

@DemiMarie
Copy link
Contributor

@DemiMarie DemiMarie commented Jul 8, 2025

Summary of the PR

vfio_syscall::map_dma causes the kernel to make an arbitrary address
accessible for DMA by a device the guest typically controls. This is
unsafe, as it can change memory that Rust assumes is immutable.

I found this through a review of Cloud Hypervisor, where I saw a
safe function that took a host address cast to u64 as an argument and
accessed that address. It turns out that this function was the source
of the unsoundness.

Requirements

Before submitting your PR, please make sure you addressed the following
requirements:

  • All commits in this PR have Signed-Off-By trailers (with
    git commit -s), and the commit message has max 60 characters for the
    summary and max 75 characters for each description line.
  • All added/changed functionality has a corresponding unit/integration
    test.
  • All added/changed public-facing functionality has entries in the "Upcoming
    Release" section of CHANGELOG.md (if no such section exists, please create one).
  • Any newly added unsafe code is properly documented.

@DemiMarie DemiMarie changed the title Fix multi Fix multiple soundness issues Jul 23, 2025
@jinankjain
Copy link
Collaborator

@DemiMarie can you please rebase and fix the clippy errors?

@DemiMarie DemiMarie force-pushed the soundness branch 2 times, most recently from 18ba7db to 0819d25 Compare September 14, 2025 18:44
@alyssais
Copy link
Contributor

alyssais commented Feb 3, 2026

@DemiMarie should this be marked "Closes #100"?

@DemiMarie
Copy link
Contributor Author

@DemiMarie should this be marked "Closes #100"?

Done

@alyssais
Copy link
Contributor

alyssais commented Feb 4, 2026

Looks like the tests need updated.

@DemiMarie DemiMarie force-pushed the soundness branch 2 times, most recently from 377b889 to 1f30841 Compare February 4, 2026 17:22
Copy link
Contributor

@rbradford rbradford left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Still lgtm

Copy link
Contributor

@rbradford rbradford left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: I think the git commit summary should have a vfio-ioctls: prefix and then good to go.

Copy link
Collaborator

@likebreath likebreath left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the patience with the review. Overall look good. Some suggestions below

Mark it as "Request Changes" due to:

  • Please fix the CHANGELOG changes (details below)
  • Please fix the typo from commit message: "Some of its
    internal APIs took a host took a host address cast to ..."

vfio_syscall::map_dma() accepts a u64 and tells the Linux kernel to make
the corresponding address accessible for DMA by a device.  Therefore,
passing bad u64 values can result in memory corruption or disclosure.
Change the u64 argument to a pointer to avoid confusion.  To reflect
that the caller must uphold invariants to prevent undefined behavior,
mark the API as unsafe.

I found this through a review of Cloud Hypervisor [1].  Some of its
internal APIs took a host took a host address cast to u64 as an argument
and accessed that address.  In one case, the u64 was passed directly to
vfio_syscall::map_dma().

[1]: cloud-hypervisor/cloud-hypervisor#7129

Fixes: rust-vmm#100
Signed-off-by: Demi Marie Obenour <demiobenour@gmail.com>
@likebreath likebreath merged commit f6f5b99 into rust-vmm:main Feb 6, 2026
7 checks passed
@DemiMarie DemiMarie deleted the soundness branch February 6, 2026 20:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants