* [PATCH] x86/cpu/intel: replace deprecated strcpy with strscpy [not found] <20250507185459.8769-1-rubenru09.ref@aol.com> @ 2025-05-07 18:51 ` Ruben Wauters 2025-05-07 20:14 ` H. Peter Anvin 0 siblings, 1 reply; 5+ messages in thread From: Ruben Wauters @ 2025-05-07 18:51 UTC (permalink / raw) To: Thomas Gleixner, Ingo Molnar, Borislav Petkov, Dave Hansen, x86 Cc: Ruben Wauters, H. Peter Anvin, linux-kernel 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 <rubenru09@aol.com> --- arch/x86/kernel/cpu/intel.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/x86/kernel/cpu/intel.c b/arch/x86/kernel/cpu/intel.c index 584dd55bf739..b49bba30434d 100644 --- a/arch/x86/kernel/cpu/intel.c +++ b/arch/x86/kernel/cpu/intel.c @@ -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 -- 2.48.1 ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] x86/cpu/intel: replace deprecated strcpy with strscpy 2025-05-07 18:51 ` [PATCH] x86/cpu/intel: replace deprecated strcpy with strscpy Ruben Wauters @ 2025-05-07 20:14 ` H. Peter Anvin 2025-05-07 20:30 ` Ruben Wauters 0 siblings, 1 reply; 5+ messages in thread From: H. Peter Anvin @ 2025-05-07 20:14 UTC (permalink / raw) To: Ruben Wauters, Thomas Gleixner, Ingo Molnar, Borislav Petkov, Dave Hansen, x86 Cc: linux-kernel On May 7, 2025 11:51:36 AM PDT, Ruben Wauters <rubenru09@aol.com> wrote: >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 <rubenru09@aol.com> >--- > arch/x86/kernel/cpu/intel.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > >diff --git a/arch/x86/kernel/cpu/intel.c b/arch/x86/kernel/cpu/intel.c >index 584dd55bf739..b49bba30434d 100644 >--- a/arch/x86/kernel/cpu/intel.c >+++ b/arch/x86/kernel/cpu/intel.c >@@ -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 > strscpy() needs a buffer length; this patch wouldn't even compile! Not to mention that the string in question is generated in such a way that cannot be unterminated. ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] x86/cpu/intel: replace deprecated strcpy with strscpy 2025-05-07 20:14 ` H. Peter Anvin @ 2025-05-07 20:30 ` Ruben Wauters 2025-05-14 19:16 ` Ruben Wauters 0 siblings, 1 reply; 5+ messages in thread From: Ruben Wauters @ 2025-05-07 20:30 UTC (permalink / raw) To: H. Peter Anvin, Thomas Gleixner, Ingo Molnar, Borislav Petkov, Dave Hansen, x86 Cc: linux-kernel On Wed, 2025-05-07 at 13:14 -0700, H. Peter Anvin wrote: > On May 7, 2025 11:51:36 AM PDT, Ruben Wauters <rubenru09@aol.com> > wrote: > > 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 <rubenru09@aol.com> > > --- > > arch/x86/kernel/cpu/intel.c | 2 +- > > 1 file changed, 1 insertion(+), 1 deletion(-) > > > > diff --git a/arch/x86/kernel/cpu/intel.c > > b/arch/x86/kernel/cpu/intel.c > > index 584dd55bf739..b49bba30434d 100644 > > --- a/arch/x86/kernel/cpu/intel.c > > +++ b/arch/x86/kernel/cpu/intel.c > > @@ -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 > > > > strscpy() needs a buffer length; this patch wouldn't even compile! Hi, this is incorrect, strscpy is defined in string.h as #define strscpy(dst, src, ...) \ CONCATENATE(__strscpy, COUNT_ARGS(__VA_ARGS__))(dst, src, __VA_ARGS__) the third parameter is optional, and it works perfectly fine with two parameters. I have compiled it, and there are no errors. > Not to mention that the string in question is generated in such a way > that cannot be unterminated. I'm not entirely sure what you mean here? The assignments above are null terminated strings, which the two parameter version works fine with. ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] x86/cpu/intel: replace deprecated strcpy with strscpy 2025-05-07 20:30 ` Ruben Wauters @ 2025-05-14 19:16 ` Ruben Wauters 2025-05-15 4:54 ` H. Peter Anvin 0 siblings, 1 reply; 5+ messages in thread From: Ruben Wauters @ 2025-05-14 19:16 UTC (permalink / raw) To: H. Peter Anvin, Thomas Gleixner, Ingo Molnar, Borislav Petkov, Dave Hansen, x86 Cc: linux-kernel On Wed, 2025-05-07 at 21:30 +0100, Ruben Wauters wrote: > On Wed, 2025-05-07 at 13:14 -0700, H. Peter Anvin wrote: > > On May 7, 2025 11:51:36 AM PDT, Ruben Wauters <rubenru09@aol.com> > > wrote: > > > 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 <rubenru09@aol.com> > > > --- > > > arch/x86/kernel/cpu/intel.c | 2 +- > > > 1 file changed, 1 insertion(+), 1 deletion(-) > > > > > > diff --git a/arch/x86/kernel/cpu/intel.c > > > b/arch/x86/kernel/cpu/intel.c > > > index 584dd55bf739..b49bba30434d 100644 > > > --- a/arch/x86/kernel/cpu/intel.c > > > +++ b/arch/x86/kernel/cpu/intel.c > > > @@ -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 > > > > > > > strscpy() needs a buffer length; this patch wouldn't even compile! > > Hi, this is incorrect, strscpy is defined in string.h as > #define strscpy(dst, src, ...) \ > CONCATENATE(__strscpy, COUNT_ARGS(__VA_ARGS__))(dst, src, > __VA_ARGS__) > > the third parameter is optional, and it works perfectly fine with two > parameters. I have compiled it, and there are no errors. > > > Not to mention that the string in question is generated in such a > > way > > that cannot be unterminated. > > I'm not entirely sure what you mean here? The assignments above are > null terminated strings, which the two parameter version works fine > with. Hello Just wanted to check that everything was ok with this patch, and that any concerns were addressed or explained. Please do let me know if there is anything I need to do or change to get this patch applied. Ruben Wauters ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] x86/cpu/intel: replace deprecated strcpy with strscpy 2025-05-14 19:16 ` Ruben Wauters @ 2025-05-15 4:54 ` H. Peter Anvin 0 siblings, 0 replies; 5+ messages in thread From: H. Peter Anvin @ 2025-05-15 4:54 UTC (permalink / raw) To: Ruben Wauters, Thomas Gleixner, Ingo Molnar, Borislav Petkov, Dave Hansen, x86 Cc: linux-kernel On May 14, 2025 12:16:20 PM PDT, Ruben Wauters <rubenru09@aol.com> wrote: >On Wed, 2025-05-07 at 21:30 +0100, Ruben Wauters wrote: >> On Wed, 2025-05-07 at 13:14 -0700, H. Peter Anvin wrote: >> > On May 7, 2025 11:51:36 AM PDT, Ruben Wauters <rubenru09@aol.com> >> > wrote: >> > > 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 <rubenru09@aol.com> >> > > --- >> > > arch/x86/kernel/cpu/intel.c | 2 +- >> > > 1 file changed, 1 insertion(+), 1 deletion(-) >> > > >> > > diff --git a/arch/x86/kernel/cpu/intel.c >> > > b/arch/x86/kernel/cpu/intel.c >> > > index 584dd55bf739..b49bba30434d 100644 >> > > --- a/arch/x86/kernel/cpu/intel.c >> > > +++ b/arch/x86/kernel/cpu/intel.c >> > > @@ -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 >> > > >> > >> > strscpy() needs a buffer length; this patch wouldn't even compile! >> >> Hi, this is incorrect, strscpy is defined in string.h as >> #define strscpy(dst, src, ...) \ >> CONCATENATE(__strscpy, COUNT_ARGS(__VA_ARGS__))(dst, src, >> __VA_ARGS__) >> >> the third parameter is optional, and it works perfectly fine with two >> parameters. I have compiled it, and there are no errors. >> >> > Not to mention that the string in question is generated in such a >> > way >> > that cannot be unterminated. >> >> I'm not entirely sure what you mean here? The assignments above are >> null terminated strings, which the two parameter version works fine >> with. > >Hello > >Just wanted to check that everything was ok with this patch, and that >any concerns were addressed or explained. Please do let me know if >there is anything I need to do or change to get this patch applied. > >Ruben Wauters > Yes, I stand corrected. I still think it is superfluous (or arguably a memcpy would be better, since this is a fixed length) but it doesn't hurt enything. ^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2025-05-15 4:54 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
[not found] <20250507185459.8769-1-rubenru09.ref@aol.com>
2025-05-07 18:51 ` [PATCH] x86/cpu/intel: replace deprecated strcpy with strscpy Ruben Wauters
2025-05-07 20:14 ` H. Peter Anvin
2025-05-07 20:30 ` Ruben Wauters
2025-05-14 19:16 ` Ruben Wauters
2025-05-15 4:54 ` H. Peter Anvin
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®