WSL2-Linux-Kernel/drivers/block
Jack Wang 3a21777c6e block/rnbd-clt: avoid module unload race with close confirmation
We had kernel panic, it is caused by unload module and last
close confirmation.

call trace:
[1196029.743127]  free_sess+0x15/0x50 [rtrs_client]
[1196029.743128]  rtrs_clt_close+0x4c/0x70 [rtrs_client]
[1196029.743129]  ? rnbd_clt_unmap_device+0x1b0/0x1b0 [rnbd_client]
[1196029.743130]  close_rtrs+0x25/0x50 [rnbd_client]
[1196029.743131]  rnbd_client_exit+0x93/0xb99 [rnbd_client]
[1196029.743132]  __x64_sys_delete_module+0x190/0x260

And in the crashdump confirmation kworker is also running.
PID: 6943   TASK: ffff9e2ac8098000  CPU: 4   COMMAND: "kworker/4:2"
 #0 [ffffb206cf337c30] __schedule at ffffffff9f93f891
 #1 [ffffb206cf337cc8] schedule at ffffffff9f93fe98
 #2 [ffffb206cf337cd0] schedule_timeout at ffffffff9f943938
 #3 [ffffb206cf337d50] wait_for_completion at ffffffff9f9410a7
 #4 [ffffb206cf337da0] __flush_work at ffffffff9f08ce0e
 #5 [ffffb206cf337e20] rtrs_clt_close_conns at ffffffffc0d5f668 [rtrs_client]
 #6 [ffffb206cf337e48] rtrs_clt_close at ffffffffc0d5f801 [rtrs_client]
 #7 [ffffb206cf337e68] close_rtrs at ffffffffc0d26255 [rnbd_client]
 #8 [ffffb206cf337e78] free_sess at ffffffffc0d262ad [rnbd_client]
 #9 [ffffb206cf337e88] rnbd_clt_put_dev at ffffffffc0d266a7 [rnbd_client]

The problem is both code path try to close same session, which lead to
panic.

To fix it, just skip the sess if the refcount already drop to 0.

Fixes: f7a7a5c228 ("block/rnbd: client: main functionality")
Signed-off-by: Jack Wang <jinpu.wang@cloud.ionos.com>
Reviewed-by: Gioh Kim <gi-oh.kim@cloud.ionos.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
2021-01-08 08:19:18 -07:00
..
aoe aoe: don't call set_capacity from irq context 2020-11-16 08:34:14 -07:00
drbd block: switch partition lookup to use struct block_device 2020-12-01 14:53:40 -07:00
mtip32xx mtip32xx: remove the call to fsync_bdev on removal 2020-12-01 14:53:38 -07:00
null_blk null_blk: Move driver into its own directory 2020-12-07 17:36:04 -07:00
paride
rnbd block/rnbd-clt: avoid module unload race with close confirmation 2021-01-08 08:19:18 -07:00
rsxx
xen-blkback for-5.11/block-2020-12-14 2020-12-16 12:57:51 -08:00
zram for-5.11/block-2020-12-14 2020-12-16 12:57:51 -08:00
Kconfig block: rsxx: select CONFIG_CRC32 2021-01-03 14:54:43 -07:00
Makefile null_blk: Move driver into its own directory 2020-12-07 17:36:04 -07:00
amiflop.c amiflop: use separate gendisks for Amiga vs MS-DOS mode 2020-11-16 08:14:30 -07:00
ataflop.c ataflop: use a separate gendisk for each media format 2020-11-16 08:14:31 -07:00
brd.c brd: use __register_blkdev to allocate devices on demand 2020-11-16 08:14:30 -07:00
cryptoloop.c
floppy.c floppy: use a separate gendisk for each media format 2020-11-16 08:14:30 -07:00
loop.c for-5.11/drivers-2020-12-14 2020-12-16 13:09:32 -08:00
loop.h
nbd.c nbd: Respect max_part for all partition scans 2020-12-17 07:54:51 -07:00
pktcdvd.c pktcdvd: use set_capacity_and_notify 2020-11-16 08:34:14 -07:00
ps3disk.c powerpc/ps3: make system bus's remove and shutdown callbacks return void 2020-12-04 01:01:22 +11:00
ps3vram.c powerpc/ps3: make system bus's remove and shutdown callbacks return void 2020-12-04 01:01:22 +11:00
rbd.c The big ticket item here is support for msgr2 on-wire protocol, which 2020-12-17 11:53:52 -08:00
rbd_types.h
skd_main.c skd_main: remove unused including <linux/version.h> 2020-10-17 08:11:14 -06:00
skd_s1120.h
sunvdc.c
swim.c swim: don't call blk_register_region 2020-11-16 08:14:30 -07:00
swim3.c
swim_asm.S
sx8.c
umem.c
umem.h
virtio_blk.c virtio-blk: remove a spurious call to revalidate_disk_size 2020-11-16 08:34:15 -07:00
xen-blkfront.c xen: branch for v5.11-rc1b 2020-12-19 12:56:23 -08:00
xsysace.c xsysace: use platform_get_resource() and platform_get_irq_optional() 2020-10-29 08:22:33 -06:00
z2ram.c z2ram: use separate gendisk for the different modes 2020-11-16 08:14:31 -07:00