Skip to contentSkip to conversation

scsi_sysfs: fix a buffer overflow in sysfs handling

PATCH New Nikolay Aleksandrov 1 participant 1 message Nov 7, 2012 SCSI

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 scsi_sysfs: fix a buffer overflow in sysfs handling

Fix a stack buffer overflow in the SCSI layer sysfs handling code (store_host_reset()). When a host reset type is read via sscanf in str there is no limit on the length and str is defined as char str[10].

How to reproduce:
Given that the sysfs entry exists, execute
echo "AAAAAAAAAAAAAAAA" > /sys/devices/pci0000:00/0000:00:1f.2/ata1/host0/scsi_host/host0/host_reset

---
 drivers/scsi/scsi_sysfs.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/scsi/scsi_sysfs.c +1 -1
index ce5224c..51826e2 100644
@@ -267,7 +267,7 @@ store_host_reset(struct device *dev, struct device_attribute *attr,
 	char str[10];
 	int type;
 
-	sscanf(buf, "%s", str);
+	sscanf(buf, "%9s", str);
 	type = check_reset_type(str);
 
 	if (!type)
Signature · 1 line
1.7.11.4