Commit 47fc365
fix(virtio/mem): reject BAR regions overlapping TD private DRAM
Virtio PCI capability parsing built MemoryRegion instances directly from
BAR base, offset, and length values, all of which are controlled by the
untrusted VMM. MemoryRegion::new only guarded against integer overflow
and never compared the resulting [base, base + length) range against the
TD's private DRAM. A malicious host could therefore program a BAR so that
a common/notify/device-config region or the MSI-X table pointed into
guest-private memory. In a cfg(not(tdcall)) build the subsequent
read/write_volatile would then read or corrupt TD-private secrets
(INV-4 / RC-066).
Add region_overlaps_private_dram() in the pci crate, which uses the
existing E820 memory map to detect overlap with platform RAM and rejects
any region below 1 MiB. Enforce it in MemoryRegion::new so that all four
BAR-derived call sites in VirtioPciTransport::init fail closed with
VirtioError::InvalidParameter. The check is purely arithmetic and applies
regardless of the tdcall feature; it is skipped only under the fuzz
feature, which is not a security boundary.
Signed-off-by: Michal Tarnacki <michal.tarnacki@intel.com>
Co-authored-by: GitHub Copilot <noreply@github.com>1 parent f815df8 commit 47fc365
2 files changed
Lines changed: 39 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
38 | 38 | | |
39 | 39 | | |
40 | 40 | | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
41 | 74 | | |
42 | 75 | | |
43 | 76 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
33 | 33 | | |
34 | 34 | | |
35 | 35 | | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
36 | 42 | | |
37 | 43 | | |
38 | 44 | | |
| |||
0 commit comments