From: Florian Westphal <fw@strlen.de>
To: I Hsin Cheng <richard120310@gmail.com>
Cc: jhs@mojatatu.com, xiyou.wangcong@gmail.com, jiri@resnulli.us,
davem@davemloft.net, edumazet@google.com, kuba@kernel.org,
pabeni@redhat.com, horms@kernel.org, netdev@vger.kernel.org,
linux-kernel@vger.kernel.org, skhan@linuxfoundation.org,
linux-kernel-mentees@lists.linux.dev
Subject: Re: [RFC PATCH] net: sched: em_text: Replace strncpy() with strscpy_pad()
Date: Thu, 27 Mar 2025 17:23:25 +0100 [thread overview]
Message-ID: <20250327162325.GA30844@breakpoint.cc> (raw)
In-Reply-To: <20250327143733.187438-1-richard120310@gmail.com>
I Hsin Cheng <richard120310@gmail.com> wrote:
> The content within "conf.algo" should be a valid NULL-terminated string,
> however "strncpy()" doesn't guarantee that. Use strscpy_pad() to replace
> it to make sure "conf.algo" is NULL-terminated. ( trailing NULL-padding
> if source buffer is shorter. )
>
> Link: https://github.com/KSPP/linux/issues/90
> Signed-off-by: I Hsin Cheng <richard120310@gmail.com>
> ---
> net/sched/em_text.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/net/sched/em_text.c b/net/sched/em_text.c
> index 420c66203b17..c78b82931dc4 100644
> --- a/net/sched/em_text.c
> +++ b/net/sched/em_text.c
> @@ -108,7 +108,7 @@ static int em_text_dump(struct sk_buff *skb, struct tcf_ematch *m)
> struct text_match *tm = EM_TEXT_PRIV(m);
> struct tcf_em_text conf;
>
> - strncpy(conf.algo, tm->config->ops->name, sizeof(conf.algo) - 1);
> + strscpy_pad(conf.algo, tm->config->ops->name, sizeof(conf.algo) - 1);
Please drop the 3rd argument and then resend with a fixes tag:
Fixes: d675c989ed2d ("[PKT_SCHED]: Packet classification based on textsearch (ematch)")
As is, the last byte remains uninitialised.
next prev parent reply other threads:[~2025-03-27 16:23 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-03-27 14:37 [RFC PATCH] net: sched: em_text: Replace strncpy() with strscpy_pad() I Hsin Cheng
2025-03-27 16:23 ` Florian Westphal [this message]
2025-04-05 8:57 ` I Hsin Cheng
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=20250327162325.GA30844@breakpoint.cc \
--to=fw@strlen.de \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=horms@kernel.org \
--cc=jhs@mojatatu.com \
--cc=jiri@resnulli.us \
--cc=kuba@kernel.org \
--cc=linux-kernel-mentees@lists.linux.dev \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=richard120310@gmail.com \
--cc=skhan@linuxfoundation.org \
--cc=xiyou.wangcong@gmail.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.