Skip to contentSkip to conversation

panasonic-laptop: avoid overflow in acpi_pcc_hotkey_add()

PATCH New Xi Wang 1 participant 1 message Dec 29, 2011

Subsystems (2)
lore
Share & tools
lore

Xi Wang

author
#0 lore raw

PATCH 1/1 panasonic-laptop: avoid overflow in acpi_pcc_hotkey_add()

num_sifr could go negative since acpi_pcc_get_sqty() returns -EINVAL on error. Then it could bypass the sanity check (num_sifr > 255). The subsequent call to kzalloc() would allocate a small buffer, leading to a memory corruption.

---
 drivers/platform/x86/panasonic-laptop.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
drivers/platform/x86/panasonic-laptop.c +2 -2
index 05be30e..ffff8b4 100644
@@ -562,8 +562,8 @@ static int acpi_pcc_hotkey_add(struct acpi_device *device)
 
 	num_sifr = acpi_pcc_get_sqty(device);
 
-	if (num_sifr > 255) {
-		ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "num_sifr too large"));
+	if (num_sifr < 0 || num_sifr > 255) {
+		ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "num_sifr out of range"));
 		return -ENODEV;
 	}
 
Signature · 1 line
1.7.5.4