* [PATCH] devlink/param: replace deprecated strcpy() with strscpy()
@ 2026-05-06 21:14 Álvaro Costa
2026-05-06 22:42 ` Jakub Kicinski
2026-05-07 8:04 ` David Laight
0 siblings, 2 replies; 8+ messages in thread
From: Álvaro Costa @ 2026-05-06 21:14 UTC (permalink / raw)
To: jiri
Cc: Álvaro Costa, David S. Miller, Eric Dumazet, Jakub Kicinski,
Paolo Abeni, Simon Horman, open list:DEVLINK, open list
Replace strcpy() call used to extract a string parameter from param_data
with strscpy(). Since strscpy() already performs bounds checking and
ensures the destination string is NUL-terminated, remove the string
length check as well.
Signed-off-by: Álvaro Costa <alvaroc.dev@gmail.com>
---
net/devlink/param.c | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/net/devlink/param.c b/net/devlink/param.c
index cf95268da5b0..26695b7e2861 100644
--- a/net/devlink/param.c
+++ b/net/devlink/param.c
@@ -536,11 +536,9 @@ devlink_param_value_get_from_info(const struct devlink_param *param,
value->vu64 = nla_get_u64(param_data);
break;
case DEVLINK_PARAM_TYPE_STRING:
- len = strnlen(nla_data(param_data), nla_len(param_data));
- if (len == nla_len(param_data) ||
- len >= __DEVLINK_PARAM_MAX_STRING_VALUE)
+ len = strscpy(value->vstr, nla_data(param_data));
+ if (len < 0)
return -EINVAL;
- strcpy(value->vstr, nla_data(param_data));
break;
case DEVLINK_PARAM_TYPE_BOOL:
if (param_data && nla_len(param_data))
--
2.53.0
^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH] devlink/param: replace deprecated strcpy() with strscpy()
2026-05-06 21:14 [PATCH] devlink/param: replace deprecated strcpy() with strscpy() Álvaro Costa
@ 2026-05-06 22:42 ` Jakub Kicinski
2026-05-06 23:52 ` Álvaro Costa
2026-05-07 8:04 ` David Laight
1 sibling, 1 reply; 8+ messages in thread
From: Jakub Kicinski @ 2026-05-06 22:42 UTC (permalink / raw)
To: Álvaro Costa
Cc: jiri, David S. Miller, Eric Dumazet, Paolo Abeni, Simon Horman,
open list:DEVLINK, open list
On Wed, 6 May 2026 18:14:11 -0300 Álvaro Costa wrote:
> Replace strcpy() call used to extract a string parameter from param_data
> with strscpy(). Since strscpy() already performs bounds checking and
> ensures the destination string is NUL-terminated, remove the string
> length check as well.
The current code validates the netlink attr is nul-terminated.
I'm not sure if your patch retains current behavior.
I am sure, however, that checking whether the change is correct
is a poor use of everyone's time.
Please don't send these sort of patches for networking.
--
pw-bot: reject
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] devlink/param: replace deprecated strcpy() with strscpy()
2026-05-06 22:42 ` Jakub Kicinski
@ 2026-05-06 23:52 ` Álvaro Costa
0 siblings, 0 replies; 8+ messages in thread
From: Álvaro Costa @ 2026-05-06 23:52 UTC (permalink / raw)
To: Jakub Kicinski
Cc: jiri, David S. Miller, Eric Dumazet, Paolo Abeni, Simon Horman,
open list:DEVLINK, open list
On Wed, May 6, 2026 at 7:42 PM Jakub Kicinski <kuba@kernel.org> wrote:
> The current code validates the netlink attr is nul-terminated.
> I'm not sure if your patch retains current behavior.
> I am sure, however, that checking whether the change is correct
> is a poor use of everyone's time.
> Please don't send these sort of patches for networking.
> --
> pw-bot: reject
Ok, thank you for the quick feedback!
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] devlink/param: replace deprecated strcpy() with strscpy()
2026-05-06 21:14 [PATCH] devlink/param: replace deprecated strcpy() with strscpy() Álvaro Costa
2026-05-06 22:42 ` Jakub Kicinski
@ 2026-05-07 8:04 ` David Laight
2026-05-07 14:52 ` Jakub Kicinski
1 sibling, 1 reply; 8+ messages in thread
From: David Laight @ 2026-05-07 8:04 UTC (permalink / raw)
To: Álvaro Costa
Cc: jiri, David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
Simon Horman, open list:DEVLINK, open list
On Wed, 6 May 2026 18:14:11 -0300
Álvaro Costa <alvaroc.dev@gmail.com> wrote:
> Replace strcpy() call used to extract a string parameter from param_data
> with strscpy(). Since strscpy() already performs bounds checking and
> ensures the destination string is NUL-terminated, remove the string
> length check as well.
>
> Signed-off-by: Álvaro Costa <alvaroc.dev@gmail.com>
> ---
> net/devlink/param.c | 6 ++----
> 1 file changed, 2 insertions(+), 4 deletions(-)
>
> diff --git a/net/devlink/param.c b/net/devlink/param.c
> index cf95268da5b0..26695b7e2861 100644
> --- a/net/devlink/param.c
> +++ b/net/devlink/param.c
> @@ -536,11 +536,9 @@ devlink_param_value_get_from_info(const struct devlink_param *param,
> value->vu64 = nla_get_u64(param_data);
> break;
> case DEVLINK_PARAM_TYPE_STRING:
> - len = strnlen(nla_data(param_data), nla_len(param_data));
> - if (len == nla_len(param_data) ||
> - len >= __DEVLINK_PARAM_MAX_STRING_VALUE)
> + len = strscpy(value->vstr, nla_data(param_data));
> + if (len < 0)
> return -EINVAL;
> - strcpy(value->vstr, nla_data(param_data));
The only sensible thing here is to replace the strcpy() with:
memcpy(value->vstr, nla_data(param_data), len + 1);
-- David
> break;
> case DEVLINK_PARAM_TYPE_BOOL:
> if (param_data && nla_len(param_data))
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] devlink/param: replace deprecated strcpy() with strscpy()
2026-05-07 8:04 ` David Laight
@ 2026-05-07 14:52 ` Jakub Kicinski
2026-05-07 21:10 ` David Laight
0 siblings, 1 reply; 8+ messages in thread
From: Jakub Kicinski @ 2026-05-07 14:52 UTC (permalink / raw)
To: David Laight
Cc: Álvaro Costa, jiri, David S. Miller, Eric Dumazet,
Paolo Abeni, Simon Horman, open list:DEVLINK, open list
On Thu, 7 May 2026 09:04:45 +0100 David Laight wrote:
> > case DEVLINK_PARAM_TYPE_STRING:
> > - len = strnlen(nla_data(param_data), nla_len(param_data));
> > - if (len == nla_len(param_data) ||
> > - len >= __DEVLINK_PARAM_MAX_STRING_VALUE)
> > + len = strscpy(value->vstr, nla_data(param_data));
> > + if (len < 0)
> > return -EINVAL;
> > - strcpy(value->vstr, nla_data(param_data));
>
> The only sensible thing here is to replace the strcpy() with:
> memcpy(value->vstr, nla_data(param_data), len + 1);
That'd probably be a good move, to avoid getting the broken strscpy()
conversion submissions. Care to send a patch?
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] devlink/param: replace deprecated strcpy() with strscpy()
2026-05-07 14:52 ` Jakub Kicinski
@ 2026-05-07 21:10 ` David Laight
0 siblings, 0 replies; 8+ messages in thread
From: David Laight @ 2026-05-07 21:10 UTC (permalink / raw)
To: Jakub Kicinski
Cc: Álvaro Costa, jiri, David S. Miller, Eric Dumazet,
Paolo Abeni, Simon Horman, open list:DEVLINK, open list
On Thu, 7 May 2026 07:52:34 -0700
Jakub Kicinski <kuba@kernel.org> wrote:
> On Thu, 7 May 2026 09:04:45 +0100 David Laight wrote:
> > > case DEVLINK_PARAM_TYPE_STRING:
> > > - len = strnlen(nla_data(param_data), nla_len(param_data));
> > > - if (len == nla_len(param_data) ||
> > > - len >= __DEVLINK_PARAM_MAX_STRING_VALUE)
> > > + len = strscpy(value->vstr, nla_data(param_data));
> > > + if (len < 0)
> > > return -EINVAL;
> > > - strcpy(value->vstr, nla_data(param_data));
> >
> > The only sensible thing here is to replace the strcpy() with:
> > memcpy(value->vstr, nla_data(param_data), len + 1);
>
> That'd probably be a good move, to avoid getting the broken strscpy()
> conversion submissions. Care to send a patch?
I'll lob one in soon.
I'm working my way through a compile that errors strcpy() except for
constant strings into arrays (ie the safe ones).
Why is it that the worst examples is in the 'secerity code' :-)
-- David
^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH] devlink/param: replace deprecated strcpy() with strscpy()
@ 2026-04-24 1:20 Álvaro Costa
2026-04-24 1:31 ` Jakub Kicinski
0 siblings, 1 reply; 8+ messages in thread
From: Álvaro Costa @ 2026-04-24 1:20 UTC (permalink / raw)
To: jiri
Cc: David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
Simon Horman, netdev, Álvaro Costa
Replace strcpy() call used to extract a string parameter from param_data
with strscpy(). Since strscpy() already performs bounds checking and
ensures the destination string is NUL-terminated, remove the string
length check as well.
Signed-off-by: Álvaro Costa <alvaroc.dev@gmail.com>
---
net/devlink/param.c | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/net/devlink/param.c b/net/devlink/param.c
index cf95268da5b0..26695b7e2861 100644
--- a/net/devlink/param.c
+++ b/net/devlink/param.c
@@ -536,11 +536,9 @@ devlink_param_value_get_from_info(const struct devlink_param *param,
value->vu64 = nla_get_u64(param_data);
break;
case DEVLINK_PARAM_TYPE_STRING:
- len = strnlen(nla_data(param_data), nla_len(param_data));
- if (len == nla_len(param_data) ||
- len >= __DEVLINK_PARAM_MAX_STRING_VALUE)
+ len = strscpy(value->vstr, nla_data(param_data));
+ if (len < 0)
return -EINVAL;
- strcpy(value->vstr, nla_data(param_data));
break;
case DEVLINK_PARAM_TYPE_BOOL:
if (param_data && nla_len(param_data))
--
2.53.0
^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH] devlink/param: replace deprecated strcpy() with strscpy()
2026-04-24 1:20 Álvaro Costa
@ 2026-04-24 1:31 ` Jakub Kicinski
0 siblings, 0 replies; 8+ messages in thread
From: Jakub Kicinski @ 2026-04-24 1:31 UTC (permalink / raw)
To: Álvaro Costa
Cc: jiri, David S. Miller, Eric Dumazet, Paolo Abeni, Simon Horman,
netdev
On Thu, 23 Apr 2026 22:20:22 -0300 Álvaro Costa wrote:
> Replace strcpy() call used to extract a string parameter from param_data
> with strscpy(). Since strscpy() already performs bounds checking and
> ensures the destination string is NUL-terminated, remove the string
> length check as well.
## Form letter - net-next-closed
We have already submitted our pull request with net-next material for v7.1,
and therefore net-next is closed for new drivers, features, code refactoring
and optimizations. We are currently accepting bug fixes only.
Please repost when net-next reopens after Apr 27th.
RFC patches sent for review only are obviously welcome at any time.
See: https://www.kernel.org/doc/html/next/process/maintainer-netdev.html#development-cycle
--
pw-bot: defer
pv-bot: closed
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2026-05-07 21:10 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-05-06 21:14 [PATCH] devlink/param: replace deprecated strcpy() with strscpy() Álvaro Costa
2026-05-06 22:42 ` Jakub Kicinski
2026-05-06 23:52 ` Álvaro Costa
2026-05-07 8:04 ` David Laight
2026-05-07 14:52 ` Jakub Kicinski
2026-05-07 21:10 ` David Laight
-- strict thread matches above, loose matches on Subject: below --
2026-04-24 1:20 Álvaro Costa
2026-04-24 1:31 ` Jakub Kicinski
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox