diff --git a/devices/src/acpi.rs b/devices/src/acpi.rs index 54b8ca76a..2d7f49a73 100644 --- a/devices/src/acpi.rs +++ b/devices/src/acpi.rs @@ -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> { + 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; }