|
|
Message-ID: <12356C813DFF6F479B608F81178A561587ABA9@BGSMSX101.gar.corp.intel.com>
Date: Tue, 23 Jul 2019 09:26:23 +0000
From: "Gote, Nitin R" <nitin.r.gote@...el.com>
To: Joe Perches <joe@...ches.com>, Kees Cook <keescook@...omium.org>
CC: "corbet@....net" <corbet@....net>, "akpm@...ux-foundation.org"
<akpm@...ux-foundation.org>, "apw@...onical.com" <apw@...onical.com>,
"linux-doc@...r.kernel.org" <linux-doc@...r.kernel.org>,
"kernel-hardening@...ts.openwall.com" <kernel-hardening@...ts.openwall.com>
Subject: RE: [PATCH v5] Documentation/checkpatch: Prefer strscpy/strscpy_pad
over strcpy/strlcpy/strncpy
> -----Original Message-----
> From: Joe Perches [mailto:joe@...ches.com]
> Sent: Monday, July 22, 2019 11:11 PM
> To: Kees Cook <keescook@...omium.org>; Gote, Nitin R
> <nitin.r.gote@...el.com>
> Cc: corbet@....net; akpm@...ux-foundation.org; apw@...onical.com;
> linux-doc@...r.kernel.org; kernel-hardening@...ts.openwall.com
> Subject: Re: [PATCH v5] Documentation/checkpatch: Prefer
> strscpy/strscpy_pad over strcpy/strlcpy/strncpy
>
> On Mon, 2019-07-22 at 10:30 -0700, Kees Cook wrote:
> > On Wed, Jul 17, 2019 at 10:00:05AM +0530, NitinGote wrote:
> > > From: Nitin Gote <nitin.r.gote@...el.com>
> > >
> > > Added check in checkpatch.pl to
> > > 1. Deprecate strcpy() in favor of strscpy().
> > > 2. Deprecate strlcpy() in favor of strscpy().
> > > 3. Deprecate strncpy() in favor of strscpy() or strscpy_pad().
> > >
> > > Updated strncpy() section in Documentation/process/deprecated.rst
> > > to cover strscpy_pad() case.
> > >
> > > Signed-off-by: Nitin Gote <nitin.r.gote@...el.com>
> >
> > Reviewed-by: Kees Cook <keescook@...omium.org>
> >
> > Joe, does this address your checkpatch concerns?
>
> Well, kinda.
>
> strscpy_pad isn't used anywhere in the kernel.
>
> And
>
> + "strncpy" => "strscpy, strscpy_pad or for non-
> NUL-terminated strings, strncpy() can still be used, but destinations should
> be marked with __nonstring",
>
> is a bit verbose. This could be simply:
>
> + "strncpy" => "strscpy - for non-NUL-terminated uses, strncpy() dst
> should be __nonstring",
>
But, if the destination buffer needs extra NUL-padding for remaining size of destination,
then safe replacement is strscpy_pad(). Right? If yes, then what is your opinion on below change :
"strncpy" => "strscpy, strcpy_pad - for non-NUL-terminated uses, strncpy() dst
should be __nonstring",
> And I still prefer adding stracpy as it
> reduces code verbosity and eliminates defects.
>
-Nitin
Powered by blists - more mailing lists
Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.