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:
Rob Bradford
2026-04-25 22:07:27 +01:00
parent 14aa30cd2e
commit 8a4b3efec9

View File

@@ -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;
}