Skip to contentSkip to conversation

Fix an off-by-one buffer overrun in inject_ue_write

PATCH Superseded Yiyuan Guo 3 participants 4 messages Jun 29, 2023 – Jul 11, 2023

Subsystems (3)
lore
Share & tools
lore

Yiyuan Guo

author
#0 lore raw

PATCH 1/1 Fix an off-by-one buffer overrun in inject_ue_write

---
 drivers/edac/zynqmp_edac.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/edac/zynqmp_edac.c +1 -1
index ac7d1e0b324c..bd9c1ff4b5e9 100644
@@ -304,7 +304,7 @@ static ssize_t inject_ue_write(struct file *file, const char __user *data,
 	if (!data)
 		return -EFAULT;
 
-	len = min_t(size_t, count, sizeof(buf));
+	len = min_t(size_t, count, sizeof(buf) - 1);
 	if (copy_from_user(buf, data, len))
 		return -EFAULT;
 
Signature · 1 line
2.25.1
maintainer
#1 lore raw

Your subject is missing subsystem. Run git log on this driver to look at style.

Quoted 1 line · Yiyuan Guo

And there is missing commit message which describes the problem what you are facing.

Thanks,
Michal

author
#2 lore raw

PATCH v2 1/1 EDAC/zynqmp: Fix an off-by-one buffer overrun in inject_ue_write

In reply to Yiyuan Guo

inject_ue_write() may access a local buffer buf at index len = sizeof(buf). Fix the length value to avoid buffer overrun.

---
 drivers/edac/zynqmp_edac.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/edac/zynqmp_edac.c +1 -1
index ac7d1e0b324c..bd9c1ff4b5e9 100644
@@ -304,7 +304,7 @@ static ssize_t inject_ue_write(struct file *file, const char __user *data,
 	if (!data)
 		return -EFAULT;
 
-	len = min_t(size_t, count, sizeof(buf));
+	len = min_t(size_t, count, sizeof(buf) - 1);
 	if (copy_from_user(buf, data, len))
 		return -EFAULT;
 
Signature · 1 line
2.25.1
maintainer Reviewed-by on v2 1/1
#3 lore raw

RE: [PATCH v2] EDAC/zynqmp: Fix an off-by-one buffer overrun in inject_ue_write

Quoted 14 lines

-----Original Message-----
From: Yiyuan Guo <[email protected]>
Sent: Thursday, June 29, 2023 9:21 PM
To: Datta, Shubhrajyoti <[email protected]>; Potthuri, Sai Krishna <[email protected]>
Cc: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; Simek, Michal <[email protected]>; [email protected]; linux-arm- [email protected]; [email protected]
Subject: [PATCH v2] EDAC/zynqmp: Fix an off-by-one buffer overrun in inject_ue_write

Quoted 4 lines

inject_ue_write() may access a local buffer buf at index len = sizeof(buf). Fix the length value to avoid buffer overrun.

Quoted 20 lines
---
 drivers/edac/zynqmp_edac.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/edac/zynqmp_edac.c index renamed from drivers/edac/zynqmp_edac.c +0 -0

ac7d1e0b324c..bd9c1ff4b5e9 100644

drivers/edac/zynqmp_edac.c +1 -2
@@ -304,7 +304,7 @@ static ssize_t inject_ue_write(struct file *file, const char
 __user *data,
 	if (!data)
 		return -EFAULT;
 
-	len = min_t(size_t, count, sizeof(buf));
+	len = min_t(size_t, count, sizeof(buf) - 1);
 	if (copy_from_user(buf, data, len))
 		return -EFAULT;
 
--

2.25.1