android_kernel_oneplus_msm8998/drivers
Yufen Yu a7d04d5862 scsi: core: try to get module before removing device
commit 77c301287ebae86cc71d03eb3806f271cb14da79 upstream.

We have a test case like block/001 in blktests, which will create a scsi
device by loading scsi_debug module and then try to delete the device by
sysfs interface. At the same time, it may remove the scsi_debug module.

And getting a invalid paging request BUG_ON as following:

[   34.625854] BUG: unable to handle page fault for address: ffffffffa0016bb8
[   34.629189] Oops: 0000 [] SMP PTI
[   34.629618] CPU: 1 PID: 450 Comm: bash Tainted: G        W         5.4.0-rc3+ 
[   34.632524] RIP: 0010:scsi_proc_hostdir_rm+0x5/0xa0
[   34.643555] CR2: ffffffffa0016bb8 CR3: 000000012cd88000 CR4: 00000000000006e0
[   34.644545] Call Trace:
[   34.644907]  scsi_host_dev_release+0x6b/0x1f0
[   34.645511]  device_release+0x74/0x110
[   34.646046]  kobject_put+0x116/0x390
[   34.646559]  put_device+0x17/0x30
[   34.647041]  scsi_target_dev_release+0x2b/0x40
[   34.647652]  device_release+0x74/0x110
[   34.648186]  kobject_put+0x116/0x390
[   34.648691]  put_device+0x17/0x30
[   34.649157]  scsi_device_dev_release_usercontext+0x2e8/0x360
[   34.649953]  execute_in_process_context+0x29/0x80
[   34.650603]  scsi_device_dev_release+0x20/0x30
[   34.651221]  device_release+0x74/0x110
[   34.651732]  kobject_put+0x116/0x390
[   34.652230]  sysfs_unbreak_active_protection+0x3f/0x50
[   34.652935]  sdev_store_delete.cold.4+0x71/0x8f
[   34.653579]  dev_attr_store+0x1b/0x40
[   34.654103]  sysfs_kf_write+0x3d/0x60
[   34.654603]  kernfs_fop_write+0x174/0x250
[   34.655165]  __vfs_write+0x1f/0x60
[   34.655639]  vfs_write+0xc7/0x280
[   34.656117]  ksys_write+0x6d/0x140
[   34.656591]  __x64_sys_write+0x1e/0x30
[   34.657114]  do_syscall_64+0xb1/0x400
[   34.657627]  entry_SYSCALL_64_after_hwframe+0x44/0xa9
[   34.658335] RIP: 0033:0x7f156f337130

During deleting scsi target, the scsi_debug module have been removed. Then,
sdebug_driver_template belonged to the module cannot be accessd, resulting
in scsi_proc_hostdir_rm() BUG_ON.

To fix the bug, we add scsi_device_get() in sdev_store_delete() to try to
increase refcount of module, avoiding the module been removed.

Cc: stable@vger.kernel.org
Link: https://lore.kernel.org/r/20191015130556.18061-1-yuyufen@huawei.com
Signed-off-by: Yufen Yu <yuyufen@huawei.com>
Reviewed-by: Bart Van Assche <bvanassche@acm.org>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2019-10-29 09:13:26 +01:00
..
accessibility
acpi ACPI: custom_method: fix memory leaks 2019-10-05 12:27:49 +02:00
amba
android ANDROID: binder: synchronize_rcu() when using POLLFREE. 2019-10-07 21:01:03 +02:00
ata libata: add SG safety checks in SFF pio transfers 2019-09-06 10:18:08 +02:00
atm Kconfig: Fix the reference to the IDT77105 Phy driver in the description of ATM_NICSTAR_USE_IDT77105 2019-09-21 07:12:50 +02:00
auxdisplay
base base: soc: Export soc_device_register/unregister APIs 2019-10-05 12:27:46 +02:00
bcma
block loop: Add LOOP_SET_DIRECT_IO to compat ioctl 2019-10-29 09:13:21 +01:00
bluetooth Bluetooth: btrtl: Additional Realtek 8822CE Bluetooth devices 2019-10-05 12:27:40 +02:00
bus
cdrom cdrom: Fix race condition in cdrom_sysctl_register 2019-04-27 09:33:52 +02:00
char ipmi_si: Only schedule continuously in the thread in maintenance mode 2019-10-07 21:00:59 +02:00
clk clk: sirf: Don't reference clk_init_data after registration 2019-10-07 21:01:00 +02:00
clocksource clocksource/drivers/exynos_mct: Clear timer interrupt when shutdown 2019-03-23 08:44:35 +01:00
connector
cpufreq cpufreq/pasemi: fix use-after-free in pas_cpufreq_cpu_init() 2019-08-25 10:52:47 +02:00
cpuidle cpuidle: big.LITTLE: fix refcount leak 2019-02-20 10:13:09 +01:00
crypto crypto: caam - fix concurrency issue in givencrypt descriptor 2019-10-17 13:40:56 -07:00
dca
devfreq PM / devfreq: tegra: fix error return code in tegra_devfreq_probe() 2018-11-10 07:41:40 -08:00
dio
dma dmaengine: ti: edma: Do not reset reserved paRAM slots 2019-10-05 12:27:50 +02:00
dma-buf
edac EDAC: Fix global-out-of-bounds write when setting edac_mc_poll_msec 2019-08-04 09:34:48 +02:00
eisa
extcon extcon: arizona: Disable mic detect if running when driver is removed 2019-06-11 12:24:01 +02:00
firewire firewire-ohci: work around oversized DMA reads on JMicron controllers 2018-05-30 07:48:52 +02:00
firmware efi: cper: print AER info of PCIe fatal error 2019-10-05 12:27:47 +02:00
fmc
fpga
gpio gpio: omap: ensure irq is enabled before wakeup 2019-08-04 09:34:45 +02:00
gpu drm/amdgpu: Check for valid number of registers to read 2019-10-17 13:40:55 -07:00
hid HID: apple: Fix stuck function keys when using FN 2019-10-07 21:01:02 +02:00
hsi
hv Drivers: hv: vmbus: Return -EINVAL for the sys files for unopened channels 2019-01-13 10:05:27 +01:00
hwmon hwmon: (acpi_power_meter) Change log level for 'unsafe software power cap' 2019-10-05 12:27:49 +02:00
hwspinlock
hwtracing stm class: Fix a double free of stm_source_device 2019-09-06 10:18:17 +02:00
i2c i2c: riic: Clear NACK in tend isr 2019-10-05 12:27:55 +02:00
ide ide: pmac: add of_node_put() 2018-12-21 14:09:52 +01:00
idle
iio iio: light: opt3001: fix mutex unlock race 2019-10-17 13:41:03 -07:00
infiniband IB/mlx4: Fix memory leaks 2019-09-10 10:29:48 +01:00
input Input: psmouse - fix build error of multiple definition 2019-08-25 10:53:03 +02:00
iommu iommu/amd: Move iommu_init_pci() to .init section 2019-08-25 10:53:05 +02:00
ipack
irqchip irqchip/gic-v3-its: Fix LPI release for Multi-MSI devices 2019-10-05 12:27:39 +02:00
isdn mISDN: enforce CAP_NET_RAW for raw sockets 2019-10-05 12:27:42 +02:00
leds leds: leds-lp5562 allow firmware files up to the maximum length 2019-10-05 12:27:44 +02:00
lguest
lightnvm
macintosh macintosh/via-pmu: Add missing mmio accessors 2018-09-19 22:48:57 +02:00
mailbox mailbox: handle failed named mailbox channel request 2019-08-04 09:34:58 +02:00
mcb
md md/raid6: Set R5_ReadError when there is read failure on parity disk 2019-10-05 12:27:54 +02:00
media media: stkwebcam: fix runtime PM after driver unbind 2019-10-17 13:41:05 -07:00
memory memory: tegra: Fix integer overflow on tick value calculation 2019-06-11 12:23:46 +02:00
memstick memstick: Fix error cleanup path of memstick_init 2019-08-04 09:34:56 +02:00
message scsi: mptfusion: Add bounds check in mptctl_hp_targetinfo() 2018-05-30 07:48:58 +02:00
mfd mfd: intel-lpss: Remove D3cold delay 2019-10-07 21:01:01 +02:00
misc VMCI: Release resource if the work is already queued 2019-09-06 10:18:17 +02:00
mmc mmc: sdhci: Fix incorrect switch to HS mode 2019-10-05 12:27:50 +02:00
mtd mtd: cfi_cmdset_0002: Use chip_good() to retry in do_write_oneword() 2019-10-05 12:27:37 +02:00
net net: bcmgenet: Set phydev->dev_flags only for internal PHYs 2019-10-29 09:13:22 +01:00
nfc st_nci_hci_connectivity_event_received: null check the allocation 2019-09-06 10:18:05 +02:00
ntb ntb_transport: Fix bug with max_mw_size parameter 2018-05-30 07:48:55 +02:00
nubus
nvdimm libnvdimm/btt: Fix a kmemdup failure check 2019-05-16 19:45:05 +02:00
nvme nvme-pci: initialize queue memory before interrupts 2018-07-11 16:03:47 +02:00
nvmem nvmem: core: fix read buffer in place 2019-06-22 08:18:20 +02:00
of of: add helper to lookup compatible child node 2018-12-01 09:46:35 +01:00
oprofile
parisc parisc: Disable HP HSC-PCI Cards to prevent kernel crash 2019-10-05 12:27:52 +02:00
parport parport: Fix mem leak in parport_register_dev_model 2019-07-10 09:56:31 +02:00
pci PCI: sysfs: Ignore lockdep for remove attribute 2019-08-04 09:34:57 +02:00
pcmcia pcmcia: Implement CLKRUN protocol disabling for Ricoh bridges 2018-11-21 09:27:30 +01:00
perf
phy phy: renesas: rcar-gen2: Fix memory leak at error paths 2019-08-04 09:34:57 +02:00
pinctrl pinctrl: tegra: Fix write barrier placement in pmx_writel 2019-10-07 21:01:00 +02:00
platform platform/chrome: cros_ec_proto: check for NULL transfer function 2019-06-22 08:18:20 +02:00
pnp
power power: supply: sysfs: prevent endless uevent loop with CONFIG_POWER_SUPPLY_DEBUG 2019-06-11 12:23:49 +02:00
powercap
pps drivers/pps/pps.c: clear offset flags in PPS_SETPARAMS ioctl 2019-08-04 09:35:02 +02:00
ps3
ptp ptp: check gettime64 return code in PTP_SYS_OFFSET ioctl 2019-02-20 10:13:05 +01:00
pwm pwm: Fix deadlock warning when removing PWM device 2019-06-22 08:18:21 +02:00
rapidio
ras
regulator regulator: s2mps11: Fix buck7 and buck8 wrong voltages 2019-08-04 09:34:50 +02:00
remoteproc
reset
rpmsg
rtc rtc: 88pm860x: prevent use-after-free on device remove 2019-06-11 12:23:54 +02:00
s390 s390/cio: exclude subchannels with no parent from pseudo check 2019-10-17 13:40:53 -07:00
sbus drivers/sbus/char: add of_node_put() 2018-12-21 14:09:52 +01:00
scsi scsi: core: try to get module before removing device 2019-10-29 09:13:26 +01:00
sfi
sh
sn
soc soc: mediatek: pwrap: Zero initialize rdata in pwrap_init_cipher 2019-06-22 08:18:20 +02:00
spi spi: bcm2835aux: fix corruptions for longer spi transfers 2019-09-10 10:29:50 +01:00
spmi
ssb ssb: Fix possible NULL pointer dereference in ssb_host_pcmcia_exit 2019-06-11 12:23:53 +02:00
staging Staging: fbtft: fix memory leak in fbtft_framebuffer_alloc 2019-10-17 13:41:04 -07:00
target scsi: target/iscsi: Avoid iscsit_release_commands_from_conn() deadlock 2019-03-23 08:44:35 +01:00
tc TC: Set DMA masks for devices 2018-11-21 09:27:36 +01:00
thermal thermal: Fix use-after-free when unregistering thermal zone device 2019-10-17 13:40:55 -07:00
thunderbolt
tty serial: uartlite: fix exit path null pointer 2019-10-17 13:41:00 -07:00
uio uio: Fix an Oops on load 2018-11-27 16:08:02 +01:00
usb USB: ldusb: fix read info leaks 2019-10-29 09:13:26 +01:00
uwb uwb: hwa-rc: fix memory leak at probe 2018-10-10 08:52:04 +02:00
vfio vfio_pci: Restore original state on release 2019-10-07 21:01:00 +02:00
vhost vhost: make sure log_num < in_num 2019-09-16 08:13:36 +02:00
video video: ssd1307fb: Start page range at page_offset 2019-10-07 21:00:59 +02:00
virt drivers/virt/fsl_hypervisor.c: prevent integer overflow in ioctl 2019-05-16 19:45:18 +02:00
virtio virtio_balloon: fix another race between migration and ballooning 2018-08-06 16:24:42 +02:00
vlynq
vme
w1 w1: fix the resume command API 2019-06-11 12:23:55 +02:00
watchdog watchdog: bcm2835_wdt: Fix module autoload 2019-09-06 10:18:15 +02:00
xen xen/pci: reserve MCFG areas earlier 2019-10-17 13:40:55 -07:00
zorro zorro: Set up z->dev.dma_mask for the DMA API 2018-05-30 07:49:11 +02:00
Kconfig
Makefile