From: David Laight <david.laight.linux@gmail.com>
To: "Álvaro Costa" <alvaroc.dev@gmail.com>
Cc: jiri@resnulli.us, "David S. Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@google.com>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
Simon Horman <horms@kernel.org>,
netdev@vger.kernel.org (open list:DEVLINK),
linux-kernel@vger.kernel.org (open list)
Subject: Re: [PATCH] devlink/param: replace deprecated strcpy() with strscpy()
Date: Thu, 7 May 2026 09:04:45 +0100 [thread overview]
Message-ID: <20260507090445.3448d536@pumpkin> (raw)
In-Reply-To: <20260506211415.16343-1-alvaroc.dev@gmail.com>
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))
next prev parent reply other threads:[~2026-05-07 8:04 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
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 [this message]
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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260507090445.3448d536@pumpkin \
--to=david.laight.linux@gmail.com \
--cc=alvaroc.dev@gmail.com \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=horms@kernel.org \
--cc=jiri@resnulli.us \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.