Skip to contentSkip to conversation

dev/parport: fix the array out-of-bounds risk

PATCH New tuhaowen 1 participant 1 message May 27, 2024 Parallel port

lore
Share & tools
lore

tuhaowen

author
#0 lore raw

PATCH 1/1 dev/parport: fix the array out-of-bounds risk

The array buffer size is 20 bytes.
When executing code in a 64-bit CPU environment, up to 42 bytes of data will be written into this array
(the size of "%lu\t%lu\n" is 20 +1 + 20 + 1).

In fact, this line of code for 32-bit CPUs also has the risk of crossing the boundary, but it can exceed 2 bytes at most. With good luck, it is local variables that are damaged, and there are no serious consequences.

---
 drivers/parport/procfs.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/parport/procfs.c +1 -1
index bd388560ed59..9f501d5fa1ec 100644
@@ -117,7 +117,7 @@ static int do_hardware_base_addr(struct ctl_table *table, int write,
 				 void *result, size_t *lenp, loff_t *ppos)
 {
 	struct parport *port = (struct parport *)table->extra1;
-	char buffer[20];
+	char buffer[64];
 	int len = 0;
 
 	if (*ppos) {
Signature · 1 line
2.20.1