* [PATCH] powerpc/pseries/lparcfg: Replace deprecated strcpy in parse_system_parameter_string
@ 2025-10-13 13:57 Thorsten Blum
2026-06-19 22:00 ` Madhavan Srinivasan
0 siblings, 1 reply; 2+ messages in thread
From: Thorsten Blum @ 2025-10-13 13:57 UTC (permalink / raw)
To: Madhavan Srinivasan, Michael Ellerman, Nicholas Piggin,
Christophe Leroy, Thomas Weißschuh, Thomas Gleixner
Cc: linux-hardening, Thorsten Blum, linuxppc-dev, linux-kernel
strcpy() is deprecated; use strscpy() instead. Use the return value of
strscpy() instead of calling strlen() again, and ignore any potential
string truncation since both strings are much shorter than the buffer
size SPLPAR_MAXLENGTH.
Change both if conditions to silence the following checkpatch warnings:
Comparisons should place the constant on the right side of the test
Link: https://github.com/KSPP/linux/issues/88
Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev>
---
arch/powerpc/platforms/pseries/lparcfg.c | 24 +++++++++++++-----------
1 file changed, 13 insertions(+), 11 deletions(-)
diff --git a/arch/powerpc/platforms/pseries/lparcfg.c b/arch/powerpc/platforms/pseries/lparcfg.c
index cc22924f159f..533a6edf2e03 100644
--- a/arch/powerpc/platforms/pseries/lparcfg.c
+++ b/arch/powerpc/platforms/pseries/lparcfg.c
@@ -22,6 +22,7 @@
#include <asm/papr-sysparm.h>
#include <linux/seq_file.h>
#include <linux/slab.h>
+#include <linux/string.h>
#include <linux/uaccess.h>
#include <linux/hugetlb.h>
#include <asm/lppaca.h>
@@ -420,17 +421,18 @@ static void parse_system_parameter_string(struct seq_file *m)
w_idx = 0;
} else if (local_buffer[idx] == '=') {
/* code here to replace workbuffer contents
- with different keyword strings */
- if (0 == strcmp(workbuffer, "MaxEntCap")) {
- strcpy(workbuffer,
- "partition_max_entitled_capacity");
- w_idx = strlen(workbuffer);
- }
- if (0 == strcmp(workbuffer, "MaxPlatProcs")) {
- strcpy(workbuffer,
- "system_potential_processors");
- w_idx = strlen(workbuffer);
- }
+ * with different keyword strings. Truncation
+ * by strscpy is deliberately ignored because
+ * SPLPAR_MAXLENGTH >= maximum string size.
+ */
+ if (!strcmp(workbuffer, "MaxEntCap"))
+ w_idx = strscpy(workbuffer,
+ "partition_max_entitled_capacity",
+ SPLPAR_MAXLENGTH);
+ if (!strcmp(workbuffer, "MaxPlatProcs"))
+ w_idx = strscpy(workbuffer,
+ "system_potential_processors",
+ SPLPAR_MAXLENGTH);
}
}
kfree(workbuffer);
--
2.51.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] powerpc/pseries/lparcfg: Replace deprecated strcpy in parse_system_parameter_string
2025-10-13 13:57 [PATCH] powerpc/pseries/lparcfg: Replace deprecated strcpy in parse_system_parameter_string Thorsten Blum
@ 2026-06-19 22:00 ` Madhavan Srinivasan
0 siblings, 0 replies; 2+ messages in thread
From: Madhavan Srinivasan @ 2026-06-19 22:00 UTC (permalink / raw)
To: Michael Ellerman, Nicholas Piggin, Thomas Weißschuh,
Christophe Leroy, Thomas Gleixner, Thorsten Blum
Cc: linux-hardening, linuxppc-dev, linux-kernel
On Mon, 13 Oct 2025 15:57:02 +0200, Thorsten Blum wrote:
> strcpy() is deprecated; use strscpy() instead. Use the return value of
> strscpy() instead of calling strlen() again, and ignore any potential
> string truncation since both strings are much shorter than the buffer
> size SPLPAR_MAXLENGTH.
>
> Change both if conditions to silence the following checkpatch warnings:
>
> [...]
Applied to powerpc/next.
[1/1] powerpc/pseries/lparcfg: Replace deprecated strcpy in parse_system_parameter_string
https://git.kernel.org/powerpc/c/c8f80f95da32618d49c2a068ee561b85655b761d
cheers
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-06-19 22:00 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-10-13 13:57 [PATCH] powerpc/pseries/lparcfg: Replace deprecated strcpy in parse_system_parameter_string Thorsten Blum
2026-06-19 22:00 ` Madhavan Srinivasan
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).