Skip to content

Commit 126efa8

Browse files
ManciukicJackThomson2
authored andcommitted
fix: return error on missing ITS with gicv3
The fuzzer found a crash when Gicv3 is used but its is None. Do not unwrap but return an Err. Signed-off-by: Riccardo Mancini <mancio@amazon.com>
1 parent 4952698 commit 126efa8

2 files changed

Lines changed: 7 additions & 3 deletions

File tree

src/vmm/src/arch/aarch64/gic/gicv3/regs/mod.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,11 @@ pub fn restore_state(
5757
icc_regs::set_icc_regs(gic_device, *mpidr, &vcpu_state.icc)?;
5858
}
5959

60-
// Safe to unwrap here, as we know we support an ITS device, so `its_state.is_some()` is always
61-
// `true`.
62-
state.its_state.as_ref().unwrap().restore(its_device)
60+
state
61+
.its_state
62+
.as_ref()
63+
.ok_or(GicError::MissingItsState)?
64+
.restore(its_device)
6365
}
6466

6567
#[cfg(test)]

src/vmm/src/arch/aarch64/gic/mod.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,8 @@ pub enum GicError {
5858
InconsistentVcpuCount,
5959
/// The VgicSysRegsState is invalid.
6060
InvalidVgicSysRegState,
61+
/// ITS state is missing.
62+
MissingItsState,
6163
}
6264

6365
/// List of implemented GICs.

0 commit comments

Comments
 (0)