* [PATCH v2] EDAC/ghes: Replace deprecated strcpy in ghes_edac_report_mem_error
@ 2025-11-18 13:56 Thorsten Blum
2025-11-18 14:31 ` Zhuo, Qiuxu
2025-11-18 16:16 ` Borislav Petkov
0 siblings, 2 replies; 3+ messages in thread
From: Thorsten Blum @ 2025-11-18 13:56 UTC (permalink / raw)
To: Mauro Carvalho Chehab, Borislav Petkov, Tony Luck
Cc: Thorsten Blum, linux-edac, linux-kernel
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.
Link: https://www.kernel.org/doc/html/latest/process/deprecated.html#strcpy [1]
Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev>
---
Changes in v2:
- Update patch description (Boris)
- Link to v1: https://lore.kernel.org/lkml/20251031114607.133523-1-thorsten.blum@linux.dev/
---
drivers/edac/ghes_edac.c | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/drivers/edac/ghes_edac.c b/drivers/edac/ghes_edac.c
index 1eb0136c6fbd..d80c88818691 100644
--- a/drivers/edac/ghes_edac.c
+++ b/drivers/edac/ghes_edac.c
@@ -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;
--
2.51.1
^ permalink raw reply related [flat|nested] 3+ messages in thread* RE: [PATCH v2] EDAC/ghes: Replace deprecated strcpy in ghes_edac_report_mem_error
2025-11-18 13:56 [PATCH v2] EDAC/ghes: Replace deprecated strcpy in ghes_edac_report_mem_error Thorsten Blum
@ 2025-11-18 14:31 ` Zhuo, Qiuxu
2025-11-18 16:16 ` Borislav Petkov
1 sibling, 0 replies; 3+ messages in thread
From: Zhuo, Qiuxu @ 2025-11-18 14:31 UTC (permalink / raw)
To: Thorsten Blum, Mauro Carvalho Chehab, Borislav Petkov, Luck, Tony
Cc: linux-edac@vger.kernel.org, linux-kernel@vger.kernel.org
> From: Thorsten Blum <thorsten.blum@linux.dev>
> Sent: Tuesday, November 18, 2025 9:56 PM
> To: Mauro Carvalho Chehab <mchehab@kernel.org>; Borislav Petkov
> <bp@alien8.de>; Luck, Tony <tony.luck@intel.com>
> Cc: Thorsten Blum <thorsten.blum@linux.dev>; linux-edac@vger.kernel.org;
> linux-kernel@vger.kernel.org
> 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.
>
> Link: https://www.kernel.org/doc/html/latest/process/deprecated.html#strcpy
> [1]
> Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev>
> ---
> Changes in v2:
> - Update patch description (Boris)
> - Link to v1: https://lore.kernel.org/lkml/20251031114607.133523-1-
> thorsten.blum@linux.dev/
LGTM, thanks.
Reviewed-by: Qiuxu Zhuo <qiuxu.zhuo@intel.com>
> [...]
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH v2] EDAC/ghes: Replace deprecated strcpy in ghes_edac_report_mem_error
2025-11-18 13:56 [PATCH v2] EDAC/ghes: Replace deprecated strcpy in ghes_edac_report_mem_error Thorsten Blum
2025-11-18 14:31 ` Zhuo, Qiuxu
@ 2025-11-18 16:16 ` Borislav Petkov
1 sibling, 0 replies; 3+ messages in thread
From: Borislav Petkov @ 2025-11-18 16:16 UTC (permalink / raw)
To: Thorsten Blum; +Cc: Mauro Carvalho Chehab, Tony Luck, linux-edac, linux-kernel
On Tue, Nov 18, 2025 at 02:56:22PM +0100, Thorsten Blum wrote:
> 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.
>
> Link: https://www.kernel.org/doc/html/latest/process/deprecated.html#strcpy [1]
> Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev>
> ---
> Changes in v2:
> - Update patch description (Boris)
> - Link to v1: https://lore.kernel.org/lkml/20251031114607.133523-1-thorsten.blum@linux.dev/
> ---
> drivers/edac/ghes_edac.c | 7 ++++---
> 1 file changed, 4 insertions(+), 3 deletions(-)
Applied, thanks.
--
Regards/Gruss,
Boris.
https://people.kernel.org/tglx/notes-about-netiquette
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2025-11-18 16:17 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-11-18 13:56 [PATCH v2] EDAC/ghes: Replace deprecated strcpy in ghes_edac_report_mem_error Thorsten Blum
2025-11-18 14:31 ` Zhuo, Qiuxu
2025-11-18 16:16 ` Borislav Petkov
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox