linux/arch
Linus Torvalds 12e993b894 x86-32: fix up strncpy_from_user() sign error
The 'max' range needs to be unsigned, since the size of the user address
space is bigger than 2GB.

We know that 'count' is positive in 'long' (that is checked in the
caller), so we will truncate 'max' down to something that fits in a
signed long, but before we actually do that, that comparison needs to be
done in unsigned.

Bug introduced in commit 92ae03f2ef ("x86: merge 32/64-bit versions of
'strncpy_from_user()' and speed it up").  On x86-64 you can't trigger
this, since the user address space is much smaller than 63 bits, and on
x86-32 it works in practice, since you would seldom hit the strncpy
limits anyway.

I had actually tested the corner-cases, I had only tested them on
x86-64.  Besides, I had only worried about the case of a pointer *close*
to the end of the address space, rather than really far away from it ;)

This also changes the "we hit the user-specified maximum" to return
'res', for the trivial reason that gcc seems to generate better code
that way.  'res' and 'count' are the same in that case, so it really
doesn't matter which one we return.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2012-04-15 17:23:00 -07:00
..
alpha alpha: fix build failures from system.h dismemberment 2012-04-13 13:15:16 -04:00
arm Merge branch 'v3.4-samsung-fixes-2' of git://git.kernel.org/pub/scm/linux/kernel/git/kgene/linux-samsung into fixes 2012-04-14 17:50:45 -07:00
avr32 avr32: fix nop compile fails from system.h split up 2012-04-04 08:23:44 -07:00
blackfin blackfin: update defconfig for bf527-ezkit 2012-04-06 10:25:03 +08:00
c6x irq: Kill pointless irqd_to_hw export 2012-04-10 22:39:17 -06:00
cris Merge branch 'x86-x32-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip 2012-03-29 18:12:23 -07:00
frv frv: fix warnings in mb93090-mb00/pci-dma.c about implicit EXPORT_SYMBOL 2012-04-02 14:41:26 -07:00
h8300 Merge branch 'x86-x32-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip 2012-03-29 18:12:23 -07:00
hexagon Merge branch 'for-linus' of git://git.linaro.org/people/mszyprowski/linux-dma-mapping 2012-04-04 17:13:43 -07:00
ia64 ia64: populate the cmpxchg header with appropriate code 2012-04-13 13:15:16 -04:00
m32r Merge branch 'x86-x32-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip 2012-03-29 18:12:23 -07:00
m68k m68k/q40: Add missing platform check before registering platform devices 2012-04-01 22:57:53 +02:00
microblaze Merge branch 'for-linus' of git://git.linaro.org/people/mszyprowski/linux-dma-mapping 2012-04-04 17:13:43 -07:00
mips Merge branch 'for-linus' of git://git.linaro.org/people/mszyprowski/linux-dma-mapping 2012-04-04 17:13:43 -07:00
mn10300 Merge branch 'x86-x32-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip 2012-03-29 18:12:23 -07:00
openrisc Disintegrate and delete asm/system.h 2012-03-28 15:58:21 -07:00
parisc parisc: fix missing cmpxchg file error from system.h split 2012-04-02 14:41:26 -07:00
powerpc irqdomain bug fixes for v3.4-rc3 2012-04-12 12:49:56 -07:00
s390 [S390] Fix build errors (fallout from system.h disintegration) 2012-03-30 09:41:12 +02:00
score Delete all instances of asm/system.h 2012-03-28 18:30:03 +01:00
sh SuperH updates for 3.4-rc1 2012-04-07 09:52:46 -07:00
sparc sparc64: Eliminate obsolete __handle_softirq() function 2012-04-13 11:58:38 -07:00
tile arch/tile: avoid unused variable warning in proc.c for tilegx 2012-04-11 12:45:20 -04:00
um um: uml_setup_stubs': warning: unused variable 'pages' 2012-04-10 00:13:45 +02:00
unicore32 Merge branch 'for-linus' of git://git.linaro.org/people/mszyprowski/linux-dma-mapping 2012-04-04 17:13:43 -07:00
x86 x86-32: fix up strncpy_from_user() sign error 2012-04-15 17:23:00 -07:00
xtensa Merge branch 'x86-x32-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip 2012-03-29 18:12:23 -07:00
.gitignore
Kconfig Merge git://git.kernel.org/pub/scm/linux/kernel/git/cmetcalf/linux-tile 2012-03-29 14:49:45 -07:00