[Security][riscv64] Guest-to-Hypervisor Escape via Incorrect G-stage MemoryRegion Splitting

Aperta
#412 1 commento 1 reazione 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
5/5
Tempo stimato
Più di una settimana
Idoneità per principianti
12/100
Tipo di issue
Bug
Chiarezza
Abbastanza chiara
Stato di attività
Attiva
Stack tecnologico
rust

Direzione di ricerca

Start in src/device/iommu/riscv_iommu/viommu.rs at VirtualIommuInner::handle_ddt1lvl_mode() and compare how it builds subregions with MemoryRegion::new_with_offset_mapper() against the original G-stage mapping. Because this is a reported guest-to-hypervisor escape, do not work on it publicly; the reporter asks for private disclosure, so route any patch through the maintainers. Done means the split preserves the original GPA-to-HPA offset and the error and TLB paths are checked.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

bug riscv64 security

I found a potential VM escape vulnerability in the RISC-V vIOMMU implementation of hvisor v0.6.

Affected Code

src/device/iommu/riscv_iommu/viommu.rs

Function: VirtualIommuInner::handle_ddt1lvl_mode()

Root Cause

When a guest configures the vIOMMU DDTP register to use the one-level DDT mode, hvisor removes the DDT page from the original G-stage mapping and splits the corresponding MemoryRegion into two subregions.

However, both subregions are created using MemoryRegion::new_with_offset_mapper() with the guest physical address as the host physical address.

For example, the original mapping is:

HPA = GPA + OFFSET

After the split, the new mapping incorrectly becomes:

HPA = GPA

This breaks the original GPA-to-HPA mapping and may expose Hypervisor physical memory to the guest.

Impact

A malicious guest can trigger this issue by writing a crafted DDTP value to the virtual IOMMU.

We reproduced the vulnerability in a QEMU-based RISC-V environment. The guest can access and modify Hypervisor memory, including executable code. By triggering the modified code through an SBI ecall, we successfully demonstrated code execution in HS-mode.

This is a guest-to-Hypervisor escape, rather than merely a guest crash or an in-guest privilege escalation.

Suggested Fix

The subregions should preserve the original memory mapper instead of reconstructing the mapping using GPA as HPA.

A possible solution is to introduce a MemoryRegion::subregion() method that retains the original mapper when splitting a region.

It would also be worth checking the error handling and G-stage TLB invalidation paths to ensure that failed mapping operations cannot leave inconsistent memory mappings.

Reproduction and Disclosure

I have a working PoC and QEMU validation logs demonstrating the issue, including Hypervisor memory modification and HS-mode code execution.

I can share the complete reproduction package and a proposed fix with the maintainers through a private channel.

Could you please confirm whether this is a known issue and advise on the preferred vulnerability disclosure process?

Thanks for maintaining hvisor.

Lingua principale
Rust
Stelle
209
Fork
62
Merge medio
1g 21h
PR unite (30g)
20

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di syswonder/hvisor

Tutte le issue di syswonder/hvisor

Issue simili

Altre issue su Rust

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.