linux-stable/arch/powerpc
Haren Myneni 959dc1b16e powerpc/pseries/vas: Hold mmap_mutex after mmap lock during window close
[ Upstream commit b59c9dc4d9 ]

Commit 8ef7b9e176 ("powerpc/pseries/vas: Close windows with DLPAR
core removal") unmaps the window paste address and issues HCALL to
close window in the hypervisor for migration or DLPAR core removal
events. So holds mmap_mutex and then mmap lock before unmap the
paste address. But if the user space issue mmap paste address at
the same time with the migration event, coproc_mmap() is called
after holding the mmap lock which can trigger deadlock when trying
to acquire mmap_mutex in coproc_mmap().

t1: mmap() call to mmap              t2: Migration event
    window paste address

do_mmap2()                           migration_store()
 ksys_mmap_pgoff()                    pseries_migrate_partition()
  vm_mmap_pgoff()                      vas_migration_handler()
    Acquire mmap lock                   reconfig_close_windows()
    do_mmap()                             lock mmap_mutex
     mmap_region()                        Acquire mmap lock
      call_mmap()                         //Wait for mmap lock
       coproc_mmap()                        unmap vma
         lock mmap_mutex                    update window status
         //wait for mmap_mutex            Release mmap lock
          mmap vma                        unlock mmap_mutex
          update window status
         unlock mmap_mutex
    ...
    Release mmap lock

Fix this deadlock issue by holding mmap lock first before mmap_mutex
in reconfig_close_windows().

Fixes: 8ef7b9e176 ("powerpc/pseries/vas: Close windows with DLPAR core removal")
Signed-off-by: Haren Myneni <haren@linux.ibm.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Link: https://msgid.link/20230716100506.7833-1-haren@linux.ibm.com
Signed-off-by: Sasha Levin <sashal@kernel.org>
2023-08-03 10:25:41 +02:00
..
boot powerpc: dts: turris1x.dts: Fix PCIe MEM size for pci2 node 2023-07-19 16:36:46 +02:00
configs powerpc updates for 6.4 2023-04-28 16:24:32 -07:00
crypto powerpc/crypto: Fix aes-gcm-p10 link errors 2023-05-30 15:50:32 +10:00
include watchdog/hardlockup: rename some "NMI watchdog" constants/function 2023-07-19 16:35:32 +02:00
kernel powerpc/security: Fix Speculation_Store_Bypass reporting on Power10 2023-07-23 13:53:55 +02:00
kexec powerpc/kexec_file: print error string on usable memory property update failure 2023-02-15 23:14:06 +11:00
kvm s390: 2023-05-01 12:06:20 -07:00
lib powerpc/64: vmlinux support building with PCREL addresing 2023-04-20 12:59:21 +10:00
math-emu powerpc/math-emu: Inhibit W=1 warnings 2022-09-08 11:11:18 +10:00
mm powerpc/64s: Fix native_hpte_remove() to be irq-safe 2023-07-23 13:53:55 +02:00
net powerpc/bpf: populate extable entries only during the last pass 2023-05-15 15:40:31 +10:00
perf powerpc/perf: Properly detect mpc7450 family 2023-03-30 23:35:43 +11:00
platforms powerpc/pseries/vas: Hold mmap_mutex after mmap lock during window close 2023-08-03 10:25:41 +02:00
purgatory powerpc/purgatory: remove PGO flags 2023-06-12 11:31:50 -07:00
sysdev powerpc updates for 6.4 2023-04-28 16:24:32 -07:00
tools powerpc: Move script to check relocations at compile time in scripts/ 2023-04-19 07:46:31 -07:00
xmon powerpc/xmon: Use KSYM_NAME_LEN in array size 2023-05-30 16:46:56 +10:00
Kbuild
Kconfig powerpc/mm: Convert to using lock_mm_and_find_vma() 2023-07-01 13:12:39 +02:00
Kconfig.debug powerpc: allow PPC_EARLY_DEBUG_CPM only when SERIAL_CPM=y 2023-07-19 16:36:46 +02:00
Makefile powerpc: Fail build if using recordmcount with binutils v2.37 2023-07-23 13:53:55 +02:00
Makefile.postlink kbuild: remove --include-dir MAKEFLAG from top Makefile 2023-02-05 18:51:22 +09:00