Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp8469310ybi; Tue, 9 Jul 2019 16:37:27 -0700 (PDT) X-Google-Smtp-Source: APXvYqycIdin0nJgPDy26/9hkoLbyP3igJF0khJWCkVrf2WvzYhSx47rjyZNi9mtGoXNcLI+t8UJ X-Received: by 2002:a63:2148:: with SMTP id s8mr32724685pgm.336.1562715447050; Tue, 09 Jul 2019 16:37:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1562715447; cv=none; d=google.com; s=arc-20160816; b=rq3RTWv5MTDuG6YfR1UYJeNeUmZqitnZH8XHmNEw6WgnwrDXcNeAd4ylPtBSgUHy/b T1K/Oz5uaLr8nSiQ4XMlbg/o1/fpyvFYCML6LbxUYOUoH6kqb1qa6GMcelHCi0fGcSoe qiBqw358hb1oo5Iw56js1Fv5e2roANElmTy4ggNNTxY1uAHIP5k+q6BdGrmwxsc2xN5n PP/fmlzGWYLK7sR4dYaCc7GSJcflKi+6Ji01Ku2FeE1yTzRUmVjrgikIkWXGD5rTly9j 4xlRUctqAuv2+waEC9P62vtdcJR7l/B22jyEa+AB1T98qHRfb9Ry7K85NmxGAsTY9NOR g/+g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=w9ixuZyOgVcR4GFUhPWOuXve9QwwzEZ9wHmSxuSMhLs=; b=mku2uzMgPRPbMCoIVHapabkkqDVRlsn3CqeDb/0LYLmt8y1dnh/rnOvNkAtUN2AzEy kWNLSF7nJiP6omcVVFdPB6dt2FsFoM5AS+8q8F58qDmg32ostpg2k7FNZzV+EEhR/3xR 4nHAVoEb+J5d/BynG5/R7+woM6NezFhtBnujdt8OLay/5pjKE2huBRSWf9pQsvyTBMig taNKUxG844FbpraPpEnzT5gEIzcXoTUDaIC8B5OW4SpWi6xYtCdHK8ol8EIrlmte4qRb B+jkvWFCs9/mIiPwszQkf6mmVsS7m5vgX76IrxD22hkK3QDLtEVtMGnVwGxFFyauyQAY LWUw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-nfs-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a17si352465pff.195.2019.07.09.16.36.59; Tue, 09 Jul 2019 16:37:27 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-nfs-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-nfs-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726957AbfGIXdy (ORCPT + 99 others); Tue, 9 Jul 2019 19:33:54 -0400 Received: from fieldses.org ([173.255.197.46]:52792 "EHLO fieldses.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726951AbfGIXdy (ORCPT ); Tue, 9 Jul 2019 19:33:54 -0400 Received: by fieldses.org (Postfix, from userid 2815) id A988D1C9D; Tue, 9 Jul 2019 19:33:53 -0400 (EDT) Date: Tue, 9 Jul 2019 19:33:53 -0400 From: "J. Bruce Fields" To: Joe Perches Cc: Chuck Lever , linux-nfs@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH 8/8] nfsd: Fix misuse of strlcpy Message-ID: <20190709233353.GA1536@fieldses.org> References: <20190709031404.GD14439@fieldses.org> <9a5dedb0c9221743033f28974820e8dd724e388d.camel@perches.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <9a5dedb0c9221743033f28974820e8dd724e388d.camel@perches.com> User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-nfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org 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 > >