From: Greg KH <gregkh@linuxfoundation.org>
To: guo.ziliang@zte.com.cn
Cc: tj@kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH linux-next] kernfs: use strscpy() is more robust and safer
Date: Tue, 15 Nov 2022 07:43:05 +0100 [thread overview]
Message-ID: <Y3M0+fNWo+lrEPZw@kroah.com> (raw)
In-Reply-To: <202211150847452601249@zte.com.cn>
On Tue, Nov 15, 2022 at 08:47:45AM +0800, guo.ziliang@zte.com.cn wrote:
> From: guo ziliang <guo.ziliang@zte.com.cn>
>
> The implementation of strscpy() is more robust and safer.
How exactly is it more robust and safer?
> That's now the recommended way to copy NUL terminated strings.
Recommended by whom for what?
>
> Signed-off-by: guo ziliang <guo.ziliang@zte.com.cn>
> ---
> fs/kernfs/dir.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/fs/kernfs/dir.c b/fs/kernfs/dir.c
> index 77d7a3a..fbb8df4 100644
> --- a/fs/kernfs/dir.c
> +++ b/fs/kernfs/dir.c
> @@ -844,7 +844,7 @@ static struct kernfs_node *kernfs_walk_ns(struct kernfs_node *parent,
>
> spin_lock_irq(&kernfs_pr_cont_lock);
>
> - len = strlcpy(kernfs_pr_cont_buf, path, sizeof(kernfs_pr_cont_buf));
> + len = strscpy(kernfs_pr_cont_buf, path, sizeof(kernfs_pr_cont_buf));
How did you test this change is correct and does not cause any problems?
How was this issue found?
thanks,
greg k-h
next prev parent reply other threads:[~2022-11-15 6:43 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-11-15 0:47 [PATCH linux-next] kernfs: use strscpy() is more robust and safer guo.ziliang
2022-11-15 6:43 ` Greg KH [this message]
2022-11-15 10:32 ` Greg KH
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=Y3M0+fNWo+lrEPZw@kroah.com \
--to=gregkh@linuxfoundation.org \
--cc=guo.ziliang@zte.com.cn \
--cc=linux-kernel@vger.kernel.org \
--cc=tj@kernel.org \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox