Skip to contentSkip to conversation

remoteproc: avoid array index out of bounds in debugfs file

PATCH In review Xiaobing shi 2 participants 2 messages Mar 28, 2022 – Mar 29, 2022

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

PATCH 1/1 remoteproc: avoid array index out of bounds in debugfs file

There is a negative offset of an on-stack array that causes an out of bounds issue when someone called with a zero 'count' argument to syswrite().

	buf[count - 1]

We should add an extra check in rproc_coredump_write() to prevent the access.

---
 drivers/remoteproc/remoteproc_debugfs.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/remoteproc/remoteproc_debugfs.c +1 -1
index b5a1e3b697d9..581930483ef8 100644
@@ -76,7 +76,7 @@ static ssize_t rproc_coredump_write(struct file *filp,
 	int ret, err = 0;
 	char buf[20];
 
-	if (count > sizeof(buf))
+	if (count < 1 || count > sizeof(buf))
 		return -EINVAL;
 
 	ret = copy_from_user(buf, user_buf, count);
Signature · 1 line
2.18.0