Skip to contentSkip to conversation

remoteproc: Fix count check in rproc_coredump_write()

PATCH Applied Alistair Delva 2 participants 3 messages Jan 19, 2022 – Feb 8, 2022

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

PATCH 1/1 remoteproc: Fix count check in rproc_coredump_write()

Check count for 0, to avoid a potential underflow. Make the check the same as the one in rproc_recovery_write().

Fixes 3afdc59e4390 ("remoteproc: Add coredump debugfs entry")
Cc Rishabh Bhatnagar <[email protected]>
Cc Ohad Ben-Cohen <[email protected]>
Cc Bjorn Andersson <[email protected]>
Cc Mathieu Poirier <[email protected]>
Cc Sibi Sankar <[email protected]>
---
 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.30.2
Reviewed-by on v1 1/1
#1 lore raw
Quoted 13 lines · Alistair Delva

Check count for 0, to avoid a potential underflow. Make the check the same as the one in rproc_recovery_write().

Fixes 3afdc59e4390 ("remoteproc: Add coredump debugfs entry")
Cc Rishabh Bhatnagar <[email protected]>
Cc Ohad Ben-Cohen <[email protected]>
Cc Bjorn Andersson <[email protected]>
Cc Mathieu Poirier <[email protected]>
Cc Sibi Sankar <[email protected]>

Regards,
Bjorn

Quoted 20 lines
---
 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.30.2
#2 lore raw
In reply to Alistair Delva
Quoted 4 lines · Alistair Delva

Check count for 0, to avoid a potential underflow. Make the check the same as the one in rproc_recovery_write().

Applied, thanks!

[1/1] remoteproc: Fix count check in rproc_coredump_write()

      commit: 09dc6efba9088a84ac00bd25be36c50d0a01a4df

Best regards,

Signature · 1 line
Bjorn Andersson <[email protected]>