linux/drivers
Jiazi Li 2e3c211e7e BACKPORT: dm: fix NULL pointer issue when free bio
dm_io_dec_pending call end_io_acct first, will dec md in-flight
pending count. If a task is swapping table at same time.
task1                             task2
do_resume
 ->do_suspend
  ->dm_wait_for_completion
                                  bio_endio
				   ->clone_endio
				    ->dm_io_dec_pending
				     ->end_io_acct
				      ->wakeup task1
 ->dm_swap_table
  ->__bind
   ->__bind_mempools
    ->bioset_exit
     ->mempool_exit
                                     ->free_io
mempool->elements is NULL, and lead to following crash:
[ 67.330330] Unable to handle kernel NULL pointer dereference at virtual
address 0000000000000000
......
[ 67.330494] pstate: 80400085 (Nzcv daIf +PAN -UAO)
[ 67.330510] pc : mempool_free+0x70/0xa0
[ 67.330515] lr : mempool_free+0x4c/0xa0
[ 67.330520] sp : ffffff8008013b20
[ 67.330524] x29: ffffff8008013b20 x28: 0000000000000004
[ 67.330530] x27: ffffffa8c2ff40a0 x26: 00000000ffff1cc8
[ 67.330535] x25: 0000000000000000 x24: ffffffdada34c800
[ 67.330541] x23: 0000000000000000 x22: ffffffdada34c800
[ 67.330547] x21: 00000000ffff1cc8 x20: ffffffd9a1304d80
[ 67.330552] x19: ffffffdada34c970 x18: 000000b312625d9c
[ 67.330558] x17: 00000000002dcfbf x16: 00000000000006dd
[ 67.330563] x15: 000000000093b41e x14: 0000000000000010
[ 67.330569] x13: 0000000000007f7a x12: 0000000034155555
[ 67.330574] x11: 0000000000000001 x10: 0000000000000001
[ 67.330579] x9 : 0000000000000000 x8 : 0000000000000000
[ 67.330585] x7 : 0000000000000000 x6 : ffffff80148b5c1a
[ 67.330590] x5 : ffffff8008013ae0 x4 : 0000000000000001
[ 67.330596] x3 : ffffff80080139c8 x2 : ffffff801083bab8
[ 67.330601] x1 : 0000000000000000 x0 : ffffffdada34c970
[ 67.330609] Call trace:
[ 67.330616] mempool_free+0x70/0xa0
[ 67.330627] bio_put+0xf8/0x110
[ 67.330638] dec_pending+0x13c/0x230
[ 67.330644] clone_endio+0x90/0x180
[ 67.330649] bio_endio+0x198/0x1b8
[ 67.330655] dec_pending+0x190/0x230
[ 67.330660] clone_endio+0x90/0x180
[ 67.330665] bio_endio+0x198/0x1b8
[ 67.330673] blk_update_request+0x214/0x428
[ 67.330683] scsi_end_request+0x2c/0x300
[ 67.330688] scsi_io_completion+0xa0/0x710
[ 67.330695] scsi_finish_command+0xd8/0x110
[ 67.330700] scsi_softirq_done+0x114/0x148
[ 67.330708] blk_done_softirq+0x74/0xd0
[ 67.330716] __do_softirq+0x18c/0x374
[ 67.330724] irq_exit+0xb4/0xb8
[ 67.330732] __handle_domain_irq+0x84/0xc0
[ 67.330737] gic_handle_irq+0x148/0x1b0
[ 67.330744] el1_irq+0xe8/0x190
[ 67.330753] lpm_cpuidle_enter+0x4f8/0x538
[ 67.330759] cpuidle_enter_state+0x1fc/0x398
[ 67.330764] cpuidle_enter+0x18/0x20
[ 67.330772] do_idle+0x1b4/0x290
[ 67.330778] cpu_startup_entry+0x20/0x28
[ 67.330786] secondary_start_kernel+0x160/0x170

Move end_io_acct after free_io to fix this issue.

Bug: 228982905
Link: https://lore.kernel.org/dm-devel/1632916768-22379-1-git-send-email-lijiazi@xiaomi.com/T/#u
[Akilesh: Resolved merge conflict in drivers/md/dm.c]
Signed-off-by: Jiazi Li <lijiazi@xiaomi.com>
Signed-off-by: Akilesh Kailash <akailash@google.com>
(cherry picked from commit d208b89401)
Change-Id: I9f122cab2af3b961c472b8cf2087399c63c28de1
2022-04-27 22:40:43 +00:00
..
accessibility speakup-dectlk: Restore pitch setting 2022-02-16 12:54:30 +01:00
acpi This is the 5.10.101 stable release 2022-02-16 15:16:06 +01:00
amba This is the 5.10.78 stable release 2021-11-06 14:22:24 +01:00
android ANDROID: add for tuning readahead size 2022-04-24 10:53:17 +00:00
ata libata: if T_LENGTH is zero, dma direction should be DMA_NONE 2021-12-22 09:30:58 +01:00
atm
auxdisplay auxdisplay: ht16k33: Fix frame buffer device blanking 2021-11-18 14:04:24 +01:00
base Merge tag 'android12-5.10.101_r00' into android12-5.10 2022-03-21 14:29:02 +01:00
bcma bcma: Fix memory leak for internally-handled cores 2021-09-15 09:50:45 +02:00
block BACKPORT: virtio-blk: Use blk_validate_block_size() to validate block size 2022-04-26 09:42:49 +00:00
bluetooth This is the 5.10.94 stable release 2022-01-27 11:49:22 +01:00
bus Revert "drivers: bus: simple-pm-bus: Add support for probing simple bus only devices" 2022-02-05 12:37:55 +01:00
cdrom
char This is the 5.10.94 stable release 2022-01-27 11:49:22 +01:00
clk This is the 5.10.94 stable release 2022-01-27 11:49:22 +01:00
clocksource This is the 5.10.101 stable release 2022-02-16 15:16:06 +01:00
connector
counter counter: stm32-lptimer-cnt: remove iio counter abi 2022-01-27 10:54:08 +01:00
cpufreq This is the 5.10.94 stable release 2022-01-27 11:49:22 +01:00
cpuidle This is the 5.10.80 stable release 2021-11-19 11:50:41 +01:00
crypto This is the 5.10.94 stable release 2022-01-27 11:49:22 +01:00
dax
dca
devfreq
dio
dma This is the 5.10.94 stable release 2022-01-27 11:49:22 +01:00
dma-buf Merge tag 'android12-5.10.101_r00' into android12-5.10 2022-03-21 14:29:02 +01:00
edac EDAC/xgene: Fix deferred probing 2022-02-08 18:30:40 +01:00
eisa
extcon extcon: intel-mrfld: Sync hardware and software state on init 2021-07-19 09:45:00 +02:00
firewire
firmware Merge tag 'android12-5.10.101_r00' into android12-5.10 2022-03-21 14:29:02 +01:00
fpga fpga: machxo2-spi: Fix missing error code in machxo2_write_complete() 2021-09-30 10:11:04 +02:00
fsi fsi: Add missing MODULE_DEVICE_TABLE 2021-07-20 16:05:42 +02:00
gnss
gpio This is the 5.10.101 stable release 2022-02-16 15:16:06 +01:00
gpu This is the 5.10.101 stable release 2022-02-16 15:16:06 +01:00
greybus
hid This is the 5.10.94 stable release 2022-01-27 11:49:22 +01:00
hsi HSI: core: Fix return freed object in hsi_new_client 2022-01-27 10:54:12 +01:00
hv hyperv/vmbus: include linux/bitops.h 2021-11-18 14:03:42 +01:00
hwmon This is the 5.10.101 stable release 2022-02-16 15:16:06 +01:00
hwspinlock
hwtracing UPSTREAM: coresight: trbe: Fix incorrect access of the sink specific data 2022-02-11 17:30:23 -08:00
i2c This is the 5.10.94 stable release 2022-01-27 11:49:22 +01:00
i3c
ide
idle
iio iio: adc: ti-adc081c: Partial revert of removal of ACPI IDs 2022-01-27 10:53:43 +01:00
infiniband This is the 5.10.99 stable release 2022-02-09 12:14:04 +01:00
input This is the 5.10.91 stable release 2022-01-11 15:46:18 +01:00
interconnect Revert "treewide: Change list_sort to use const pointers" 2021-10-04 11:07:40 +02:00
iommu BACKPORT: iommu: Extend mutex lock scope in iommu_probe_device() 2022-04-19 19:55:09 -07:00
ipack ipack: ipoctal: fix module reference leak 2021-10-06 15:56:01 +02:00
irqchip Merge branch 'android12-5.10' into android12-5.10-lts 2022-02-09 18:16:30 +01:00
isdn mISDN: change function names to avoid conflicts 2022-01-11 15:25:02 +01:00
leds leds: trigger: audio: Add an activate callback to ensure the initial brightness is set 2021-09-15 09:50:36 +02:00
lightnvm
macintosh
mailbox soc: mediatek: cmdq: add address shift in jump 2021-09-18 13:40:16 +02:00
mcb mcb: fix error handling in mcb_alloc_bus() 2021-09-30 10:11:00 +02:00
md BACKPORT: dm: fix NULL pointer issue when free bio 2022-04-27 22:40:43 +00:00
media BACKPORT: media: v4l2-mem2mem: Apply DST_QUEUE_OFF_BASE on MMAP buffers across ioctls 2022-04-22 07:38:57 +00:00
memory This is the 5.10.94 stable release 2022-01-27 11:49:22 +01:00
memstick memstick: jmb38x_ms: use appropriate free function in jmb38x_ms_alloc_host() 2021-11-18 14:04:07 +01:00
message
mfd mfd: atmel-flexcom: Use .resume_noirq 2022-01-27 10:53:51 +01:00
misc This is the 5.10.101 stable release 2022-02-16 15:16:06 +01:00
mmc Merge tag 'android12-5.10.101_r00' into android12-5.10 2022-03-21 14:29:02 +01:00
most most: fix control-message timeouts 2021-11-18 14:03:51 +01:00
mtd This is the 5.10.96 stable release 2022-02-07 11:17:58 +01:00
mux
net UPSTREAM: sr9700: sanity check for packet length 2022-03-24 10:49:22 +00:00
nfc NFC: st21nfca: Fix memory leak in device probe and remove 2022-01-05 12:40:31 +01:00
ntb NTB: perf: Fix an error code in perf_setup_inbuf() 2021-09-22 12:28:02 +02:00
nubus
nvdimm libnvdimm/pmem: Fix crash triggered when I/O in-flight during unbind 2021-09-18 13:40:36 +02:00
nvme This is the 5.10.101 stable release 2022-02-16 15:16:06 +01:00
nvmem nvmem: core: set size for sysfs bin file 2022-01-27 10:54:22 +01:00
of This is the 5.10.94 stable release 2022-01-27 11:49:22 +01:00
opp This is the 5.10.80 stable release 2021-11-19 11:50:41 +01:00
oprofile
parisc parisc: pdc_stable: Fix memory leak in pdcs_register_pathentries 2022-01-27 10:54:31 +01:00
parport parport: remove non-zero check on count 2021-09-18 13:40:34 +02:00
pci This is the 5.10.97 stable release 2022-02-08 10:08:24 +01:00
pcmcia pcmcia: fix setting of kthread task states 2022-01-27 10:54:03 +01:00
perf
phy phy: ti: Fix missing sentinel for clk_div_table 2022-02-16 12:54:30 +01:00
pinctrl This is the 5.10.99 stable release 2022-02-09 12:14:04 +01:00
platform This is the 5.10.90 stable release 2022-01-05 13:23:32 +01:00
pnp
power Merge branch 'android12-5.10' into android12-5.10-lts 2022-02-09 18:16:30 +01:00
powercap
pps
ps3
ptp ptp_pch: Load module automatically if ID matches 2021-10-13 10:04:27 +02:00
pwm This is the 5.10.69 stable release 2021-09-30 18:36:17 +02:00
rapidio
ras
regulator This is the 5.10.94 stable release 2022-01-27 11:49:22 +01:00
remoteproc FROMLIST: remoteproc: Use unbounded workqueue for recovery work 2022-04-14 08:01:30 +00:00
reset This is the 5.10.80 stable release 2021-11-19 11:50:41 +01:00
rpmsg This is the 5.10.96 stable release 2022-02-07 11:17:58 +01:00
rtc This is the 5.10.99 stable release 2022-02-09 12:14:04 +01:00
s390 This is the 5.10.96 stable release 2022-02-07 11:17:58 +01:00
sbus
scsi Merge tag 'android12-5.10.101_r00' into android12-5.10 2022-03-21 14:29:02 +01:00
sfi
sh maple: fix wrong return value of maple_bus_init(). 2021-11-26 10:39:12 +01:00
siox
slimbus slimbus: ngd: reset dma setup during runtime pm 2021-08-26 08:35:55 -04:00
soc This is the 5.10.99 stable release 2022-02-09 12:14:04 +01:00
soundwire soundwire: debugfs: use controller id and link_id for debugfs 2021-11-18 14:04:16 +01:00
spi This is the 5.10.99 stable release 2022-02-09 12:14:04 +01:00
spmi
ssb
staging This is the 5.10.101 stable release 2022-02-16 15:16:06 +01:00
target This is the 5.10.101 stable release 2022-02-16 15:16:06 +01:00
tc
tee tee: fix put order in teedev_close_context() 2022-01-27 10:53:49 +01:00
thermal This is the 5.10.94 stable release 2022-01-27 11:49:22 +01:00
thunderbolt thunderbolt: Runtime PM activate both ends of the device link 2022-01-27 10:54:14 +01:00
tty This is the 5.10.101 stable release 2022-02-16 15:16:06 +01:00
uio
usb ANDROID: usb: gadget: f_accessory: add compat_ioctl support 2022-03-25 08:16:04 +00:00
vdpa vdpa/mlx5: Fix wrong configuration of virtio_version_1_0 2022-01-27 10:54:33 +01:00
vfio Merge 5.10.67 into android12-5.10-lts 2021-09-30 12:21:03 +02:00
vhost vdpa: check that offsets are within bounds 2021-12-22 09:30:51 +01:00
video This is the 5.10.99 stable release 2022-02-09 12:14:04 +01:00
virt
virtio This is the 5.10.94 stable release 2022-01-27 11:49:22 +01:00
visorbus
vlynq
vme
w1 w1: Misuse of get_user()/put_user() reported by sparse 2022-01-27 10:54:22 +01:00
watchdog This is the 5.10.80 stable release 2021-11-19 11:50:41 +01:00
xen xen/gntdev: fix unmap notification order 2022-01-27 10:54:24 +01:00
zorro
Kconfig
Makefile