From 8a4b3efec9cea7eaee84fe8320a679ee6ef2c456 Mon Sep 17 00:00:00 2001 From: Rob Bradford Date: Sat, 25 Apr 2026 22:07:27 +0100 Subject: [PATCH] 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 Assisted-by: Claude:Opus-4.7 --- devices/src/acpi.rs | 15 +++++++++++++++ 1 file changed, 15 insertions(+) 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; }