1
0
Fork 0
remarkable-linux/arch/s390
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
..
appldata s390: appldata: drop owner assignment from platform_drivers 2014-10-20 16:20:13 +02:00
boot s390/boot/decompression: disable floating point in decompressor 2015-10-22 14:43:14 -07:00
configs s390: update default configuration 2015-01-22 12:16:09 +01:00
crypto Merge git://git.kernel.org/pub/scm/linux/kernel/git/herbert/crypto-2.6 2015-05-22 14:26:36 -07:00
hypfs sysfs: Create mountpoints with sysfs_create_mount_point 2015-07-21 10:10:01 -07:00
include s390/mm: fix asce_bits handling with dynamic pagetable levels 2016-07-10 23:07:25 -04:00
kernel Revert "s390/kdump: Clear subchannel ID to signal non-CCW/SCSI IPL" 2016-07-10 22:27:13 -04:00
kvm KVM: s390: enable SIMD only when no VCPUs were created 2015-12-09 14:03:28 -05:00
lib s390: remove "64" suffix from mem64.S and swsusp_asm64.S 2015-03-25 11:49:51 +01:00
mm s390/mm: fix asce_bits handling with dynamic pagetable levels 2016-07-10 23:07:25 -04:00
net s390/bpf: clear correct BPF accumulator register 2015-08-10 12:21:52 -07:00
oprofile s390: remove 31 bit support 2015-03-25 11:49:33 +01:00
pci s390/pci: enforce fmb page boundary rule 2016-04-18 08:50:57 -04:00
Kbuild s390: remove 31 bit support 2015-03-25 11:49:33 +01:00
Kconfig s390/bpf: add dependency to z196 features 2015-04-23 16:55:50 +02:00
Kconfig.debug Kconfig: consolidate CONFIG_DEBUG_STRICT_USER_COPY_CHECKS 2013-04-30 17:04:09 -07:00
Makefile s390: remove 31 bit support 2015-03-25 11:49:33 +01:00
defconfig s390: update default configuration 2015-01-22 12:16:09 +01:00