linux-brain/arch/mips/math-emu
Paul Burton f12e01b3c6 MIPS: math-emu: Write-protect delay slot emulation pages
commit adcc81f148 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-13 10:03:51 +01:00
..
cp1emu.c MIPS: math-emu: Fix final emulation phase for certain instructions 2017-12-25 14:23:46 +01: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: Reinstate sNaN quieting handlers 2015-04-08 01:09:31 +02: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: Reinstate sNaN quieting handlers 2015-04-08 01:09:31 +02: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: <MAXA|MINA>.<D|S>: Fix cases of both infinite inputs 2017-09-27 14:39:19 +02:00
dp_fmin.c MIPS: math-emu: MINA.<D|S>: Fix some cases of infinity and zero inputs 2017-09-27 14:39:19 +02: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: <MADDF|MSUBF>.D: Fix accuracy (64-bit case) 2017-09-27 14:39:20 +02:00
dp_mul.c MIPS: math-emu: Fix code indentation 2016-05-13 14:02:23 +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: Reinstate sNaN quieting handlers 2015-04-08 01:09:31 +02:00
dp_sub.c MIPS: math-emu: Reinstate sNaN quieting handlers 2015-04-08 01:09:31 +02: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 2019-01-13 10:03:51 +01: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: Add IEEE Std 754-2008 NaN encoding emulation 2016-01-20 00:39:20 +01: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: Add z argument macros 2016-05-13 14:02:22 +02:00
ieee754int.h MIPS: math-emu: <MADDF|MSUBF>.<D|S>: Clean up "maddf_flags" enumeration 2017-09-27 14:39:20 +02:00
ieee754sp.c MIPS: math-emu: Fix m{add,sub}.s shifts 2016-05-13 14:02:23 +02:00
ieee754sp.h MIPS: math-emu: <MADDF|MSUBF>.S: Fix accuracy (32-bit case) 2017-09-27 14:39:20 +02:00
Makefile MIPS: math-emu: Unify ieee754dp_m{add,sub}f 2016-05-13 14:02:22 +02:00
me-debugfs.c MIPS: Declare mips_debugfs_dir in a header 2015-10-26 09:49:42 +01: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: Fix m{add,sub}.s shifts 2016-05-13 14:02:23 +02: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: Reinstate sNaN quieting handlers 2015-04-08 01:09:31 +02:00
sp_fdp.c MIPS: math-emu: Add IEEE Std 754-2008 NaN encoding emulation 2016-01-20 00:39:20 +01:00
sp_fint.c MIPS: math-emu: Cleanup coding style. 2014-05-23 15:11:15 +02:00
sp_flong.c MIPS: math-emu: Cleanup coding style. 2014-05-23 15:11:15 +02:00
sp_fmax.c MIPS: math-emu: <MAXA|MINA>.<D|S>: Fix cases of both infinite inputs 2017-09-27 14:39:19 +02:00
sp_fmin.c MIPS: math-emu: MINA.<D|S>: Fix some cases of infinity and zero inputs 2017-09-27 14:39:19 +02:00
sp_maddf.c MIPS: math-emu: <MADDF|MSUBF>.S: Fix accuracy (32-bit case) 2017-09-27 14:39:20 +02:00
sp_mul.c MIPS: math-emu: Reinstate sNaN quieting handlers 2015-04-08 01:09:31 +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: Reinstate sNaN quieting handlers 2015-04-08 01:09:31 +02:00
sp_sub.c MIPS: math-emu: Fix m{add,sub}.s shifts 2016-05-13 14:02:23 +02: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: Add IEEE Std 754-2008 NaN encoding emulation 2016-01-20 00:39:20 +01:00