1
0
Fork 0
remarkable-linux/drivers
Dexuan Cui 8aa07625eb hv_netvsc: Fix a deadlock by getting rtnl lock earlier in netvsc_probe()
[ Upstream commit e04e7a7bbd ]

This patch fixes the race between netvsc_probe() and
rndis_set_subchannel(), which can cause a deadlock.

These are the related 3 paths which show the deadlock:

path #1:
    Workqueue: hv_vmbus_con vmbus_onmessage_work [hv_vmbus]
    Call Trace:
     schedule
     schedule_preempt_disabled
     __mutex_lock
     __device_attach
     bus_probe_device
     device_add
     vmbus_device_register
     vmbus_onoffer
     vmbus_onmessage_work
     process_one_work
     worker_thread
     kthread
     ret_from_fork

path #2:
    schedule
     schedule_preempt_disabled
     __mutex_lock
     netvsc_probe
     vmbus_probe
     really_probe
     __driver_attach
     bus_for_each_dev
     driver_attach_async
     async_run_entry_fn
     process_one_work
     worker_thread
     kthread
     ret_from_fork

path #3:
    Workqueue: events netvsc_subchan_work [hv_netvsc]
    Call Trace:
     schedule
     rndis_set_subchannel
     netvsc_subchan_work
     process_one_work
     worker_thread
     kthread
     ret_from_fork

Before path #1 finishes, path #2 can start to run, because just before
the "bus_probe_device(dev);" in device_add() in path #1, there is a line
"object_uevent(&dev->kobj, KOBJ_ADD);", so systemd-udevd can
immediately try to load hv_netvsc and hence path #2 can start to run.

Next, path #2 offloads the subchannal's initialization to a workqueue,
i.e. path #3, so we can end up in a deadlock situation like this:

Path #2 gets the device lock, and is trying to get the rtnl lock;
Path #3 gets the rtnl lock and is waiting for all the subchannel messages
to be processed;
Path #1 is trying to get the device lock, but since #2 is not releasing
the device lock, path #1 has to sleep; since the VMBus messages are
processed one by one, this means the sub-channel messages can't be
procedded, so #3 has to sleep with the rtnl lock held, and finally #2
has to sleep... Now all the 3 paths are sleeping and we hit the deadlock.

With the patch, we can make sure #2 gets both the device lock and the
rtnl lock together, gets its job done, and releases the locks, so #1
and #3 will not be blocked for ever.

Fixes: 8195b1396e ("hv_netvsc: fix deadlock on hotplug")
Signed-off-by: Dexuan Cui <decui@microsoft.com>
Cc: Stephen Hemminger <sthemmin@microsoft.com>
Cc: K. Y. Srinivasan <kys@microsoft.com>
Cc: Haiyang Zhang <haiyangz@microsoft.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-09-15 09:45:26 +02:00
..
accessibility
acpi ACPI / EC: Use ec_no_wakeup on more Thinkpad X1 Carbon 6th systems 2018-08-24 13:09:20 +02:00
amba ARM: amba: Don't read past the end of sysfs "driver_override" buffer 2018-05-01 12:58:21 -07:00
android ANDROID: binder: prevent transactions into own process. 2018-05-01 12:58:20 -07:00
ata libahci: Fix possible Spectre-v1 pmp indexing in ahci_led_store() 2018-08-24 13:09:00 +02:00
atm atm: zatm: Fix potential Spectre v1 2018-07-22 14:28:43 +02:00
auxdisplay auxdisplay: fix broken menu 2018-07-03 11:24:56 +02:00
base PM / clk: signedness bug in of_pm_clk_add_clks() 2018-09-05 09:26:42 +02:00
bcma
block drivers/block/zram/zram_drv.c: fix bug storing backing_dev 2018-09-09 19:55:58 +02:00
bluetooth Bluetooth: hci_serdev: Init hci_uart proto_lock to avoid oops 2018-08-15 18:12:49 +02:00
bus drivers/perf: arm-ccn: don't log to dmesg in event_init 2018-08-03 07:50:31 +02:00
cdrom cdrom: Fix info leak/OOB read in cdrom_ioctl_drive_status 2018-09-05 09:26:42 +02:00
char tpm: Return the actual size when receiving an unsupported command 2018-09-05 09:26:41 +02:00
clk clk: rockchip: fix clk_i2sout parent selection bits on rk3399 2018-09-05 09:26:42 +02:00
clocksource clocksource/drivers/imx-tpm: Correct some registers operation flow 2018-06-21 04:02:40 +09:00
connector
cpufreq cpufreq: governor: Avoid accessing invalid governor_data 2018-09-09 19:55:58 +02:00
cpuidle cpuidle: powernv: Fix promotion from snooze if next state disabled 2018-07-03 11:24:51 +02:00
crypto crypto: caam/qi - fix error path in xts setkey 2018-09-09 19:56:02 +02:00
dax dev-dax: check_vma: ratelimit dev_info-s 2018-08-24 13:09:08 +02:00
dca
devfreq PM / devfreq: Fix potential NULL pointer dereference in governor_store 2018-04-12 12:32:13 +02:00
dio
dma dmaengine: k3dma: Off by one in k3_of_dma_simple_xlate() 2018-08-24 13:09:08 +02:00
dma-buf dma-buf: remove redundant initialization of sg_table 2018-06-05 11:41:57 +02:00
edac EDAC: Add missing MEM_LRDDR4 entry in edac_mem_types[] 2018-08-24 13:08:55 +02:00
eisa
extcon extcon: Release locking when sending the notification of connector state 2018-09-09 19:55:56 +02:00
firewire firewire-ohci: work around oversized DMA reads on JMicron controllers 2018-04-26 11:02:03 +02:00
firmware fw_cfg: fix driver remove 2018-08-17 21:01:11 +02:00
fmc
fpga fpga-manager: altera-ps-spi: preserve nCONFIG state 2018-05-01 12:58:24 -07:00
fsi
gpio gpiolib-acpi: make sure we trigger edge events at least once on boot 2018-09-05 09:26:32 +02:00
gpu drm/i915/userptr: reject zero user_size 2018-09-09 19:55:53 +02:00
hid HID: wacom: Correct touch maximum XY of 2nd-gen Intuos 2018-08-24 13:09:11 +02:00
hsi
hv Drivers: hv: vmbus: Reset the channel callback in vmbus_onoffer_rescind() 2018-09-09 19:55:56 +02:00
hwmon hwmon: (nct6775) Fix potential Spectre v1 2018-09-05 09:26:40 +02:00
hwspinlock
hwtracing intel_th: Use correct device when freeing buffers 2018-06-05 11:41:59 +02:00
i2c i2c/mux, locking/core: Annotate the nested rt_mutex usage 2018-09-05 09:26:29 +02:00
ide cdrom: do not call check_disk_change() inside cdrom_open() 2018-05-30 07:52:34 +02:00
idle intel_idle: Graceful probe failure when MWAIT is disabled 2018-08-09 12:16:39 +02:00
iio iio: ad9523: Fix return value for ad952x_store() 2018-09-09 19:55:56 +02:00
infiniband RDMA/rxe: Set wqe->status correctly if an unexpected response is received 2018-09-09 19:55:54 +02:00
input Input: synaptics-rmi4 - fix axis-swap behavior 2018-08-24 13:08:56 +02:00
iommu iommu/vt-d: Fix dev iotlb pfsid use 2018-09-09 19:56:00 +02:00
ipack
irqchip irqchip/ls-scfg-msi: Map MSIs in the iommu 2018-08-03 07:50:24 +02:00
isdn isdn: Disable IIOCDBGVAR 2018-08-22 07:46:11 +02:00
leds leds: pm8058: Silence pointer to integer size warning 2018-03-19 08:42:50 +01:00
lightnvm lightnvm: pblk: warn in case of corrupted write buffer 2018-08-03 07:50:25 +02:00
macintosh drivers: macintosh: rack-meter: really fix bogus memsets 2018-05-30 07:52:27 +02:00
mailbox mailbox: xgene-slimpro: Fix potential NULL pointer dereference 2018-09-09 19:55:54 +02:00
mcb
md bcache: release dc->writeback_lock properly in bch_writeback_thread() 2018-09-09 19:56:01 +02:00
media media: Revert "[media] tvp5150: fix pad format frame height" 2018-09-09 19:55:53 +02:00
memory memory: tegra: Apply interrupts mask per SoC 2018-08-03 07:50:38 +02:00
memstick
message scsi: mptfusion: Add bounds check in mptctl_hp_targetinfo() 2018-05-25 16:17:47 +02:00
mfd mfd: hi655x: Fix regmap area declared size for hi655x 2018-09-09 19:55:58 +02:00
misc vmw_balloon: fix VMCI use when balloon built into kernel 2018-09-09 19:55:57 +02:00
mmc mmc: renesas_sdhi_internal_dmac: fix #define RST_RESERVED_BITS 2018-09-09 19:55:53 +02:00
mtd mtd: dataflash: Use ULL suffix for 64-bit constants 2018-08-24 13:09:04 +02:00
mux mux: core: fix double get_device() 2018-01-17 09:45:27 +01:00
net hv_netvsc: Fix a deadlock by getting rtnl lock earlier in netvsc_probe() 2018-09-15 09:45:26 +02:00
nfc NFC: pn533: Fix wrong GFP flag usage 2018-08-24 13:09:06 +02:00
ntb ntb_transport: Fix bug with max_mw_size parameter 2018-04-26 11:02:13 +02:00
nubus
nvdimm libnvdimm: fix ars_status output length calculation 2018-09-09 19:56:01 +02:00
nvme nvme-pci: add a memory barrier to nvme_dbbuf_update_and_check_event 2018-09-05 09:26:36 +02:00
nvmem nvmem: Don't let a NULL cell_id for nvmem_cell_get() crash us 2018-08-24 13:09:14 +02:00
of of: platform: stop accessing invalid dev in of_platform_device_destroy 2018-07-03 11:24:52 +02:00
oprofile
parisc parisc/pci: Switch LBA PCI bus from Hard Fail to Soft Fail mode 2018-05-30 07:52:28 +02:00
parport parport_pc: Add support for WCH CH382L PCI-E single parallel port card. 2018-04-08 14:26:31 +02:00
pci PCI: pciehp: Fix unprotected list iteration in IRQ handler 2018-08-24 13:09:23 +02:00
pcmcia PCMCIA / PM: Avoid noirq suspend aborts during suspend-to-idle 2018-05-30 07:52:39 +02:00
perf drivers/perf: xgene_pmu: Fix IOB SLOW PMU parser error 2018-08-24 13:08:59 +02:00
phy phy: phy-mtk-tphy: use auto instead of force to bypass utmi signals 2018-08-15 18:12:48 +02:00
pinctrl pinctrl: freescale: off by one in imx1_pinconf_group_dbg_show() 2018-09-05 09:26:39 +02:00
platform platform/x86: ideapad-laptop: Apply no_hw_rfkill to Y20-15IKBM, too 2018-09-05 09:26:36 +02:00
pnp
power power: generic-adc-battery: check for duplicate properties copied from iio channels 2018-09-05 09:26:42 +02:00
powercap
pps
ps3
ptp ptp: fix missing break in switch 2018-07-25 11:25:10 +02:00
pwm pwm: tiehrpwm: Fix disabling of output of PWMs 2018-09-09 19:56:00 +02:00
rapidio drivers/rapidio/devices/rio_mport_cdev.c: fix resource leak in error handling path in 'rio_dma_transfer()' 2017-12-14 09:53:08 +01:00
ras
regulator regulator: Don't return or expect -errno from of_map_mode() 2018-08-03 07:50:40 +02:00
remoteproc remoteproc: qcom: Fix potential device node leaks 2018-06-21 04:02:48 +09:00
reset
rpmsg rpmsg: smd: do not use mananged resources for endpoints and channels 2018-07-03 11:24:59 +02:00
rtc rtc: omap: fix potential crash on power off 2018-09-09 19:55:57 +02:00
s390 s390/qdio: reset old sbal_state flags 2018-09-05 09:26:40 +02:00
sbus
scsi scsi: core: Avoid that SCSI device removal through sysfs triggers a deadlock 2018-09-05 09:26:41 +02:00
sfi
sh
sn
soc soc: imx: gpc: restrict register range for regmap access 2018-08-24 13:09:19 +02:00
spi spi: cadence: Change usleep_range() to udelay(), for atomic context 2018-09-09 19:55:53 +02:00
spmi
ssb
staging media: staging: omap4iss: Include asm/cacheflush.h after generic includes 2018-09-05 09:26:28 +02:00
target iscsi target: fix session creation failure handling 2018-09-05 09:26:41 +02:00
tc
tee tee: check shm references are consistent in offset/size 2018-06-21 04:02:54 +09:00
thermal thermal: exynos: fix setting rising_threshold for Exynos5433 2018-08-03 07:50:37 +02:00
thunderbolt thunderbolt: Prevent crash when ICM firmware is not running 2018-04-24 09:36:29 +02:00
tty uart: fix race between uart_put_char() and uart_shutdown() 2018-09-09 19:55:56 +02:00
uio uio_hv_generic: check that host supports monitor page 2018-04-12 12:32:19 +02:00
usb usb: gadget: f_uac2: fix endianness of 'struct cntrl_*_lay3' 2018-09-05 09:26:26 +02:00
uwb
vfio vfio/type1: Fix task tracking for QEMU vCPU hotplug 2018-08-03 07:50:23 +02:00
vhost vhost: correctly check the iova range when waking virtqueue 2018-09-15 09:45:25 +02:00
video fb: fix lost console when the user unplugs a USB adapter 2018-09-09 19:56:01 +02:00
virt
virtio virtio_balloon: fix another race between migration and ballooning 2018-08-06 16:20:49 +02:00
vlynq
vme
w1 1wire: family module autoload fails because of upper/lower case mismatch. 2018-07-03 11:24:47 +02:00
watchdog watchdog: da9063: Fix updating timeout value 2018-08-03 07:50:24 +02:00
xen xen/scsiback: add error handling for xenbus_printf 2018-08-24 13:09:01 +02:00
zorro zorro: Set up z->dev.dma_mask for the DMA API 2018-05-30 07:52:30 +02:00
Kconfig
Makefile usb: build drivers/usb/common/ when USB_SUPPORT is set 2018-02-25 11:07:53 +01:00