Skip to content

Commit cdf5ecc

Browse files
tobluxbp3tk0v
authored andcommitted
EDAC/ghes: Replace deprecated strcpy() in ghes_edac_report_mem_error()
strcpy() has been deprecated¹ because it performs no bounds checking on the destination buffer, which can lead to buffer overflows. Use the safer strscpy() instead. ¹ https://www.kernel.org/doc/html/latest/process/deprecated.html#strcpy Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev> Signed-off-by: Borislav Petkov (AMD) <bp@alien8.de> Reviewed-by: Qiuxu Zhuo <qiuxu.zhuo@intel.com> Link: https://patch.msgid.link/20251118135621.101148-2-thorsten.blum@linux.dev
1 parent f18e71c commit cdf5ecc

1 file changed

Lines changed: 4 additions & 3 deletions

File tree

drivers/edac/ghes_edac.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
#include "edac_module.h"
1616
#include <ras/ras_event.h>
1717
#include <linux/notifier.h>
18+
#include <linux/string.h>
1819

1920
#define OTHER_DETAIL_LEN 400
2021

@@ -332,7 +333,7 @@ static int ghes_edac_report_mem_error(struct notifier_block *nb,
332333
p = pvt->msg;
333334
p += snprintf(p, sizeof(pvt->msg), "%s", cper_mem_err_type_str(etype));
334335
} else {
335-
strcpy(pvt->msg, "unknown error");
336+
strscpy(pvt->msg, "unknown error");
336337
}
337338

338339
/* Error address */
@@ -357,14 +358,14 @@ static int ghes_edac_report_mem_error(struct notifier_block *nb,
357358
dimm = find_dimm_by_handle(mci, mem_err->mem_dev_handle);
358359
if (dimm) {
359360
e->top_layer = dimm->idx;
360-
strcpy(e->label, dimm->label);
361+
strscpy(e->label, dimm->label);
361362
}
362363
}
363364
if (p > e->location)
364365
*(p - 1) = '\0';
365366

366367
if (!*e->label)
367-
strcpy(e->label, "unknown memory");
368+
strscpy(e->label, "unknown memory");
368369

369370
/* All other fields are mapped on e->other_detail */
370371
p = pvt->other_detail;

0 commit comments

Comments
 (0)