From: Kees Cook <keescook@chromium.org>
To: laniel_francis@privacyrequired.com
Cc: linux-hardening@vger.kernel.org, netdev@vger.kernel.org,
davem@davemloft.net, kuba@kernel.org
Subject: Re: [RFC][PATCH v3 1/3] Fix unefficient call to memset before memcpu in nla_strlcpy.
Date: Wed, 21 Oct 2020 16:46:23 -0700 [thread overview]
Message-ID: <202010211646.28D4C5642@keescook> (raw)
In-Reply-To: <20201020164707.30402-2-laniel_francis@privacyrequired.com>
On Tue, Oct 20, 2020 at 06:47:05PM +0200, laniel_francis@privacyrequired.com wrote:
> From: Francis Laniel <laniel_francis@privacyrequired.com>
>
> Before this commit, nla_strlcpy first memseted dst to 0 then wrote src into it.
> This is inefficient because bytes whom number is less than src length are written
> twice.
>
> This patch solves this issue by first writing src into dst then fill dst with
> 0's.
> Note that, in the case where src length is higher than dst, only 0 is written.
> Otherwise there are as many 0's written to fill dst.
>
> For example, if src is "foo\0" and dst is 5 bytes long, the result will be:
> 1. "fooGG" after memcpy (G means garbage).
> 2. "foo\0\0" after memset.
>
> Signed-off-by: Francis Laniel <laniel_francis@privacyrequired.com>
Looks good! (If there are future versions of this series, I think you
can drop the RFC part...)
Reviewed-by: Kees Cook <keescook@chromium.org>
--
Kees Cook
next prev parent reply other threads:[~2020-10-21 23:46 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-10-20 16:47 [RFC][PATCH v3 0/3] Fix inefficiences and rename nla_strlcpy laniel_francis
2020-10-20 16:47 ` [RFC][PATCH v3 1/3] Fix unefficient call to memset before memcpu in nla_strlcpy laniel_francis
2020-10-21 23:46 ` Kees Cook [this message]
2020-10-20 16:47 ` [RFC][PATCH v3 2/3] Modify return value of nla_strlcpy to match that of strscpy laniel_francis
2020-10-21 23:48 ` Kees Cook
2020-10-22 9:40 ` Francis Laniel
2020-10-20 16:47 ` [RFC][PATCH v3 3/3] Rename nla_strlcpy to nla_strscpy laniel_francis
2020-10-21 23:49 ` Kees Cook
2020-10-22 9:41 ` Francis Laniel
2020-10-22 20:04 ` Kees Cook
2020-10-22 23:05 ` Jakub Kicinski
2020-10-23 8:07 ` David Laight
2020-10-23 15:15 ` Francis Laniel
2020-10-23 15:29 ` Jakub Kicinski
2020-10-23 17:41 ` Kees Cook
2020-10-23 15:16 ` Francis Laniel
2020-10-24 10:41 ` Francis Laniel
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=202010211646.28D4C5642@keescook \
--to=keescook@chromium.org \
--cc=davem@davemloft.net \
--cc=kuba@kernel.org \
--cc=laniel_francis@privacyrequired.com \
--cc=linux-hardening@vger.kernel.org \
--cc=netdev@vger.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).