mirror of https://github.com/torvalds/linux.git
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
This commit is contained in:
parent
f18e71cd6c
commit
cdf5ecc3f6
|
|
@ -15,6 +15,7 @@
|
||||||
#include "edac_module.h"
|
#include "edac_module.h"
|
||||||
#include <ras/ras_event.h>
|
#include <ras/ras_event.h>
|
||||||
#include <linux/notifier.h>
|
#include <linux/notifier.h>
|
||||||
|
#include <linux/string.h>
|
||||||
|
|
||||||
#define OTHER_DETAIL_LEN 400
|
#define OTHER_DETAIL_LEN 400
|
||||||
|
|
||||||
|
|
@ -332,7 +333,7 @@ static int ghes_edac_report_mem_error(struct notifier_block *nb,
|
||||||
p = pvt->msg;
|
p = pvt->msg;
|
||||||
p += snprintf(p, sizeof(pvt->msg), "%s", cper_mem_err_type_str(etype));
|
p += snprintf(p, sizeof(pvt->msg), "%s", cper_mem_err_type_str(etype));
|
||||||
} else {
|
} else {
|
||||||
strcpy(pvt->msg, "unknown error");
|
strscpy(pvt->msg, "unknown error");
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Error address */
|
/* 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);
|
dimm = find_dimm_by_handle(mci, mem_err->mem_dev_handle);
|
||||||
if (dimm) {
|
if (dimm) {
|
||||||
e->top_layer = dimm->idx;
|
e->top_layer = dimm->idx;
|
||||||
strcpy(e->label, dimm->label);
|
strscpy(e->label, dimm->label);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (p > e->location)
|
if (p > e->location)
|
||||||
*(p - 1) = '\0';
|
*(p - 1) = '\0';
|
||||||
|
|
||||||
if (!*e->label)
|
if (!*e->label)
|
||||||
strcpy(e->label, "unknown memory");
|
strscpy(e->label, "unknown memory");
|
||||||
|
|
||||||
/* All other fields are mapped on e->other_detail */
|
/* All other fields are mapped on e->other_detail */
|
||||||
p = pvt->other_detail;
|
p = pvt->other_detail;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue