x86/cpu/intel: replace deprecated strcpy with strscpy
A message that is not in the archive (sent off-list or not yet received): [email protected]
PATCH RESEND 1/1 x86/cpu/intel: replace deprecated strcpy with strscpy
strcpy is deprecated due to lack of bounds checking.
This patch replaces strcpy with strscpy, the recommended alternative for null terminated strings, to follow best practices.
---
This patch was reviewed by H. Peter Anvin and (by my understanding) was deemed ok to apply. I have not added a Reviewed-by tag as H. Peter Anvin did not do so.
The last time I resent this patch was during the merge window so it understandably did not get applied or further reviewed.
I have resent it again as the merge window has now closed, hopefully so it can be further reviewed and applied
--- arch/x86/kernel/cpu/intel.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/x86/kernel/cpu/intel.c +1 -1
@@ -607,7 +607,7 @@ static void init_intel(struct cpuinfo_x86 *c) }if (p) -strcpy (c->x86_model_id, p); +strscpy (c->x86_model_id, p); }#endif
Signature · 1 line
2.48.1
Borislav Petkov
maintainerQuoted 23 lines · Ruben Wauters
strcpy is deprecated due to lack of bounds checking.
This patch replaces strcpy with strscpy, the recommended alternative for null terminated strings, to follow best practices.Signed-off-by Ruben Wauters <[email protected]>---
This patch was reviewed by H. Peter Anvin and (by my understanding) was deemed ok to apply. I have not added a Reviewed-by tag as H. Peter Anvin did not do so.The last time I resent this patch was during the merge window so it understandably did not get applied or further reviewed.
I have resent it again as the merge window has now closed, hopefully so it can be further reviewed and applied--- arch/x86/kernel/cpu/intel.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)arch/x86/kernel/cpu/intel.c +0
-0
arch/x86/kernel/cpu/intel.c static void init_intel(struct cpuinfo_x86 *c) · line 612
Quoted 7 lines
arch/x86/kernel/cpu/intel.c +1
-1@@ -607,7 +607,7 @@ static void init_intel(struct cpuinfo_x86 *c) }if (p) -strcpy (c->x86_model_id, p); +strscpy (c->x86_model_id, p); }#endif
"strcpy()
--------strcpy() performs no bounds checking on the destination buffer. This could result in linear overflows beyond the end of the buffer, leading to all kinds of misbehaviors. While CONFIG_FORTIFY_SOURCE=y and various compiler flags help reduce the risk of using this function, there is no good reason to add new uses of this function."
From: Documentation/process/deprecated.rst
Note the "new uses of this function".
This is old code, there are no problems with it so unless I'm missing something, if it ain't broke, there's no need to fix it.
But I'm *sure* you'll find something else in the kernel which is really broken and you could send a fix then...
:-)
Thx.
Signature · 4 lines
Regards/Gruss,
Boris.
https://people.kernel.org/tglx/notes-about-netiquette