remarkable-linux/arch
Gerald Schaefer a36c14ba24 s390/mm: fix asce_bits handling with dynamic pagetable levels
[ Upstream commit 723cacbd9d ]

There is a race with multi-threaded applications between context switch and
pagetable upgrade. In switch_mm() a new user_asce is built from mm->pgd and
mm->context.asce_bits, w/o holding any locks. A concurrent mmap with a
pagetable upgrade on another thread in crst_table_upgrade() could already
have set new asce_bits, but not yet the new mm->pgd. This would result in a
corrupt user_asce in switch_mm(), and eventually in a kernel panic from a
translation exception.

Fix this by storing the complete asce instead of just the asce_bits, which
can then be read atomically from switch_mm(), so that it either sees the
old value or the new value, but no mixture. Both cases are OK. Having the
old value would result in a page fault on access to the higher level memory,
but the fault handler would see the new mm->pgd, if it was a valid access
after the mmap on the other thread has completed. So as worst-case scenario
we would have a page fault loop for the racing thread until the next time
slice.

Also remove dead code and simplify the upgrade/downgrade path, there are no
upgrades from 2 levels, and only downgrades from 3 levels for compat tasks.
There are also no concurrent upgrades, because the mmap_sem is held with
down_write() in do_mmap, so the flush and table checks during upgrade can
be removed.

Reported-by: Michael Munday <munday@ca.ibm.com>
Reviewed-by: Martin Schwidefsky <schwidefsky@de.ibm.com>
Signed-off-by: Gerald Schaefer <gerald.schaefer@de.ibm.com>
Signed-off-by: Martin Schwidefsky <schwidefsky@de.ibm.com>
Signed-off-by: Sasha Levin <sasha.levin@oracle.com>
2016-07-10 23:07:25 -04:00
..
alpha alpha: kernel: osf_sys: Set 'kts.tv_nsec' only when 'tv' has effect 2015-05-26 10:01:51 -07:00
arc arc: unwind: warn only once if DW2_UNWIND is disabled 2016-07-10 22:27:13 -04:00
arm ARM: OMAP3: Add cpuidle parameters table for omap3430 2016-07-10 23:07:15 -04:00
arm64 arm64: mm: remove page_mapping check in __sync_icache_dcache 2016-07-10 20:20:00 -04:00
avr32 mmc: atmel-mci: restore dma on AVR32 2016-04-18 08:51:01 -04:00
blackfin blackfin: Fix build error 2015-06-10 10:19:24 -07:00
c6x C6X Fixes for v4.1 2015-04-16 18:48:55 -04:00
cris CRIS changes for 4.1 2015-04-26 13:31:05 -07:00
frv Devicetree updates for 4.1: 2015-04-24 08:46:18 -07:00
hexagon Merge branch 'exec_domain_rip_v2' of git://git.kernel.org/pub/scm/linux/kernel/git/rw/misc 2015-04-15 13:53:55 -07:00
ia64 ia64: make cpu_callin_map non-volatile. 2015-06-02 10:07:03 -07:00
m32r m32r: fix m32104ut_defconfig build fail 2016-02-03 16:23:16 -05:00
m68k m68k: Define asmlinkage_protect 2015-10-22 14:43:25 -07:00
metag Metag architecture changes for v4.1 2015-04-24 07:56:50 -07:00
microblaze microblaze: use asm-generic for seccomp.h 2015-04-17 09:04:10 -04:00
mips MIPS: KVM: Fix modular KVM under QEMU 2016-07-10 20:19:56 -04:00
mn10300 mn10300: Select CONFIG_HAVE_UID16 to fix build failure 2016-01-31 11:23:40 -08:00
nios2 nios2 update for v4.1-rc1 2015-04-24 07:59:07 -07:00
openrisc openrisc: fix CONFIG_UID16 setting 2015-08-03 09:28:58 -07:00
parisc parisc: Fix pagefault crash in unaligned __get_user() call 2016-06-17 15:39:21 -04:00
powerpc powerpc: Update TM user feature bits in scan_features() 2016-07-10 23:07:09 -04:00
s390 s390/mm: fix asce_bits handling with dynamic pagetable levels 2016-07-10 23:07:25 -04:00
score score: Fix exception handler label 2015-06-10 10:19:47 -07:00
sh lib/decompressors: use real out buf size for gunzip with kernel 2015-09-29 19:26:19 +02:00
sparc sparc64: fix incorrect sign extension in sys_sparc64_personality 2016-02-03 16:23:15 -05:00
tile signal: fix information leak in copy_siginfo_from_user32 2015-08-16 20:52:26 -07:00
um fs/coredump: prevent fsuid=0 dumps into user-controlled directories 2016-04-18 08:51:07 -04:00
unicore32 lib/decompressors: use real out buf size for gunzip with kernel 2015-09-29 19:26:19 +02:00
x86 ACPI / processor: Request native thermal interrupt handling via _OSC 2016-07-10 23:07:20 -04:00
xtensa xtensa: clear all DBREAKC registers on start 2016-04-18 08:50:55 -04:00
.gitignore
Kconfig powerpc updates for 4.1 2015-04-16 13:53:32 -05:00