Skip to contentSkip to conversation

EDAC/ghes: Replace deprecated strcpy in ghes_edac_report_mem_error

PATCH Applied Thorsten Blum 3 participants 3 messages Nov 18, 2025

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

PATCH v2 1/1 EDAC/ghes: Replace deprecated strcpy in ghes_edac_report_mem_error

strcpy() has been deprecated [1] because it performs no bounds checking on the destination buffer, which can lead to buffer overflows. Use the safer strscpy() instead.

---
Changes in v2:
- Update patch description (Boris)
- Link to v1: https://lore.kernel.org/lkml/[email protected]/

---
 drivers/edac/ghes_edac.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)
drivers/edac/ghes_edac.c +4 -3
index 1eb0136c6fbd..d80c88818691 100644
@@ -15,6 +15,7 @@
 #include "edac_module.h"
 #include <ras/ras_event.h>
 #include <linux/notifier.h>
+#include <linux/string.h>
 
 #define OTHER_DETAIL_LEN	400
 
@@ -332,7 +333,7 @@ static int ghes_edac_report_mem_error(struct notifier_block *nb,
 		p = pvt->msg;
 		p += snprintf(p, sizeof(pvt->msg), "%s", cper_mem_err_type_str(etype));
 	} else {
-		strcpy(pvt->msg, "unknown error");
+		strscpy(pvt->msg, "unknown error");
 	}
 
 	/* Error address */
@@ -357,14 +358,14 @@ static int ghes_edac_report_mem_error(struct notifier_block *nb,
 		dimm = find_dimm_by_handle(mci, mem_err->mem_dev_handle);
 		if (dimm) {
 			e->top_layer = dimm->idx;
-			strcpy(e->label, dimm->label);
+			strscpy(e->label, dimm->label);
 		}
 	}
 	if (p > e->location)
 		*(p - 1) = '\0';
 
 	if (!*e->label)
-		strcpy(e->label, "unknown memory");
+		strscpy(e->label, "unknown memory");
 
 	/* All other fields are mapped on e->other_detail */
 	p = pvt->other_detail;
Signature · 1 line
2.51.1
Reviewed-by on v2 1/1
#1 lore raw
Quoted 13 lines

From: Thorsten Blum <[email protected]>
Sent: Tuesday, November 18, 2025 9:56 PM
To: Mauro Carvalho Chehab <[email protected]>; Borislav Petkov <[email protected]>; Luck, Tony <[email protected]>
Cc: Thorsten Blum <[email protected]>; [email protected]; [email protected]
Subject: [PATCH v2] EDAC/ghes: Replace deprecated strcpy in ghes_edac_report_mem_error

strcpy() has been deprecated [1] because it performs no bounds checking on the destination buffer, which can lead to buffer overflows. Use the safer strscpy() instead.

Quoted 8 lines

---
Changes in v2:
- Update patch description (Boris)
- Link to v1: https://lore.kernel.org/lkml/20251031114607.133523-1-
[email protected]/

LGTM, thanks.

Quoted 1 line

[...]

maintainer Applied
#2 lore raw
In reply to Thorsten Blum
Quoted 6 lines · Thorsten Blum

strcpy() has been deprecated [1] because it performs no bounds checking on the destination buffer, which can lead to buffer overflows. Use the safer strscpy() instead.

Quoted 7 lines

---
Changes in v2:
- Update patch description (Boris)
- Link to v1: https://lore.kernel.org/lkml/[email protected]/

---
 drivers/edac/ghes_edac.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

Applied, thanks.

Signature · 4 lines
Regards/Gruss,
    Boris.

https://people.kernel.org/tglx/notes-about-netiquette