android_kernel_lge_bullhead/arch/mips/cavium-octeon
James Cowgill e51712a87d MIPS: OCTEON: Fix copy_from_user fault handling for large buffers
commit 884b426917e4b3c85f33b382c792a94305dfdd62 upstream.

If copy_from_user is called with a large buffer (>= 128 bytes) and the
userspace buffer refers partially to unreadable memory, then it is
possible for Octeon's copy_from_user to report the wrong number of bytes
have been copied. In the case where the buffer size is an exact multiple
of 128 and the fault occurs in the last 64 bytes, copy_from_user will
report that all the bytes were copied successfully but leave some
garbage in the destination buffer.

The bug is in the main __copy_user_common loop in octeon-memcpy.S where
in the middle of the loop, src and dst are incremented by 128 bytes. The
l_exc_copy fault handler is used after this but that assumes that
"src < THREAD_BUADDR($28)". This is not the case if src has already been
incremented.

Fix by adding an extra fault handler which rewinds the src and dst
pointers 128 bytes before falling though to l_exc_copy.

Thanks to the pwritev test from the strace test suite for originally
highlighting this bug!

Fixes: 5b3b16880f ("MIPS: Add Cavium OCTEON processor support ...")
Signed-off-by: James Cowgill <James.Cowgill@imgtec.com>
Acked-by: David Daney <david.daney@cavium.com>
Reviewed-by: James Hogan <james.hogan@imgtec.com>
Cc: Ralf Baechle <ralf@linux-mips.org>
Cc: linux-mips@linux-mips.org
Patchwork: https://patchwork.linux-mips.org/patch/14978/
Signed-off-by: James Hogan <james.hogan@imgtec.com>
Signed-off-by: Willy Tarreau <w@1wt.eu>
2017-06-08 00:47:00 +02:00
..
executive Merge branch 'upstream' of git://git.linux-mips.org/pub/scm/ralf/upstream-linus 2013-03-02 07:44:16 -08:00
.gitignore MIPS: Octeon: Add device tree source files. 2012-07-23 13:54:52 +01:00
Kconfig MIPS: Octeon: Adding driver to measure interrupt latency on Octeon. 2013-02-15 23:07:37 +01:00
Makefile MIPS: Octeon: Adding driver to measure interrupt latency on Octeon. 2013-02-15 23:07:37 +01:00
Platform MIPS: Octeon: Migrate to new platform makefile style. 2010-08-05 13:25:54 +01:00
cpu.c MIPS: Octeon: Place cnmips_cu2_setup in __init memory. 2010-10-04 18:34:00 +01:00
csrc-octeon.c MIPS: Octeon: Add octeon_io_clk_delay() function. 2012-08-31 11:48:48 -07:00
dma-octeon.c x86: Don't panic if can not alloc buffer for swiotlb 2013-01-29 19:36:53 -08:00
flash_setup.c mips/octeon: 16-Bit NOR flash was not being detected during boot 2012-11-09 11:37:16 +01:00
oct_ilm.c MIPS: Octeon: Adding driver to measure interrupt latency on Octeon. 2013-02-15 23:07:37 +01:00
octeon-irq.c genirq: Allow forcing cpu affinity of interrupts 2014-06-07 13:25:29 -07:00
octeon-memcpy.S MIPS: OCTEON: Fix copy_from_user fault handling for large buffers 2017-06-08 00:47:00 +02:00
octeon-platform.c MIPS: Whitespace cleanup. 2013-02-01 10:00:22 +01:00
octeon_3xxx.dts MIPS: Whitespace cleanup. 2013-02-01 10:00:22 +01:00
octeon_68xx.dts MIPS: Whitespace cleanup. 2013-02-01 10:00:22 +01:00
octeon_boot.h MIPS: Whitespace cleanup. 2013-02-01 10:00:22 +01:00
serial.c MIPS: drivers: remove __dev* attributes. 2013-01-03 15:57:09 -08:00
setup.c MIPS: OCTEON: make get_system_type() thread-safe 2014-09-17 09:03:58 -07:00
smp.c MIPS: Whitespace cleanup. 2013-02-01 10:00:22 +01:00