Skip to content

hv1_emulator: bounds-check guest-controlled synic indices#3686

Open
rei141 wants to merge 1 commit into
microsoft:mainfrom
rei141:fix-synic-event-flag-bounds
Open

hv1_emulator: bounds-check guest-controlled synic indices#3686
rei141 wants to merge 1 commit into
microsoft:mainfrom
rei141:fix-synic-event-flag-bounds

Conversation

@rei141

@rei141 rei141 commented Jun 7, 2026

Copy link
Copy Markdown

Summary

signal_event indexed the SINT array with an unchecked sint_index and the SIEFP page with an unchecked,
guest-controllable flag; post_message indexed (and shifted by) an unchecked sint_index. An out-of-range value — e.g.
a guest-configured event flag >= 2048, which reaches signal_event via a guest-opened channel's event_flag — caused an
out-of-bounds panic in the paravisor.

Fix

  • signal_event: return Ok(false) (the existing benign "not signaled" path used for masked/proxy SINTs) when
    sint_index >= NUM_SINTS or flag >= (HV_PAGE_SIZE_USIZE / NUM_SINTS) * 8 (= 2048, the number of event flags one SINT
    owns in the SIEFP page).
  • post_message: return the existing HvError::InvalidSynicState when sint_index >= NUM_SINTS, guarding both the array
    index and the 1 << sint_index shift.

Impact

Denial of service (out-of-bounds array/page index → panic), not memory unsafety. Scoped to the attacking guest's own VM —
an unprivileged VTL0 guest crashing the VTL2 paravisor that serves it (a self-DoS); no cross-VM/host impact. The paravisor
should not panic on guest-controlled indices regardless.

`signal_event` indexed the SINT array with an unchecked `sint_index` and
the SIEFP page with an unchecked, guest-controllable `flag`;
`post_message` indexed (and shifted by) an unchecked `sint_index`. An
out-of-range value (e.g. a guest-configured event flag >= 2048) caused an
out-of-bounds panic.

Reject out-of-range `sint_index`/`flag` instead of indexing past the
fixed-size array/page.
Copilot AI review requested due to automatic review settings June 7, 2026 17:26
@rei141 rei141 requested a review from a team as a code owner June 7, 2026 17:26

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Note

Copilot was unable to run its full agentic suite in this review.

This PR hardens SynIC emulation against guest/caller-influenced out-of-range indices to prevent panics from out-of-bounds array/page indexing.

Changes:

  • Add bounds checks for sint_index before indexing the VP SINT array.
  • Validate flag against the number of event-flag bits owned per SINT in the SIEFP page.
  • Add bounds checks for sint_index in ProcessorSynic::post_message to avoid invalid array access/bit shifts.

Comment on lines +245 to +251
// Each SINT owns this many event flags in the SIEFP page. `flag` is
// guest-controllable (e.g. via a guest-configured event port), so an
// out-of-range value must be rejected rather than indexing past the
// page below (which would be a guest-triggerable OOB panic).
if flag >= (HV_PAGE_SIZE_USIZE / NUM_SINTS) * 8 {
return Ok(false);
}
Comment on lines +240 to +242
if sint_index >= NUM_SINTS {
return Ok(false);
}
Comment on lines +450 to +452
if sint_index as usize >= NUM_SINTS {
return Err(HvError::InvalidSynicState);
}
@smalis-msft

Copy link
Copy Markdown
Contributor

If the guest wants to crash itself it always can, I'm not sure this is worthwhile.

@github-actions

github-actions Bot commented Jun 8, 2026

Copy link
Copy Markdown

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.

3 participants