linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [GIT PULL] strscpy string copy function
@ 2015-06-30 18:01 Chris Metcalf
  2015-07-01 16:11 ` Linus Torvalds
  0 siblings, 1 reply; 37+ messages in thread
From: Chris Metcalf @ 2015-06-30 18:01 UTC (permalink / raw)
  To: Linus Torvalds, open list

Linus,

Please pull the following changes for 4.2 from:

   git://git.kernel.org/pub/scm/linux/kernel/git/cmetcalf/linux-tile.git strscpy

The discussion on this died down on LKML [1], so either (a) everybody loved it and
it was obviously correct, or (b) everybody lost interest.  I'm optimistically
assuming (a), but willing to hear otherwise!

[1] https://lwn.net/Articles/643140/

Chris Metcalf (3):
       Make asm/word-at-a-time.h available on all architectures
       string: provide strscpy() and strscpy_truncate()
       tile: use global strscpy() rather than private copy

  arch/arc/include/asm/Kbuild          |   1 +
  arch/avr32/include/asm/Kbuild        |   1 +
  arch/blackfin/include/asm/Kbuild     |   1 +
  arch/c6x/include/asm/Kbuild          |   1 +
  arch/cris/include/asm/Kbuild         |   1 +
  arch/frv/include/asm/Kbuild          |   1 +
  arch/hexagon/include/asm/Kbuild      |   1 +
  arch/ia64/include/asm/Kbuild         |   1 +
  arch/m32r/include/asm/Kbuild         |   1 +
  arch/metag/include/asm/Kbuild        |   1 +
  arch/microblaze/include/asm/Kbuild   |   1 +
  arch/mips/include/asm/Kbuild         |   1 +
  arch/mn10300/include/asm/Kbuild      |   1 +
  arch/nios2/include/asm/Kbuild        |   1 +
  arch/powerpc/include/asm/Kbuild      |   1 +
  arch/s390/include/asm/Kbuild         |   1 +
  arch/score/include/asm/Kbuild        |   1 +
  arch/tile/gxio/mpipe.c               |  33 ++---------
  arch/tile/include/asm/Kbuild         |   1 +
  arch/um/include/asm/Kbuild           |   1 +
  arch/unicore32/include/asm/Kbuild    |   1 +
  arch/xtensa/include/asm/Kbuild       |   1 +
  include/asm-generic/word-at-a-time.h |  80 ++++++++++++++++++++++---
  include/linux/string.h               |   6 ++
  lib/string.c                         | 110 +++++++++++++++++++++++++++++++++++
  25 files changed, 213 insertions(+), 37 deletions(-)

-- 
Chris Metcalf, EZChip Semiconductor
http://www.ezchip.com


^ permalink raw reply	[flat|nested] 37+ messages in thread
* [GIT PULL] strscpy string copy function
@ 2015-09-10 19:43 Chris Metcalf
  2015-10-04 15:55 ` Linus Torvalds
  0 siblings, 1 reply; 37+ messages in thread
From: Chris Metcalf @ 2015-09-10 19:43 UTC (permalink / raw)
  To: Linus Torvalds, open list

Linus,

Please pull the following changes for 4.3 from:

   git://git.kernel.org/pub/scm/linux/kernel/git/cmetcalf/linux-tile.git strscpy

Your comment for 4.2 was to get rid of the "make it zero-sized" default thing,
which I did in the v2 patch in July.  I did get a bit of feedback around the
language of the kerneldoc comment, which I updated, and the result is ready
to be pulled, if it seems like the right thing to you now!

Chris Metcalf (3):
       Make asm/word-at-a-time.h available on all architectures
       string: provide strscpy()
       tile: use global strscpy() rather than private copy

  arch/arc/include/asm/Kbuild          |  1 +
  arch/avr32/include/asm/Kbuild        |  1 +
  arch/blackfin/include/asm/Kbuild     |  1 +
  arch/c6x/include/asm/Kbuild          |  1 +
  arch/cris/include/asm/Kbuild         |  1 +
  arch/frv/include/asm/Kbuild          |  1 +
  arch/hexagon/include/asm/Kbuild      |  1 +
  arch/ia64/include/asm/Kbuild         |  1 +
  arch/m32r/include/asm/Kbuild         |  1 +
  arch/metag/include/asm/Kbuild        |  1 +
  arch/microblaze/include/asm/Kbuild   |  1 +
  arch/mips/include/asm/Kbuild         |  1 +
  arch/mn10300/include/asm/Kbuild      |  1 +
  arch/nios2/include/asm/Kbuild        |  1 +
  arch/powerpc/include/asm/Kbuild      |  1 +
  arch/s390/include/asm/Kbuild         |  1 +
  arch/score/include/asm/Kbuild        |  1 +
  arch/tile/gxio/mpipe.c               | 33 ++------------
  arch/tile/include/asm/Kbuild         |  1 +
  arch/um/include/asm/Kbuild           |  1 +
  arch/unicore32/include/asm/Kbuild    |  1 +
  arch/xtensa/include/asm/Kbuild       |  1 +
  include/asm-generic/word-at-a-time.h | 80 ++++++++++++++++++++++++++++----
  include/linux/string.h               |  3 ++
  lib/string.c                         | 88 ++++++++++++++++++++++++++++++++++++
  25 files changed, 188 insertions(+), 37 deletions(-)

-- 
Chris Metcalf, EZChip Semiconductor
http://www.ezchip.com


^ permalink raw reply	[flat|nested] 37+ messages in thread
* revert "fs/befs/linuxvfs.c: replace strncpy by strlcpy"
@ 2015-04-28  3:48 Al Viro
  2015-04-28  5:35 ` Fabian Frederick
  0 siblings, 1 reply; 37+ messages in thread
From: Al Viro @ 2015-04-28  3:48 UTC (permalink / raw)
  To: Linus Torvalds; +Cc: Fabian Frederick, linux-kernel

commit 39d7a29f867bd5a4a551fad6bb3812ceddb0bce1
Author: Fabian Frederick <fabf@skynet.be>
Date:   Fri Jun 6 14:36:15 2014 -0700

    fs/befs/linuxvfs.c: replace strncpy by strlcpy
    
    strncpy + end of string assignment replaced by strlcpy

replaces perfectly safe code with undefined behaviour.  All in the name
of "security hardening", presumably.  Folks, seeing the words "designed to be
safer, more consistent, and less error prone replacement" in a manpage does
*NOT* mean "OK, quit reading it - no need to go further, not even to the end
of the paragraph".  Because in the end of that paragraph it says "This means
that for strlcpy() src must be NUL-terminated".  And sure enough, our
implementation relies on that - it starts with strlen().

strncpy() is guaranteed not to look further than size.  strlcpy() is *NOT*.
strncpy() on unvalidated source is safe, provided that you sanitize the copy;
strlcpy() on anything like that is an invitation for nasal daemons.

Sure, we can (and probably should) make strlcpy(dst, src, n) never access
memory beyond src + n - 1, but this kind of cargo-culting is a Bad Thing(tm);
mindless "security improvements" without so much as bothering to RTFM are
asking for trouble.  And in userland code anything like that _can't_ be
papered over afterwards - not unless you can patch every libc implementation
out there.

This particular code is completely pointless - if anything, it should've been
memcpy() + nd_terminate_link()...

Al, very unhappy about the prospect of looking through ~2000 calls of strlcpy()
we have in the tree...

^ permalink raw reply	[flat|nested] 37+ messages in thread

end of thread, other threads:[~2015-10-04 15:55 UTC | newest]

Thread overview: 37+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-06-30 18:01 [GIT PULL] strscpy string copy function Chris Metcalf
2015-07-01 16:11 ` Linus Torvalds
2015-07-08 20:20   ` [PATCH v2 0/3] add new strscpy() API for string copy Chris Metcalf
2015-07-08 20:20     ` [PATCH v2 1/3] Make asm/word-at-a-time.h available on all architectures Chris Metcalf
2015-07-08 20:20     ` [PATCH v2 2/3] string: provide strscpy() Chris Metcalf
2015-07-08 20:54       ` Geert Uytterhoeven
2015-07-08 20:20     ` [PATCH v2 3/3] tile: use global strscpy() rather than private copy Chris Metcalf
  -- strict thread matches above, loose matches on Subject: below --
2015-09-10 19:43 [GIT PULL] strscpy string copy function Chris Metcalf
2015-10-04 15:55 ` Linus Torvalds
2015-04-28  3:48 revert "fs/befs/linuxvfs.c: replace strncpy by strlcpy" Al Viro
2015-04-28  5:35 ` Fabian Frederick
2015-04-28 16:05   ` Al Viro
2015-04-28 16:42     ` Fabian Frederick
2015-04-28 17:39       ` Al Viro
2015-04-28 20:16         ` Fabian Frederick
2015-04-28 16:42     ` Linus Torvalds
2015-04-28 19:48       ` Chris Metcalf
2015-04-28 20:51         ` Linus Torvalds
2015-04-28 21:38           ` Chris Metcalf
2015-04-28 21:48             ` Linus Torvalds
2015-04-29  0:35               ` Al Viro
2015-04-29  8:24                 ` Geert Uytterhoeven
2015-04-30 16:01               ` [PATCH 0/3] add new strscpy() API for string copy Chris Metcalf
2015-04-30 16:01                 ` [PATCH 1/3] Make asm/word-at-a-time.h available on all architectures Chris Metcalf
2015-04-30 16:01                 ` [PATCH 2/3] string: provide strscpy() and strscpy_truncate() Chris Metcalf
2015-05-06 15:01                   ` Dan Carpenter
2015-05-06 15:21                     ` Chris Metcalf
2015-05-06 15:59                       ` Dan Carpenter
2015-05-06 16:45                         ` Geert Uytterhoeven
2015-05-07  9:00                           ` Dan Carpenter
2015-05-07 15:10                             ` Chris Metcalf
2015-04-30 16:01                 ` [PATCH 3/3] tile: use global strscpy() rather than private copy Chris Metcalf
2015-05-11 15:37                 ` [PATCH 0/3] add new strscpy() API for string copy Chris Metcalf
2015-05-14 23:10                 ` Michael Ellerman
2015-05-15 15:15                   ` Chris Metcalf
2015-05-18  1:13                     ` Michael Ellerman
2015-05-26 19:33                       ` Chris Metcalf

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).