android_kernel_xiaomi_sm7250/arch/mips/math-emu
Paul Burton 62452b3511 MIPS: math-emu: Write-protect delay slot emulation pages
commit adcc81f148d733b7e8e641300c5590a2cdc13bf3 upstream.

Mapping the delay slot emulation page as both writeable & executable
presents a security risk, in that if an exploit can write to & jump into
the page then it can be used as an easy way to execute arbitrary code.

Prevent this by mapping the page read-only for userland, and using
access_process_vm() with the FOLL_FORCE flag to write to it from
mips_dsemul().

This will likely be less efficient due to copy_to_user_page() performing
cache maintenance on a whole page, rather than a single line as in the
previous use of flush_cache_sigtramp(). However this delay slot
emulation code ought not to be running in any performance critical paths
anyway so this isn't really a problem, and we can probably do better in
copy_to_user_page() anyway in future.

A major advantage of this approach is that the fix is small & simple to
backport to stable kernels.

Reported-by: Andy Lutomirski <luto@kernel.org>
Signed-off-by: Paul Burton <paul.burton@mips.com>
Fixes: 432c6bacbd ("MIPS: Use per-mm page to execute branch delay slot instructions")
Cc: stable@vger.kernel.org # v4.8+
Cc: linux-mips@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
Cc: Rich Felker <dalias@libc.org>
Cc: David Daney <david.daney@cavium.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2019-01-09 17:38:47 +01:00
..
cp1emu.c MIPS: math-emu: Mark fall throughs in switch statements with a comment 2017-12-12 17:20:20 +01:00
dp_2008class.c
dp_add.c MIPS: math-emu: Mark fall throughs in switch statements with a comment 2017-12-12 17:20:20 +01:00
dp_cmp.c
dp_div.c MIPS: math-emu: Mark fall throughs in switch statements with a comment 2017-12-12 17:20:20 +01:00
dp_fint.c
dp_flong.c
dp_fmax.c MIPS: math-emu: Mark fall throughs in switch statements with a comment 2017-12-12 17:20:20 +01:00
dp_fmin.c MIPS: math-emu: Mark fall throughs in switch statements with a comment 2017-12-12 17:20:20 +01:00
dp_fsp.c
dp_maddf.c MIPS: math-emu: Mark fall throughs in switch statements with a comment 2017-12-12 17:20:20 +01:00
dp_mul.c MIPS: math-emu: Mark fall throughs in switch statements with a comment 2017-12-12 17:20:20 +01:00
dp_rint.c MIPS: math-emu: RINT.<D|S>: Fix several problems by reimplementation 2017-08-29 15:21:56 +02:00
dp_simple.c
dp_sqrt.c MIPS: math-emu: Mark fall throughs in switch statements with a comment 2017-12-12 17:20:20 +01:00
dp_sub.c MIPS: math-emu: Mark fall throughs in switch statements with a comment 2017-12-12 17:20:20 +01:00
dp_tint.c
dp_tlong.c
dsemul.c MIPS: math-emu: Write-protect delay slot emulation pages 2019-01-09 17:38:47 +01:00
ieee754.c
ieee754.h MIPS: math-emu: Use preferred flavor of unsigned integer declarations 2017-11-07 18:33:16 +00:00
ieee754d.c
ieee754dp.c
ieee754dp.h MIPS: math-emu: Avoid definition duplication for macro DPXMULT() 2017-12-12 17:20:19 +01:00
ieee754int.h MIPS: math-emu: Use preferred flavor of unsigned integer declarations 2017-11-07 18:33:16 +00:00
ieee754sp.c MIPS: math-emu: Use preferred flavor of unsigned integer declarations 2017-11-07 18:33:16 +00:00
ieee754sp.h MIPS: math-emu: Use preferred flavor of unsigned integer declarations 2017-11-07 18:33:16 +00:00
Makefile License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
me-debugfs.c License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
sp_2008class.c
sp_add.c MIPS: math-emu: Mark fall throughs in switch statements with a comment 2017-12-12 17:20:20 +01:00
sp_cmp.c
sp_div.c MIPS: math-emu: Mark fall throughs in switch statements with a comment 2017-12-12 17:20:20 +01:00
sp_fdp.c MIPS: math-emu: Mark fall throughs in switch statements with a comment 2017-12-12 17:20:20 +01:00
sp_fint.c MIPS: math-emu: Use preferred flavor of unsigned integer declarations 2017-11-07 18:33:16 +00:00
sp_flong.c
sp_fmax.c MIPS: math-emu: Mark fall throughs in switch statements with a comment 2017-12-12 17:20:20 +01:00
sp_fmin.c MIPS: math-emu: Mark fall throughs in switch statements with a comment 2017-12-12 17:20:20 +01:00
sp_maddf.c MIPS: math-emu: Mark fall throughs in switch statements with a comment 2017-12-12 17:20:20 +01:00
sp_mul.c MIPS: math-emu: Mark fall throughs in switch statements with a comment 2017-12-12 17:20:20 +01:00
sp_rint.c MIPS: math-emu: RINT.<D|S>: Fix several problems by reimplementation 2017-08-29 15:21:56 +02:00
sp_simple.c
sp_sqrt.c MIPS: math-emu: Avoid multiple assignment 2017-12-12 17:20:20 +01:00
sp_sub.c MIPS: math-emu: Mark fall throughs in switch statements with a comment 2017-12-12 17:20:20 +01:00
sp_tint.c
sp_tlong.c MIPS: math-emu: Remove an unnecessary header inclusion 2017-12-12 17:20:19 +01:00