linux/arch/um/include/asm
Linus Torvalds 30c44659f4 Merge branch 'strscpy' of git://git.kernel.org/pub/scm/linux/kernel/git/cmetcalf/linux-tile
Pull strscpy string copy function implementation from Chris Metcalf.

Chris sent this during the merge window, but I waffled back and forth on
the pull request, which is why it's going in only now.

The new "strscpy()" function is definitely easier to use and more secure
than either strncpy() or strlcpy(), both of which are horrible nasty
interfaces that have serious and irredeemable problems.

strncpy() has a useless return value, and doesn't NUL-terminate an
overlong result.  To make matters worse, it pads a short result with
zeroes, which is a performance disaster if you have big buffers.

strlcpy(), by contrast, is a mis-designed "fix" for strlcpy(), lacking
the insane NUL padding, but having a differently broken return value
which returns the original length of the source string.  Which means
that it will read characters past the count from the source buffer, and
you have to trust the source to be properly terminated.  It also makes
error handling fragile, since the test for overflow is unnecessarily
subtle.

strscpy() avoids both these problems, guaranteeing the NUL termination
(but not excessive padding) if the destination size wasn't zero, and
making the overflow condition very obvious by returning -E2BIG.  It also
doesn't read past the size of the source, and can thus be used for
untrusted source data too.

So why did I waffle about this for so long?

Every time we introduce a new-and-improved interface, people start doing
these interminable series of trivial conversion patches.

And every time that happens, somebody does some silly mistake, and the
conversion patch to the improved interface actually makes things worse.
Because the patch is mindnumbing and trivial, nobody has the attention
span to look at it carefully, and it's usually done over large swatches
of source code which means that not every conversion gets tested.

So I'm pulling the strscpy() support because it *is* a better interface.
But I will refuse to pull mindless conversion patches.  Use this in
places where it makes sense, but don't do trivial patches to fix things
that aren't actually known to be broken.

* 'strscpy' of git://git.kernel.org/pub/scm/linux/kernel/git/cmetcalf/linux-tile:
  tile: use global strscpy() rather than private copy
  string: provide strscpy()
  Make asm/word-at-a-time.h available on all architectures
2015-10-04 16:31:13 +01:00
..
a.out-core.h
bugs.h
cache.h
common.lds.S UML: normalize global variables exported by vmlinux.lds 2013-07-03 16:07:34 -07:00
dma.h um: get rid of pointless include "..." where include <...> will do 2012-10-09 22:28:45 +02:00
fixmap.h um: Remove broken highmem support 2015-04-13 21:01:02 +02:00
irq.h
irqflags.h um: kill system-um.h 2011-11-02 14:15:34 +01:00
Kbuild Merge branch 'strscpy' of git://git.kernel.org/pub/scm/linux/kernel/git/cmetcalf/linux-tile 2015-10-04 16:31:13 +01:00
kmap_types.h um: remove km_type definitions 2012-07-24 15:27:31 +08:00
kvm_para.h kvmclock: Add functions to check if the host has stopped the vm 2012-04-08 12:48:59 +03:00
mmu_context.h mm: Make arch_unmap()/bprm_mm_init() available to all architectures 2014-11-19 11:54:13 +01:00
mmu.h um: get rid of pointless include "..." where include <...> will do 2012-10-09 22:28:45 +02:00
page.h arm64,ia64,ppc,s390,sh,tile,um,x86,mm: remove default gate area 2014-08-08 15:57:27 -07:00
pgalloc.h um: remove pointless include of asm/fixmap.h from asm/pgtable.h 2012-03-25 00:29:55 +01:00
pgtable-2level.h mm: make FIRST_USER_ADDRESS unsigned long on all archs 2015-02-11 17:06:03 -08:00
pgtable-3level.h mm: make FIRST_USER_ADDRESS unsigned long on all archs 2015-02-11 17:06:03 -08:00
pgtable.h um: Remove broken highmem support 2015-04-13 21:01:02 +02:00
processor-generic.h um: Remove broken SMP support 2015-04-13 21:00:58 +02:00
ptrace-generic.h um: Don't pollute kernel namespace with uapi 2015-06-25 22:44:11 +02:00
sections.h um: Use char[] for linker script address declarations 2015-05-31 13:14:06 +02:00
setup.h
smp.h um: Remove broken SMP support 2015-04-13 21:00:58 +02:00
stacktrace.h um: Add support for CONFIG_STACKTRACE 2014-10-13 21:46:25 +02:00
sysrq.h um: move sysrq.h out of include/shared 2012-10-09 22:28:19 +02:00
thread_info.h um: Rework uaccess code 2015-05-31 17:32:36 +02:00
timex.h
tlb.h mm: split 'tlb_flush_mmu()' into tlb flushing and memory freeing parts 2014-04-25 16:05:40 -07:00
tlbflush.h
uaccess.h um: Rework uaccess code 2015-05-31 17:32:36 +02:00