1
0
Fork 0
remarkable-linux/drivers/misc
Frederic Barrat c1edd3b19f cxl: Fix possible deadlock when processing page faults from cxllib
commit ad7b4e8022 upstream.

cxllib_handle_fault() is called by an external driver when it needs to
have the host resolve page faults for a buffer. The buffer can cover
several pages and VMAs. The function iterates over all the pages used
by the buffer, based on the page size of the VMA.

To ensure some stability while processing the faults, the thread T1
grabs the mm->mmap_sem semaphore with read access (R1). However, when
processing a page fault for a single page, one of the underlying
functions, copro_handle_mm_fault(), also grabs the same semaphore with
read access (R2). So the thread T1 takes the semaphore twice.

If another thread T2 tries to access the semaphore in write mode W1
(say, because it wants to allocate memory and calls 'brk'), then that
thread T2 will have to wait because there's a reader (R1). If the
thread T1 is processing a new page at that time, it won't get an
automatic grant at R2, because there's now a writer thread
waiting (T2). And we have a deadlock.

The timeline is:
1. thread T1 owns the semaphore with read access R1
2. thread T2 requests write access W1 and waits
3. thread T1 requests read access R2 and waits

The fix is for the thread T1 to release the semaphore R1 once it got
the information it needs from the current VMA. The address space/VMAs
could evolve while T1 iterates over the full buffer, but in the
unlikely case where T1 misses a page, the external driver will raise a
new page fault when retrying the memory access.

Fixes: 3ced8d7300 ("cxl: Export library to support IBM XSL")
Cc: stable@vger.kernel.org # 4.13+
Signed-off-by: Frederic Barrat <fbarrat@linux.vnet.ibm.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-04-24 09:36:32 +02:00
..
altera-stapl
c2port kmemcheck: remove annotations 2018-02-22 15:42:23 +01:00
cb710
cxl cxl: Fix possible deadlock when processing page faults from cxllib 2018-04-24 09:36:32 +02:00
echo
eeprom eeprom: at24: change nvmem stride to 1 2017-12-20 10:10:21 +01:00
genwqe sched/headers: Prepare for new header dependencies before moving code to <linux/sched/signal.h> 2017-03-02 08:42:29 +01:00
ibmasm License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
lis3lv02d misc: lis3lv02d: constify attribute_group structures. 2017-08-28 16:55:48 +02:00
mei mei: remove dev_err message on an unsupported ioctl 2018-04-08 14:26:31 +02:00
mic License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
sgi-gru sgi-gru: update to new mmu_notifier semantic 2017-08-31 16:13:00 -07:00
sgi-xp License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
ti-st misc: ti-st: constify attribute_group structures. 2017-08-28 16:55:48 +02:00
vmw_vmci vmci: fix duplicated code for different branches 2017-08-28 16:55:50 +02:00
Kconfig drivers/misc: add Aspeed LPC snoop driver 2017-06-03 19:15:18 +09:00
Makefile License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
ad525x_dpot-i2c.c
ad525x_dpot-spi.c
ad525x_dpot.c misc: ad525x_dpot: Fix the enabling of the "otpXen" attributes 2016-03-01 16:55:13 -08:00
ad525x_dpot.h
apds990x.c misc: apds990x: constify attribute_group structures. 2017-08-28 16:55:49 +02:00
apds9802als.c misc: apds9802als: constify i2c_device_id 2017-08-28 16:55:49 +02:00
aspeed-lpc-ctrl.c drivers/misc: aspeed-lpc-ctrl: fix printk format warning again 2017-04-08 17:37:20 +02:00
aspeed-lpc-snoop.c drivers/misc: (aspeed-lpc-snoop): Add ast2400 to compat 2017-07-17 17:23:16 +02:00
atmel-ssc.c misc: atmel-ssc: register as sound DAI if #sound-dai-cells is present 2016-12-15 12:13:31 +00:00
atmel_tclib.c
bh1770glc.c misc: bh1770glc: constify attribute_group structures. 2017-08-28 16:55:48 +02:00
cs5535-mfgpt.c
ds1682.c MISC: add const to bin_attribute structures 2017-08-28 16:55:48 +02:00
dummy-irq.c Annotate hardware config module parameters in drivers/misc/ 2017-04-20 12:02:32 +01:00
enclosure.c scsi: ses: do not add a device to an enclosure if enclosure_add_links() fails. 2017-07-01 16:52:38 -04:00
fsa9480.c
hmc6352.c misc: hmc6352: constify i2c_device_id 2017-08-28 16:55:49 +02:00
hpilo.c misc: hpilo: constify pci_device_id. 2017-08-28 16:55:48 +02:00
hpilo.h
ics932s401.c
ioc4.c misc: ioc4: constify pci_device_id. 2017-08-28 16:55:48 +02:00
isl29003.c
isl29020.c misc: isl29020: constify i2c_device_id 2017-08-28 16:55:49 +02:00
kgdbts.c sched/headers: Prepare for new header dependencies before moving code to <linux/sched/task.h> 2017-03-02 08:42:35 +01:00
lattice-ecp3-config.c
lkdtm.h License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
lkdtm_bugs.c License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
lkdtm_core.c lkdtm: Add -fstack-protector-strong test 2017-08-15 12:27:35 -07:00
lkdtm_heap.c License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
lkdtm_perms.c License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
lkdtm_refcount.c lkdtm: fix spelling mistake: "incremeted" -> "incremented" 2017-08-28 17:47:11 +02:00
lkdtm_rodata.c License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
lkdtm_usercopy.c License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
pch_phub.c MISC: add const to bin_attribute structures 2017-08-28 16:55:48 +02:00
pci_endpoint_test.c misc: pci_endpoint_test: Avoid triggering a BUG() 2017-12-20 10:10:28 +01:00
phantom.c
pti.c drivers/misc/intel/pti: Rename the header file to free up the namespace 2017-12-25 14:26:20 +01:00
qcom-coincell.c ARM: qcom: silence an uninitialized variable warning 2016-05-01 14:20:04 -07:00
spear13xx_pcie_gadget.c
sram-exec.c misc: sram-exec: Use aligned fncpy instead of memcpy 2017-05-18 17:37:52 +02:00
sram.c misc: Convert to using %pOF instead of full_name 2017-08-28 16:55:49 +02:00
sram.h misc: sram: Integrate protect-exec reserved sram area type 2017-01-25 11:48:03 +01:00
ti_dac7512.c
tifm_7xx1.c misc: tifm: constify pci_device_id. 2017-08-28 16:55:48 +02:00
tifm_core.c
tsl2550.c misc: tsl2550: Add OF device ID table 2017-04-08 18:22:59 +02:00
vexpress-syscfg.c sched/headers: Prepare to move signal wakeup & sigpending methods from <linux/sched.h> into <linux/sched/signal.h> 2017-03-02 08:42:32 +01:00
vmw_balloon.c x86/virt: Add enum for hypervisors to replace x86_hyper 2017-12-25 14:26:20 +01:00