All of lore.kernel.org
 help / color / mirror / Atom feed
From: "J. Bruce Fields" <bfields@fieldses.org>
To: Joe Perches <joe@perches.com>
Cc: Chuck Lever <chuck.lever@oracle.com>,
	linux-nfs@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 8/8] nfsd: Fix misuse of strlcpy
Date: Tue, 9 Jul 2019 19:33:53 -0400	[thread overview]
Message-ID: <20190709233353.GA1536@fieldses.org> (raw)
In-Reply-To: <9a5dedb0c9221743033f28974820e8dd724e388d.camel@perches.com>

On Mon, Jul 08, 2019 at 10:40:50PM -0700, Joe Perches wrote:
> On Mon, 2019-07-08 at 23:14 -0400, J. Bruce Fields wrote:
> > On Thu, Jul 04, 2019 at 04:57:48PM -0700, Joe Perches wrote:
> > > Probable cut&paste typo - use the correct field size.
> > 
> > Huh, that's been there forever, I wonder why we haven't seen crashes?
> > Oh, I see, name and authname both have the same size.
> > 
> > Anyway, makes sense, thanks.  Will apply for 5.3.
> > 
> > (Unless someone else is getting this; I didn't get copied on the rest of
> > the series.)
> 
> It's generally hard to cc everyone on treewide fixes like this.
> 
> There's no good mechanism I know of.
> vger mailing lists reject emails with too many addressees.

Yeah.  I guess what I don't understand is why this patch is part of a
series at all.  It makes me wonder if there's some dependency I missed
or if the 0/8 mail actually asked somebody else to apply it.

Whatever, I guess I'm being silly, it clearly stands alone.  Applying
for 5.3.

> Do you have an opinion on adding the stracpy macro which
> could avoid many of these defects?

I don't have an opinion.

--b.


> ---
>  include/linux/string.h | 16 ++++++++++++++++
>  1 file changed, 16 insertions(+)
> 
> diff --git a/include/linux/string.h b/include/linux/string.h
> index 4deb11f7976b..ef01bd6f19df 100644
> --- a/include/linux/string.h
> +++ b/include/linux/string.h
> @@ -35,6 +35,22 @@ ssize_t strscpy(char *, const char *, size_t);
>  /* Wraps calls to strscpy()/memset(), no arch specific code required */
>  ssize_t strscpy_pad(char *dest, const char *src, size_t count);
>  
> +#define stracpy(to, from)					\
> +({								\
> +	size_t size = ARRAY_SIZE(to);				\
> +	BUILD_BUG_ON(!__same_type(typeof(*to), char));		\
> +								\
> +	strscpy(to, from, size);				\
> +})
> +
> +#define stracpy_pad(to, from)					\
> +({								\
> +	size_t size = ARRAY_SIZE(to);				\
> +	BUILD_BUG_ON(!__same_type(typeof(*to), char));		\
> +								\
> +	strscpy_pad(to, from, size);				\
> +})
> +
>  #ifndef __HAVE_ARCH_STRCAT
>  extern char * strcat(char *, const char *);
>  #endif
> 
> 

      reply	other threads:[~2019-07-09 23:33 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-07-04 23:57 [PATCH 0/8] treewide: correct misuses of strscpy/strlcpy Joe Perches
2019-07-04 23:57 ` Joe Perches
2019-07-04 23:57 ` Joe Perches
2019-07-04 23:57 ` [PATCH 1/8] Input: synaptics: Fix misuse of strlcpy Joe Perches
2019-07-14 18:29   ` Dmitry Torokhov
2019-07-04 23:57 ` [PATCH 2/8] leds: as3645a: " Joe Perches
2019-07-05  7:33   ` Sakari Ailus
2019-07-05 20:23   ` Pavel Machek
2019-07-15 18:29   ` Jacek Anaszewski
2019-07-04 23:57 ` [PATCH 3/8] media: m2m-deinterlace: Fix misuse of strscpy Joe Perches
2019-07-04 23:57 ` [PATCH 4/8] media: go7007: " Joe Perches
2019-07-04 23:57 ` [PATCH 5/8] net: ethernet: sun4i-emac: Fix misuse of strlcpy Joe Perches
2019-07-04 23:57   ` Joe Perches
2019-07-08  2:22   ` David Miller
2019-07-08  2:22     ` David Miller
2019-07-04 23:57 ` [PATCH 6/8] net: nixge: " Joe Perches
2019-07-08  2:23   ` David Miller
2019-07-04 23:57 ` [PATCH 7/8] tty: hvcs: Fix odd use " Joe Perches
2019-07-04 23:57   ` Joe Perches
2019-07-04 23:57 ` [PATCH 8/8] nfsd: Fix misuse " Joe Perches
2019-07-09  3:14   ` J. Bruce Fields
2019-07-09  5:40     ` Joe Perches
2019-07-09 23:33       ` J. Bruce Fields [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=20190709233353.GA1536@fieldses.org \
    --to=bfields@fieldses.org \
    --cc=chuck.lever@oracle.com \
    --cc=joe@perches.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-nfs@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 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.