* [PATCH v1] char: ipmi: Replace deprecated strcpy with strscpy
@ 2026-10-01 17:22 Ashutosh Yadav
2026-10-01 22:14 ` Corey Minyard
0 siblings, 1 reply; 2+ messages in thread
From: Ashutosh Yadav @ 2026-10-01 17:22 UTC (permalink / raw)
To: corey; +Cc: openipmi-developer, linux-kernel, Ashutosh Yadav
strcpy() has been deprecated because it is generally unsafe and can lead
to buffer overflows. It is actively being removed from the kernel.
In action_op() and preop_op() (and related functions), strings are copied
into fixed-size buffers. Replace the strcpy() calls with strscpy() using
the sizeof() the destination buffers to guarantee NUL-termination and
prevent any potential bounds issues, ensuring compliance with safe string
APIs.
Link: https://github.com/KSPP/linux/issues/88
Signed-off-by: Ashutosh Yadav <yadavxashutosh@gmail.com>
---
drivers/char/ipmi/ipmi_watchdog.c | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/drivers/char/ipmi/ipmi_watchdog.c b/drivers/char/ipmi/ipmi_watchdog.c
index a013ddbf1466..79d4958df6ef 100644
--- a/drivers/char/ipmi/ipmi_watchdog.c
+++ b/drivers/char/ipmi/ipmi_watchdog.c
@@ -1166,13 +1166,13 @@ static int action_op(const char *inval, char *outval)
int rv;
if (outval)
- strcpy(outval, action);
+ strscpy(outval, action, sizeof(action));
if (!inval)
return 0;
rv = action_op_set_val(inval);
if (!rv)
- strcpy(action, inval);
+ strscpy(action, inval, sizeof(action));
return rv;
}
@@ -1198,13 +1198,13 @@ static int preaction_op(const char *inval, char *outval)
int rv;
if (outval)
- strcpy(outval, preaction);
+ strscpy(outval, preaction, sizeof(preaction));
if (!inval)
return 0;
rv = preaction_op_set_val(inval);
if (!rv)
- strcpy(preaction, inval);
+ strscpy(preaction, inval, sizeof(preaction));
return 0;
}
@@ -1226,14 +1226,14 @@ static int preop_op(const char *inval, char *outval)
int rv;
if (outval)
- strcpy(outval, preop);
+ strscpy(outval, preop, sizeof(preop));
if (!inval)
return 0;
rv = preop_op_set_val(inval);
if (!rv)
- strcpy(preop, inval);
+ strscpy(preop, inval, sizeof(preop));
return 0;
}
--
2.43.0
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH v1] char: ipmi: Replace deprecated strcpy with strscpy
2026-10-01 17:22 [PATCH v1] char: ipmi: Replace deprecated strcpy with strscpy Ashutosh Yadav
@ 2026-10-01 22:14 ` Corey Minyard
0 siblings, 0 replies; 2+ messages in thread
From: Corey Minyard @ 2026-10-01 22:14 UTC (permalink / raw)
To: Ashutosh Yadav; +Cc: openipmi-developer, linux-kernel
On Thu, Oct 01, 2026 at 10:52:09PM +0530, Ashutosh Yadav wrote:
> strcpy() has been deprecated because it is generally unsafe and can lead
> to buffer overflows. It is actively being removed from the kernel.
>
> In action_op() and preop_op() (and related functions), strings are copied
> into fixed-size buffers. Replace the strcpy() calls with strscpy() using
> the sizeof() the destination buffers to guarantee NUL-termination and
> prevent any potential bounds issues, ensuring compliance with safe string
> APIs.
Applied, thank you.
-corey
>
> Link: https://github.com/KSPP/linux/issues/88
> Signed-off-by: Ashutosh Yadav <yadavxashutosh@gmail.com>
> ---
> drivers/char/ipmi/ipmi_watchdog.c | 12 ++++++------
> 1 file changed, 6 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/char/ipmi/ipmi_watchdog.c b/drivers/char/ipmi/ipmi_watchdog.c
> index a013ddbf1466..79d4958df6ef 100644
> --- a/drivers/char/ipmi/ipmi_watchdog.c
> +++ b/drivers/char/ipmi/ipmi_watchdog.c
> @@ -1166,13 +1166,13 @@ static int action_op(const char *inval, char *outval)
> int rv;
>
> if (outval)
> - strcpy(outval, action);
> + strscpy(outval, action, sizeof(action));
>
> if (!inval)
> return 0;
> rv = action_op_set_val(inval);
> if (!rv)
> - strcpy(action, inval);
> + strscpy(action, inval, sizeof(action));
> return rv;
> }
>
> @@ -1198,13 +1198,13 @@ static int preaction_op(const char *inval, char *outval)
> int rv;
>
> if (outval)
> - strcpy(outval, preaction);
> + strscpy(outval, preaction, sizeof(preaction));
>
> if (!inval)
> return 0;
> rv = preaction_op_set_val(inval);
> if (!rv)
> - strcpy(preaction, inval);
> + strscpy(preaction, inval, sizeof(preaction));
> return 0;
> }
>
> @@ -1226,14 +1226,14 @@ static int preop_op(const char *inval, char *outval)
> int rv;
>
> if (outval)
> - strcpy(outval, preop);
> + strscpy(outval, preop, sizeof(preop));
>
> if (!inval)
> return 0;
>
> rv = preop_op_set_val(inval);
> if (!rv)
> - strcpy(preop, inval);
> + strscpy(preop, inval, sizeof(preop));
> return 0;
> }
>
> --
> 2.43.0
>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-10-01 22:15 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-10-01 17:22 [PATCH v1] char: ipmi: Replace deprecated strcpy with strscpy Ashutosh Yadav
2026-10-01 22:14 ` Corey Minyard
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®