mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2026-08-05 02:19:16 +00:00
devices: acpi: Reject mis-sized accesses to shutdown and GED devices
These devices should only be accessed by single byte accesses as specified through the ACPI definitions for them. Signed-off-by: Rob Bradford <rbradford@meta.com> Assisted-by: Claude:Opus-4.7
This commit is contained in:
@@ -45,10 +45,21 @@ impl AcpiShutdownDevice {
|
||||
impl BusDevice for AcpiShutdownDevice {
|
||||
// Spec has all fields as zero
|
||||
fn read(&mut self, _base: u64, _offset: u64, data: &mut [u8]) {
|
||||
if data.len() != 1 {
|
||||
warn!("Invalid sized read of ACPI shutdown device: {}", data.len());
|
||||
return;
|
||||
}
|
||||
data.fill(0);
|
||||
}
|
||||
|
||||
fn write(&mut self, _base: u64, _offset: u64, data: &[u8]) -> Option<Arc<Barrier>> {
|
||||
if data.len() != 1 {
|
||||
warn!(
|
||||
"Invalid sized write of ACPI shutdown device: {}",
|
||||
data.len()
|
||||
);
|
||||
return None;
|
||||
}
|
||||
if data[0] == 1 {
|
||||
info!("ACPI Reboot signalled");
|
||||
if let Err(e) = self.reset_evt.write(1) {
|
||||
@@ -119,6 +130,10 @@ impl AcpiGedDevice {
|
||||
impl BusDevice for AcpiGedDevice {
|
||||
// Spec has all fields as zero
|
||||
fn read(&mut self, _base: u64, _offset: u64, data: &mut [u8]) {
|
||||
if data.len() != 1 {
|
||||
warn!("Invalid sized read of ACPI GED device: {}", data.len());
|
||||
return;
|
||||
}
|
||||
data[0] = self.notification_type.bits();
|
||||
self.notification_type = AcpiNotificationFlags::NO_DEVICES_CHANGED;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user