Skip to contentSkip to conversation

x86/cpu/intel: replace deprecated strcpy with strscpy

PATCH RESEND Superseded Ruben Wauters 2 participants 3 messages May 20, 2025 – May 28, 2025 1 message not in the archive x86

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

#1 lore raw

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. However this patch has not been applied after 2 weeks, so I am resending it. I have not added a Reviewed-by tag as H. Peter Anvin did not do so.

I also wanted to note that while immediately this may not have any effect, any addition or changes to the strings above may possibly overflow the fixed buffer of 64, and the use of strscpy instead of strcpy will help prevent any buffer overflows by copying a max amount of bytes. I do also recognise however that the strings above are unlikely to be added to, as (by my understanding) they'd require intel to release a CPU where the x86_model_id would not be detectable.

I still believe that while the above scenerio may not come to pass, the replacement of a deprecated API with the preferred alternative is good practice and should be done.

---
 arch/x86/kernel/cpu/intel.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/x86/kernel/cpu/intel.c +1 -1
index 584dd55bf739..b49bba30434d 100644
@@ -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
#2 lore raw
Quoted 44 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.

---
This patch was reviewed by H. Peter Anvin and (by my understanding) was deemed ok to apply. However this patch has not been applied after 2
weeks, so I am resending it. I have not added a Reviewed-by tag as H. Peter Anvin did not do so.

I also wanted to note that while immediately this may not have any effect, any addition or changes to the strings above may possibly overflow the fixed buffer of 64, and the use of strscpy instead of strcpy will help prevent any buffer overflows by copying a max amount of
bytes. I do also recognise however that the strings above are unlikely
to be added to, as (by my understanding) they'd require intel to release
a CPU where the x86_model_id would not be detectable.

I still believe that while the above scenerio may not come to pass, the
replacement of a deprecated API with the preferred alternative is good
practice and should be done.
---
 arch/x86/kernel/cpu/intel.c | 2 +-

 1 file changed, 1 insertion(+), 1 deletion(-)
arch/x86/kernel/cpu/intel.c +0 -0
index 584dd55bf739..b49bba30434d 100644
@@ -607,7 +607,7 @@ static void init_intel(struct cpuinfo_x86 *c)
  		}


  if (p)

arch/x86/kernel/cpu/intel.c +1 -1
-			strcpy(c->x86_model_id, p);
+			strscpy(c->x86_model_id, p);
Quoted 3 lines

  }
 #endif

Hello
I was wondering if there was any chance this patch could be applied? is there something I need to do to change it so it's fine? is there someone else I need to send it to so they can review it?

I don't want to keep sending and asking about an unwanted patch so if this isn't wanted please let me know and I'll move on.

Thank you

Ruben Wauters

maintainer
#3 lore raw

Hi,

Quoted 6 lines · Ruben Wauters

I was wondering if there was any chance this patch could be applied? is there something I need to do to change it so it's fine? is there someone else I need to send it to so they can review it?

I don't want to keep sending and asking about an unwanted patch so if this isn't wanted please let me know and I'll move on.

the tip tree is open for new code after the merge window is over.

From: Documentation/process/maintainer-tip.rst

Merge window
^^^^^^^^^^^^

Please do not expect large patch series to be handled during the merge window or even during the week before. Such patches should be submitted in mergeable state *at* *least* a week before the merge window opens. Exceptions are made for bug fixes and *sometimes* for small standalone drivers for new hardware or minimally invasive patches for hardware enablement.

During the merge window, the maintainers instead focus on following the upstream changes, fixing merge window fallout, collecting bug fixes, and allowing themselves a breath. Please respect that.

The release candidate -rc1 is the starting point for new patches to be applied which are targeted for the next merge window."

IOW, be patient please. You're not the only one with a patch...

Thx.

Signature · 4 lines
Regards/Gruss,
    Boris.

https://people.kernel.org/tglx/notes-about-netiquette