From: Kees Cook <keescook@chromium.org>
To: Peng Fan <peng.fan@nxp.com>
Cc: "sboyd@kernel.org" <sboyd@kernel.org>,
"linux@armlinux.org.uk" <linux@armlinux.org.uk>,
dl-linux-imx <linux-imx@nxp.com>,
"linux-clk@vger.kernel.org" <linux-clk@vger.kernel.org>,
"linux-arm-kernel@lists.infradead.org"
<linux-arm-kernel@lists.infradead.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
Alice Guo <alice.guo@nxp.com>
Subject: Re: [PATCH] clk: clkdev: Replace strlcpy with strscpy
Date: Fri, 15 Nov 2019 09:00:26 -0800 [thread overview]
Message-ID: <201911150900.817CDE33@keescook> (raw)
In-Reply-To: <1573812819-5030-1-git-send-email-peng.fan@nxp.com>
On Fri, Nov 15, 2019 at 10:17:53AM +0000, Peng Fan wrote:
> From: Peng Fan <peng.fan@nxp.com>
>
> The implementation of strscpy() is more robust and safer.
>
> The strscpy was introduced to fix some API problems around strlcpy.
> strscpy is preferred to strlcpy() since the API doesn't require
> reading memory from the src string beyond the specified "count" bytes,
> and since the return value is easier to error-check than strlcpy()'s.
> In addition, the implementation is robust to the string changing out
> from underneath it, unlike the current strlcpy() implementation.
>
> Cc: Kees Cook <keescook@chromium.org>
> Signed-off-by: Peng Fan <peng.fan@nxp.com>
Reviewed-by: Kees Cook <keescook@chromium.org>
-Kees
> ---
> drivers/clk/clkdev.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/clk/clkdev.c b/drivers/clk/clkdev.c
> index 0f2e3fcf0f19..ee56109bc0b4 100644
> --- a/drivers/clk/clkdev.c
> +++ b/drivers/clk/clkdev.c
> @@ -165,7 +165,7 @@ vclkdev_alloc(struct clk_hw *hw, const char *con_id, const char *dev_fmt,
>
> cla->cl.clk_hw = hw;
> if (con_id) {
> - strlcpy(cla->con_id, con_id, sizeof(cla->con_id));
> + strscpy(cla->con_id, con_id, sizeof(cla->con_id));
> cla->cl.con_id = cla->con_id;
> }
>
> --
> 2.16.4
>
--
Kees Cook
prev parent reply other threads:[~2019-11-15 17:00 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-11-15 10:17 [PATCH] clk: clkdev: Replace strlcpy with strscpy Peng Fan
2019-11-15 17:00 ` Kees Cook [this message]
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=201911150900.817CDE33@keescook \
--to=keescook@chromium.org \
--cc=alice.guo@nxp.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-clk@vger.kernel.org \
--cc=linux-imx@nxp.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@armlinux.org.uk \
--cc=peng.fan@nxp.com \
--cc=sboyd@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;
as well as URLs for NNTP newsgroup(s).