linux/arch/mips/math-emu
Paul Burton adcc81f148
MIPS: math-emu: Write-protect delay slot emulation pages
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>
2018-12-20 10:00:01 -08:00
..
cp1emu.c MIPS: Ensure emulated FP sets PF_USED_MATH 2018-11-09 10:23:14 -08:00
dp_2008class.c MIPS: math-emu: Add support for the MIPS R6 CLASS FPU instruction 2015-09-03 12:08:14 +02:00
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 MIPS: math-emu: Remove redundant code from NaN comparison 2015-04-08 01:09:38 +02:00
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 MIPS: math-emu: Cleanup coding style. 2014-05-23 15:11:15 +02:00
dp_flong.c MIPS: math-emu: Cleanup coding style. 2014-05-23 15:11:15 +02:00
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 MIPS: math-emu: Reinstate sNaN quieting handlers 2015-04-08 01:09:31 +02:00
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 MIPS: math-emu: Add IEEE Std 754-2008 ABS.fmt and NEG.fmt emulation 2016-01-20 00:39:20 +01:00
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 MIPS: math-emu: Add IEEE Std 754-2008 NaN encoding emulation 2016-01-20 00:39:20 +01:00
dp_tlong.c MIPS: math-emu: Add IEEE Std 754-2008 NaN encoding emulation 2016-01-20 00:39:20 +01:00
dsemul.c MIPS: math-emu: Write-protect delay slot emulation pages 2018-12-20 10:00:01 -08:00
ieee754.c MIPS: math-emu: Add IEEE Std 754-2008 NaN encoding emulation 2016-01-20 00:39:20 +01:00
ieee754.h MIPS: math-emu: Use preferred flavor of unsigned integer declarations 2017-11-07 18:33:16 +00:00
ieee754d.c MIPS: math-emu: Cleanup coding style. 2014-05-23 15:11:15 +02:00
ieee754dp.c MIPS: math-emu: Always propagate sNaN payload in quieting 2016-05-13 14:02:11 +02:00
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 MIPS: math-emu: Change to use DEFINE_SHOW_ATTRIBUTE macro 2018-11-05 10:13:21 -08:00
sp_2008class.c MIPS: math-emu: Add support for the MIPS R6 CLASS FPU instruction 2015-09-03 12:08:14 +02:00
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 MIPS: math-emu: Remove redundant code from NaN comparison 2015-04-08 01:09:38 +02:00
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 MIPS: math-emu: Cleanup coding style. 2014-05-23 15:11:15 +02:00
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 MIPS: math-emu: Add IEEE Std 754-2008 ABS.fmt and NEG.fmt emulation 2016-01-20 00:39:20 +01:00
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 MIPS: math-emu: Add IEEE Std 754-2008 NaN encoding emulation 2016-01-20 00:39:20 +01:00
sp_tlong.c MIPS: math-emu: Remove an unnecessary header inclusion 2017-12-12 17:20:19 +01:00