Skip to contentSkip to conversation

ACPI: pfr_update: zero-initialize capability query result

PATCH Applied Karl Mehltretter 2 participants 2 messages Aug 27 – Sep 9

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ACPI: pfr_update: zero-initialize capability query result

query_capability() copies four ACPI buffers into fixed-size fields using the firmware-supplied lengths. The existing overflow guard rejects oversized buffers, but shorter buffers are accepted and leave trailing bytes of the stack-allocated cap_hdr uninitialized. PFRU_IOC_QUERY_CAP then copies the entire structure to userspace.

Zero-initialize cap_hdr before querying the firmware. This preserves the existing handling of short firmware responses while preventing disclosure of kernel stack data. Oversized buffers remain rejected.

A QEMU _DSM returning one-byte buffers reproduced nonzero stack suffix bytes in all four fields. With this change, the ioctl still succeeds and each unwritten suffix is zero-filled, while 64-byte buffers continue to return -EINVAL.

Fixes 0db89fa243e5 ("ACPI: Introduce Platform Firmware Runtime Update device driver")
Assisted-by LLM
---
 drivers/acpi/pfr_update.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/acpi/pfr_update.c +1 -1
index 9afd2c52fdbd..98ace679601b 100644
@@ -422,7 +422,7 @@ static int start_update(int action, struct pfru_device *pfru_dev)
 
 static long pfru_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
 {
-	struct pfru_update_cap_info cap_hdr;
+	struct pfru_update_cap_info cap_hdr = {};
 	struct pfru_device *pfru_dev = to_pfru_dev(file);
 	void __user *p = (void __user *)arg;
 	u32 rev;
Signature · 1 line
2.39.5 (Apple Git-154)
maintainer Applied
#1 lore raw
Quoted 31 lines · Karl Mehltretter

query_capability() copies four ACPI buffers into fixed-size fields using the firmware-supplied lengths. The existing overflow guard rejects oversized buffers, but shorter buffers are accepted and leave trailing bytes of the stack-allocated cap_hdr uninitialized. PFRU_IOC_QUERY_CAP then copies the entire structure to userspace.

Zero-initialize cap_hdr before querying the firmware. This preserves the existing handling of short firmware responses while preventing disclosure of kernel stack data. Oversized buffers remain rejected.

A QEMU _DSM returning one-byte buffers reproduced nonzero stack suffix bytes in all four fields. With this change, the ioctl still succeeds and each unwritten suffix is zero-filled, while 64-byte buffers continue to return -EINVAL.

Fixes 0db89fa243e5 ("ACPI: Introduce Platform Firmware Runtime Update device driver")
Assisted-by LLM
---
 drivers/acpi/pfr_update.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/acpi/pfr_update.c +0 -0
index 9afd2c52fdbd..98ace679601b 100644

drivers/acpi/pfr_update.c static int start_update(int action, struct pfru_device *pfru_dev)

Quoted 9 lines
drivers/acpi/pfr_update.c +1 -2
@@ -422,7 +422,7 @@ static int start_update(int action, struct pfru_device *pfru_dev)
 
 static long pfru_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
 {
-       struct pfru_update_cap_info cap_hdr;
+       struct pfru_update_cap_info cap_hdr = {};
        struct pfru_device *pfru_dev = to_pfru_dev(file);
        void __user *p = (void __user *)arg;
        u32 rev;
--

Applied as 7.4 material, thanks!