linux-sg2042/arch/sparc/lib
Rob Gardner a7c5724b5c sparc64: fix FP corruption in user copy functions
Short story: Exception handlers used by some copy_to_user() and
copy_from_user() functions do not diligently clean up floating point
register usage, and this can result in a user process seeing invalid
values in floating point registers. This sometimes makes the process
fail.

Long story: Several cpu-specific (NG4, NG2, U1, U3) memcpy functions
use floating point registers and VIS alignaddr/faligndata to
accelerate data copying when source and dest addresses don't align
well. Linux uses a lazy scheme for saving floating point registers; It
is not done upon entering the kernel since it's a very expensive
operation. Rather, it is done only when needed. If the kernel ends up
not using FP regs during the course of some trap or system call, then
it can return to user space without saving or restoring them.

The various memcpy functions begin their FP code with VISEntry (or a
variation thereof), which saves the FP regs. They conclude their FP
code with VISExit (or a variation) which essentially marks the FP regs
"clean", ie, they contain no unsaved values. fprs.FPRS_FEF is turned
off so that a lazy restore will be triggered when/if the user process
accesses floating point regs again.

The bug is that the user copy variants of memcpy, copy_from_user() and
copy_to_user(), employ an exception handling mechanism to detect faults
when accessing user space addresses, and when this handler is invoked,
an immediate return from the function is forced, and VISExit is not
executed, thus leaving the fprs register in an indeterminate state,
but often with fprs.FPRS_FEF set and one or more dirty bits. This
results in a return to user space with invalid values in the FP regs,
and since fprs.FPRS_FEF is on, no lazy restore occurs.

This bug affects copy_to_user() and copy_from_user() for NG4, NG2,
U3, and U1. All are fixed by using a new exception handler for those
loads and stores that are done during the time between VISEnter and
VISExit.

n.b. In NG4memcpy, the problematic code can be triggered by a copy
size greater than 128 bytes and an unaligned source address.  This bug
is known to be the cause of random user process memory corruptions
while perf is running with the callgraph option (ie, perf record -g).
This occurs because perf uses copy_from_user() to read user stacks,
and may fault when it follows a stack frame pointer off to an
invalid page. Validation checks on the stack address just obscure
the underlying problem.

Signed-off-by: Rob Gardner <rob.gardner@oracle.com>
Signed-off-by: Dave Aldridge <david.j.aldridge@oracle.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2015-12-24 12:13:18 -05:00
..
COPYING.LIB
GENbzero.S sparc64: Kill .fixup section bloat. 2009-02-08 22:00:55 -08:00
GENcopy_from_user.S sparc64: Fix probe_kernel_{read,write}(). 2009-02-08 22:32:31 -08:00
GENcopy_to_user.S sparc64: Fix probe_kernel_{read,write}(). 2009-02-08 22:32:31 -08:00
GENmemcpy.S sparc,sparc64: unify lib/ 2008-12-04 09:17:19 -08:00
GENpage.S sparc,sparc64: unify lib/ 2008-12-04 09:17:19 -08:00
GENpatch.S sparc,sparc64: unify lib/ 2008-12-04 09:17:19 -08:00
Makefile sparc32: introduce asm-generic/io.h 2014-05-02 01:30:21 -04:00
NG2copy_from_user.S sparc64: fix FP corruption in user copy functions 2015-12-24 12:13:18 -05:00
NG2copy_to_user.S sparc64: fix FP corruption in user copy functions 2015-12-24 12:13:18 -05:00
NG2memcpy.S sparc64: fix FP corruption in user copy functions 2015-12-24 12:13:18 -05:00
NG2patch.S sparc,sparc64: unify lib/ 2008-12-04 09:17:19 -08:00
NG4clear_page.S sparc64: Niagara-4 bzero/memset, plus use MRU stores in page copy. 2012-10-05 13:45:26 -07:00
NG4copy_from_user.S sparc64: fix FP corruption in user copy functions 2015-12-24 12:13:18 -05:00
NG4copy_page.S sparc64: Niagara-4 bzero/memset, plus use MRU stores in page copy. 2012-10-05 13:45:26 -07:00
NG4copy_to_user.S sparc64: fix FP corruption in user copy functions 2015-12-24 12:13:18 -05:00
NG4memcpy.S sparc64: fix FP corruption in user copy functions 2015-12-24 12:13:18 -05:00
NG4memset.S sparc64: Niagara-4 bzero/memset, plus use MRU stores in page copy. 2012-10-05 13:45:26 -07:00
NG4patch.S sparc64: Niagara-4 bzero/memset, plus use MRU stores in page copy. 2012-10-05 13:45:26 -07:00
NGbzero.S sparc64: Kill .fixup section bloat. 2009-02-08 22:00:55 -08:00
NGcopy_from_user.S sparc64: Fix probe_kernel_{read,write}(). 2009-02-08 22:32:31 -08:00
NGcopy_to_user.S sparc64: Fix probe_kernel_{read,write}(). 2009-02-08 22:32:31 -08:00
NGmemcpy.S sparc,sparc64: unify lib/ 2008-12-04 09:17:19 -08:00
NGpage.S sparc64: Add SPARC-T4 optimized memcpy. 2012-09-27 00:35:11 -07:00
NGpatch.S sparc,sparc64: unify lib/ 2008-12-04 09:17:19 -08:00
PeeCeeI.c sparc64: update IO access functions in PeeCeeI 2014-07-21 21:43:18 -07:00
U1copy_from_user.S sparc64: fix FP corruption in user copy functions 2015-12-24 12:13:18 -05:00
U1copy_to_user.S sparc64: fix FP corruption in user copy functions 2015-12-24 12:13:18 -05:00
U1memcpy.S sparc64: fix FP corruption in user copy functions 2015-12-24 12:13:18 -05:00
U3copy_from_user.S sparc64: fix FP corruption in user copy functions 2015-12-24 12:13:18 -05:00
U3copy_to_user.S sparc64: fix FP corruption in user copy functions 2015-12-24 12:13:18 -05:00
U3memcpy.S sparc64: fix FP corruption in user copy functions 2015-12-24 12:13:18 -05:00
U3patch.S sparc,sparc64: unify lib/ 2008-12-04 09:17:19 -08:00
VISsave.S sparc64: use ENTRY/ENDPROC in VISsave 2015-08-07 15:22:40 -07:00
ashldi3.S sparc: Convert some assembler over to linakge.h's ENTRY/ENDPROC 2012-05-11 20:33:22 -07:00
ashrdi3.S sparc: Convert some assembler over to linakge.h's ENTRY/ENDPROC 2012-05-11 20:33:22 -07:00
atomic32.c sparc: Provide atomic_{or,xor,and} 2015-07-27 14:06:23 +02:00
atomic_64.S sparc: Provide atomic_{or,xor,and} 2015-07-27 14:06:23 +02:00
bitext.c sparc/srmmu: clear trailing edge of bitmap properly 2013-03-31 19:29:12 -04:00
bitops.S sparc: Convert some assembler over to linakge.h's ENTRY/ENDPROC 2012-05-11 20:33:22 -07:00
blockops.S sparc: Convert some assembler over to linakge.h's ENTRY/ENDPROC 2012-05-11 20:33:22 -07:00
bzero.S sparc: Convert some assembler over to linakge.h's ENTRY/ENDPROC 2012-05-11 20:33:22 -07:00
checksum_32.S sparc32: Fixed unaligned memory copying in function __csum_partial_copy_sparc_generic 2011-05-11 21:35:04 -07:00
checksum_64.S sparc,sparc64: unify lib/ 2008-12-04 09:17:19 -08:00
clear_page.S sparc64: Make PAGE_OFFSET variable. 2013-11-12 15:22:34 -08:00
cmpdi2.c
copy_in_user.S sparc64: Fix probe_kernel_{read,write}(). 2009-02-08 22:32:31 -08:00
copy_page.S sparc64: Make PAGE_OFFSET variable. 2013-11-12 15:22:34 -08:00
copy_user.S
csum_copy.S sparc,sparc64: unify lib/ 2008-12-04 09:17:19 -08:00
csum_copy_from_user.S sparc64: Fix section attribute warnings. 2009-05-29 16:12:02 -07:00
csum_copy_to_user.S sparc64: Fix section attribute warnings. 2009-05-29 16:12:02 -07:00
divdi3.S sparc32: Kill off software 32-bit multiply/divide routines. 2012-05-15 11:23:47 -07:00
ffs.S sparc: Use popc when possible for ffs/__ffs/ffz. 2011-08-02 21:28:53 -07:00
hweight.S sparc: Use popc if possible for hweight routines. 2011-08-02 21:28:50 -07:00
iomap.c sparc: switch to GENERIC_PCI_IOMAP 2011-12-04 15:59:49 +02:00
ipcsum.S sparc: Convert some assembler over to linakge.h's ENTRY/ENDPROC 2012-05-11 20:33:22 -07:00
ksyms.c Merge branch 'locking-core-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip 2015-09-03 15:46:07 -07:00
libgcc.h
locks.S sparc: remove CVS keywords 2008-05-20 00:33:44 -07:00
lshrdi3.S sparc: Convert some assembler over to linakge.h's ENTRY/ENDPROC 2012-05-11 20:33:22 -07:00
mcount.S sparc64,ftrace: Remove check of obsolete variable function_trace_stop 2014-07-18 13:57:03 -04:00
memcmp.S sparc: Commonize memcmp assembler. 2008-12-09 04:09:07 -08:00
memcpy.S sparc32: Correct the return value of memcpy. 2011-10-20 15:17:23 -07:00
memmove.S sparc64: Fix several bugs in memmove(). 2015-03-23 09:22:10 -07:00
memscan_32.S sparc: prepare lib/ for unification 2008-12-04 09:17:18 -08:00
memscan_64.S sparc,sparc64: unify lib/ 2008-12-04 09:17:19 -08:00
memset.S sparc: Let memset return the address argument 2014-09-09 16:38:10 -07:00
muldi3.S sparc32: Kill off software 32-bit multiply/divide routines. 2012-05-15 11:23:47 -07:00
strlen.S sparc: Unify strlen assembler. 2008-12-09 01:07:09 -08:00
strncmp_32.S sparc: Convert some assembler over to linakge.h's ENTRY/ENDPROC 2012-05-11 20:33:22 -07:00
strncmp_64.S sparc: Convert some assembler over to linakge.h's ENTRY/ENDPROC 2012-05-11 20:33:22 -07:00
ucmpdi2.c sparc32: add ucmpdi2 2012-05-19 15:23:57 -07:00
udivdi3.S sparc32: Kill off software 32-bit multiply/divide routines. 2012-05-15 11:23:47 -07:00
user_fixup.c sparc64: move EXPORT_SYMBOL to the symbols definition 2009-01-08 16:58:20 -08:00
xor.S sparc: Convert some assembler over to linakge.h's ENTRY/ENDPROC 2012-05-11 20:33:22 -07:00