1
0
Fork 0
alistair23-linux/arch/powerpc/mm
Nicholas Piggin 557c184df3 powerpc/64s/radix: Fix mm_cpumask trimming race vs kthread_use_mm
[ Upstream commit a665eec0a2 ]

Commit 0cef77c779 ("powerpc/64s/radix: flush remote CPUs out of
single-threaded mm_cpumask") added a mechanism to trim the mm_cpumask of
a process under certain conditions. One of the assumptions is that
mm_users would not be incremented via a reference outside the process
context with mmget_not_zero() then go on to kthread_use_mm() via that
reference.

That invariant was broken by io_uring code (see previous sparc64 fix),
but I'll point Fixes: to the original powerpc commit because we are
changing that assumption going forward, so this will make backports
match up.

Fix this by no longer relying on that assumption, but by having each CPU
check the mm is not being used, and clearing their own bit from the mask
only if it hasn't been switched-to by the time the IPI is processed.

This relies on commit 38cf307c1f ("mm: fix kthread_use_mm() vs TLB
invalidate") and ARCH_WANT_IRQS_OFF_ACTIVATE_MM to disable irqs over mm
switch sequences.

Fixes: 0cef77c779 ("powerpc/64s/radix: flush remote CPUs out of single-threaded mm_cpumask")
Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
Reviewed-by: Michael Ellerman <mpe@ellerman.id.au>
Depends-on: 38cf307c1f ("mm: fix kthread_use_mm() vs TLB invalidate")
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Link: https://lore.kernel.org/r/20200914045219.3736466-5-npiggin@gmail.com
Signed-off-by: Sasha Levin <sashal@kernel.org>
2020-10-29 09:57:49 +01:00
..
book3s32 powerpc/32s: Don't warn when mapping RO data ROX. 2020-06-24 17:50:34 +02:00
book3s64 powerpc/64s/radix: Fix mm_cpumask trimming race vs kthread_use_mm 2020-10-29 09:57:49 +01:00
kasan Revert "powerpc/kasan: Fix shadow pages allocation failure" 2020-08-11 15:33:39 +02:00
nohash powerpc/fsl_booke: Avoid creating duplicate tlb1 entry 2020-04-17 10:50:22 +02:00
ptdump powerpc/ptdump: Fix build failure in hashpagetable.c 2020-08-21 13:05:24 +02:00
Makefile powerpc/mm: Move ioremap functions out of pgtable_32/64.c 2019-08-27 13:03:35 +10:00
copro_fault.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 153 2019-05-30 11:26:32 -07:00
dma-noncoherent.c powerpc updates for 5.4 2019-09-20 11:48:06 -07:00
drmem.c pseries/drmem: don't cache node id in drmem_lmb struct 2020-10-29 09:57:47 +01:00
fault.c powerpc: Allow 4224 bytes of stack expansion for the signal frame 2020-08-21 13:05:24 +02:00
highmem.c powerpc/highmem: Change BUG_ON() to WARN_ON() 2019-04-20 22:02:11 +10:00
hugetlbpage.c powerpc/hugetlb: Fix 512k hugepages on 8xx with 16k page size 2020-02-28 17:22:18 +01:00
init-common.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 152 2019-05-30 11:26:32 -07:00
init_32.c Revert "powerpc/kasan: Fix shadow pages allocation failure" 2020-08-11 15:33:39 +02:00
init_64.c powerpc/book3s64/radix: Fix boot failure with large amount of guest memory 2020-09-23 12:40:39 +02:00
ioremap.c powerpc/mm: split out early ioremap path. 2019-08-27 13:03:35 +10:00
ioremap_32.c powerpc/mm: split out early ioremap path. 2019-08-27 13:03:35 +10:00
ioremap_64.c powerpc/mm: split out early ioremap path. 2019-08-27 13:03:35 +10:00
mem.c powerpc/mm: Fix missing KUAP disable in flush_coherent_icache() 2020-03-12 13:00:25 +01:00
mmap.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 156 2019-05-30 11:26:35 -07:00
mmu_context.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 152 2019-05-30 11:26:32 -07:00
mmu_decl.h powerpc/mm: make ioremap_bot common to all 2019-08-27 13:03:34 +10:00
numa.c powerpc updates for 5.3 2019-07-13 16:08:36 -07:00
pgtable-frag.c mm: treewide: clarify pgtable_page_{ctor,dtor}() naming 2019-09-26 10:10:44 -07:00
pgtable.c powerpc updates for 5.3 2019-07-13 16:08:36 -07:00
pgtable_32.c powerpc/mm: Fix conditions to perform MMU specific management by blocks on PPC32. 2020-06-22 09:31:13 +02:00
pgtable_64.c powerpc/mm: Move ioremap functions out of pgtable_32/64.c 2019-08-27 13:03:35 +10:00
slice.c powerpc/mm: Mark get_slice_psize() & slice_addr_is_low() as notrace 2020-01-09 10:20:04 +01:00