Re: [PATCH 1/2] string: Add stracpy and stracpy_pad mechanisms

2019-07-25 Thread Joe Perches
On Thu, 2019-07-25 at 13:03 -0700, Kees Cook wrote: > On Wed, Jul 24, 2019 at 10:08:57AM -0700, Linus Torvalds wrote: > > On Wed, Jul 24, 2019 at 6:09 AM Rasmus Villemoes > > wrote: > > > The kernel's snprintf() does not behave in a non-standard way, at least > > > not with respect to its return v

Re: [PATCH 1/2] string: Add stracpy and stracpy_pad mechanisms

2019-07-25 Thread Kees Cook
On Wed, Jul 24, 2019 at 10:08:57AM -0700, Linus Torvalds wrote: > On Wed, Jul 24, 2019 at 6:09 AM Rasmus Villemoes > wrote: > > > > The kernel's snprintf() does not behave in a non-standard way, at least > > not with respect to its return value. > > Note that the kernels snprintf() *does* very mu

Re: [PATCH 1/2] string: Add stracpy and stracpy_pad mechanisms

2019-07-25 Thread Julia Lawall
On Thu, 25 Jul 2019, Markus Elfring wrote: > > New version. I check for non-use of the return value of strlcpy and > > address some issues that affected the matching of the case where the first > > argument involves a pointer dereference. > > I suggest to take another look at corresponding impl

Re: [PATCH 1/2] string: Add stracpy and stracpy_pad mechanisms

2019-07-25 Thread Markus Elfring
> New version. I check for non-use of the return value of strlcpy and > address some issues that affected the matching of the case where the first > argument involves a pointer dereference. I suggest to take another look at corresponding implementation details of the shown SmPL script. > \(strs

Re: [PATCH 1/2] string: Add stracpy and stracpy_pad mechanisms

2019-07-24 Thread Linus Torvalds
On Wed, Jul 24, 2019 at 6:09 AM Rasmus Villemoes wrote: > > The kernel's snprintf() does not behave in a non-standard way, at least > not with respect to its return value. Note that the kernels snprintf() *does* very much protect against the overflow case - not by changing the return value, but s

Re: [PATCH 1/2] string: Add stracpy and stracpy_pad mechanisms

2019-07-24 Thread Rasmus Villemoes
On 24/07/2019 14.05, Yann Droneaud wrote: > Hi, > > Beware that snprintf(), per C standard, is supposed to return the > length of the formatted string, regarless of the size of the > destination buffer. > > So encouraging developper to write something like code below because > snprintf() in kern

Re: [PATCH 1/2] string: Add stracpy and stracpy_pad mechanisms

2019-07-24 Thread Yann Droneaud
Hi, Le mardi 23 juillet 2019 à 15:41 +, David Laight a écrit : > From: Rasmus Villemoes > > Sent: 23 July 2019 07:56 > ... > > > +/** > > > + * stracpy - Copy a C-string into an array of char > > > + * @to: Where to copy the string, must be an array of char and > > > not a pointer > > > + * @f

Re: [PATCH 1/2] string: Add stracpy and stracpy_pad mechanisms

2019-07-24 Thread Joe Perches
On Tue, 2019-07-23 at 14:36 -0700, Kees Cook wrote: > On Mon, Jul 22, 2019 at 05:38:15PM -0700, Joe Perches wrote: > > Several uses of strlcpy and strscpy have had defects because the > > last argument of each function is misused or typoed. > > > > Add macro mechanisms to avoid this defect. > > >

Re: [PATCH 1/2] string: Add stracpy and stracpy_pad mechanisms

2019-07-23 Thread Kees Cook
On Mon, Jul 22, 2019 at 05:38:15PM -0700, Joe Perches wrote: > Several uses of strlcpy and strscpy have had defects because the > last argument of each function is misused or typoed. > > Add macro mechanisms to avoid this defect. > > stracpy (copy a string to a string array) must have a string >

Re: [PATCH 1/2] string: Add stracpy and stracpy_pad mechanisms

2019-07-23 Thread Kees Cook
On Tue, Jul 23, 2019 at 03:41:27PM +, David Laight wrote: > From: Rasmus Villemoes > > Sent: 23 July 2019 07:56 > ... > > > +/** > > > + * stracpy - Copy a C-string into an array of char > > > + * @to: Where to copy the string, must be an array of char and not a > > > pointer > > > + * @from:

Re: [PATCH 1/2] string: Add stracpy and stracpy_pad mechanisms

2019-07-23 Thread Kees Cook
On Mon, Jul 22, 2019 at 09:42:51PM -0700, Joe Perches wrote: > On Mon, 2019-07-22 at 21:35 -0700, Andrew Morton wrote: > > On Mon, 22 Jul 2019 17:38:15 -0700 Joe Perches wrote: > > > > > Several uses of strlcpy and strscpy have had defects because the > > > last argument of each function is misus

Re: [PATCH 1/2] string: Add stracpy and stracpy_pad mechanisms

2019-07-23 Thread Joe Perches
(adding Chris Metcalf) On Tue, 2019-07-23 at 15:41 +, David Laight wrote: > From: Rasmus Villemoes > > Sent: 23 July 2019 07:56 > ... > > > +/** > > > + * stracpy - Copy a C-string into an array of char > > > + * @to: Where to copy the string, must be an array of char and not a > > > pointer

RE: [PATCH 1/2] string: Add stracpy and stracpy_pad mechanisms

2019-07-23 Thread David Laight
From: Rasmus Villemoes > Sent: 23 July 2019 07:56 ... > > +/** > > + * stracpy - Copy a C-string into an array of char > > + * @to: Where to copy the string, must be an array of char and not a > > pointer > > + * @from: String to copy, may be a pointer or const char array > > + * > > + * Helper fo

Re: [PATCH 1/2] string: Add stracpy and stracpy_pad mechanisms

2019-07-22 Thread Rasmus Villemoes
On 23/07/2019 02.38, Joe Perches wrote: > Several uses of strlcpy and strscpy have had defects because the > last argument of each function is misused or typoed. > > Add macro mechanisms to avoid this defect. > > stracpy (copy a string to a string array) must have a string > array as the first ar

Re: [PATCH 1/2] string: Add stracpy and stracpy_pad mechanisms

2019-07-22 Thread Joe Perches
On Mon, 2019-07-22 at 21:35 -0700, Andrew Morton wrote: > On Mon, 22 Jul 2019 17:38:15 -0700 Joe Perches wrote: > > > Several uses of strlcpy and strscpy have had defects because the > > last argument of each function is misused or typoed. > > > > Add macro mechanisms to avoid this defect. > >

Re: [PATCH 1/2] string: Add stracpy and stracpy_pad mechanisms

2019-07-22 Thread Andrew Morton
On Mon, 22 Jul 2019 17:38:15 -0700 Joe Perches wrote: > Several uses of strlcpy and strscpy have had defects because the > last argument of each function is misused or typoed. > > Add macro mechanisms to avoid this defect. > > stracpy (copy a string to a string array) must have a string > array