Jens Axboe
2d097c5021
sr: get/drop reference to device in revalidate and check_events
...
We can't just use scsi_cd() to get the scsi_cd structure, we have
to grab a live reference to the device. For both callbacks, we're
not inside an open where we already hold a reference to the device.
This fixes device removal/addition under concurrent device access,
which otherwise could result in the below oops.
NULL pointer dereference at 0000000000000010
PGD 0 P4D 0
Oops: 0000 [#1 ] PREEMPT SMP
Modules linked in:
sr 12:0:0:0: [sr2] scsi-1 drive
scsi_debug crc_t10dif crct10dif_generic crct10dif_common nvme nvme_core sb_edac xl
sr 12:0:0:0: Attached scsi CD-ROM sr2
sr_mod cdrom btrfs xor zstd_decompress zstd_compress xxhash lzo_compress zlib_defc
sr 12:0:0:0: Attached scsi generic sg7 type 5
igb ahci libahci i2c_algo_bit libata dca [last unloaded: crc_t10dif]
CPU: 43 PID: 4629 Comm: systemd-udevd Not tainted 4.16.0+ #650
Hardware name: Dell Inc. PowerEdge T630/0NT78X, BIOS 2.3.4 11/09/2016
RIP: 0010:sr_block_revalidate_disk+0x23/0x190 [sr_mod]
RSP: 0018:ffff883ff357bb58 EFLAGS: 00010292
RAX: ffffffffa00b07d0 RBX: ffff883ff3058000 RCX: ffff883ff357bb66
RDX: 0000000000000003 RSI: 0000000000007530 RDI: ffff881fea631000
RBP: 0000000000000000 R08: ffff881fe4d38400 R09: 0000000000000000
R10: 0000000000000000 R11: 00000000000001b6 R12: 000000000800005d
R13: 000000000800005d R14: ffff883ffd9b3790 R15: 0000000000000000
FS: 00007f7dc8e6d8c0(0000) GS:ffff883fff340000(0000) knlGS:0000000000000000
CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 0000000000000010 CR3: 0000003ffda98005 CR4: 00000000003606e0
DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
Call Trace:
? __invalidate_device+0x48/0x60
check_disk_change+0x4c/0x60
sr_block_open+0x16/0xd0 [sr_mod]
__blkdev_get+0xb9/0x450
? iget5_locked+0x1c0/0x1e0
blkdev_get+0x11e/0x320
? bdget+0x11d/0x150
? _raw_spin_unlock+0xa/0x20
? bd_acquire+0xc0/0xc0
do_dentry_open+0x1b0/0x320
? inode_permission+0x24/0xc0
path_openat+0x4e6/0x1420
? cpumask_any_but+0x1f/0x40
? flush_tlb_mm_range+0xa0/0x120
do_filp_open+0x8c/0xf0
? __seccomp_filter+0x28/0x230
? _raw_spin_unlock+0xa/0x20
? __handle_mm_fault+0x7d6/0x9b0
? list_lru_add+0xa8/0xc0
? _raw_spin_unlock+0xa/0x20
? __alloc_fd+0xaf/0x160
? do_sys_open+0x1a6/0x230
do_sys_open+0x1a6/0x230
do_syscall_64+0x5a/0x100
entry_SYSCALL_64_after_hwframe+0x3d/0xa2
Reviewed-by: Lee Duncan <lduncan@suse.com>
Reviewed-by: Jan Kara <jack@suse.cz>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
2018-04-11 11:26:09 -06:00
..
2018-04-05 15:05:53 -07:00
2018-04-03 17:38:39 -07:00
2017-11-21 16:35:54 -08:00
2018-03-21 18:46:30 -04:00
2018-01-22 20:04:01 -05:00
2017-11-21 16:35:54 -08:00
2018-03-15 00:35:43 -04:00
2018-01-30 21:27:02 -05:00
2018-01-04 01:13:28 -05:00
2018-04-03 17:38:39 -07:00
2018-01-08 21:45:48 -05:00
2018-01-10 23:24:58 -05:00
2018-04-03 17:38:39 -07:00
2017-06-20 12:18:27 +02:00
2018-03-19 22:54:47 -04:00
2017-11-21 15:57:07 -08:00
2018-01-22 20:03:57 -05:00
2018-03-21 18:34:21 -04:00
2018-03-15 00:52:33 -04:00
2017-12-04 22:56:04 -05:00
2018-02-13 21:37:06 -05:00
2018-02-13 21:37:01 -05:00
2018-04-03 17:38:39 -07:00
2018-03-14 23:36:37 -04:00
2018-04-05 15:05:53 -07:00
2018-04-05 15:05:53 -07:00
2018-03-01 21:07:48 -05:00
2017-12-18 13:55:43 -07:00
2018-03-19 22:54:47 -04:00
2017-11-21 16:35:54 -08:00
2018-02-13 21:37:02 -05:00
2018-04-05 15:05:53 -07:00
2018-04-05 15:05:53 -07:00
2018-04-03 17:38:39 -07:00
2018-04-05 15:05:53 -07:00
2017-11-02 11:10:55 +01:00
2018-03-26 11:13:09 +02:00
2018-04-03 17:38:39 -07:00
2017-10-25 05:40:22 -04:00
2017-12-04 20:32:53 -05:00
2017-12-04 20:32:53 -05:00
2017-12-04 20:32:53 -05:00
2017-08-25 17:21:11 -04:00
2017-11-02 11:10:55 +01:00
2017-08-25 17:21:10 -04:00
2017-11-02 11:10:55 +01:00
2017-08-25 17:21:10 -04:00
2017-11-02 11:10:55 +01:00
2017-08-25 17:21:11 -04:00
2017-11-02 11:10:55 +01:00
2017-08-24 22:29:07 -04:00
2017-11-02 11:10:55 +01:00
2018-03-15 00:26:54 -04:00
2017-11-02 11:10:55 +01:00
2017-08-25 17:21:11 -04:00
2018-03-01 21:10:36 -05:00
2017-11-02 11:10:55 +01:00
2017-08-24 22:29:06 -04:00
2017-11-02 11:10:55 +01:00
2017-10-27 02:22:00 -07:00
2017-11-02 11:10:55 +01:00
2017-08-25 17:21:11 -04:00
2018-04-05 15:05:53 -07:00
2018-03-15 00:25:37 -04:00
2017-08-10 19:55:35 -04:00
2017-11-02 11:10:55 +01:00
2017-08-25 17:21:11 -04:00
2017-11-02 11:10:55 +01:00
2017-11-02 11:10:55 +01:00
2017-11-02 11:10:55 +01:00
2017-10-27 02:22:00 -07:00
2018-03-17 14:45:23 -06:00
2017-08-25 17:21:10 -04:00
2017-11-02 11:10:55 +01:00
2018-04-03 17:38:39 -07:00
2017-10-25 04:55:18 -04:00
2018-04-03 17:38:39 -07:00
2018-03-14 23:31:13 -04:00
2017-08-25 17:21:10 -04:00
2017-08-25 17:21:11 -04:00
2017-11-02 11:10:55 +01:00
2018-03-12 21:16:58 -04:00
2018-02-13 21:49:14 -05:00
2018-03-15 00:26:30 -04:00
2017-06-20 12:18:27 +02:00
2018-04-05 14:27:02 -07:00
2018-03-12 22:05:43 -04:00
2018-03-19 22:54:47 -04:00
2017-08-22 16:34:36 +02:00
2018-01-03 23:10:06 -05:00
2018-01-03 23:10:06 -05:00
2017-08-07 14:04:02 -04:00
2017-11-02 11:10:55 +01:00
2017-08-10 19:55:34 -04:00
2017-08-25 17:21:11 -04:00
2018-04-03 17:38:39 -07:00
2017-08-07 14:04:01 -04:00
2017-11-02 11:10:55 +01:00
2017-11-02 11:10:55 +01:00
2018-03-19 22:54:47 -04:00
2017-11-02 11:10:55 +01:00
2017-11-21 15:57:07 -08:00
2017-11-14 16:23:44 -08:00
2017-11-02 11:10:55 +01:00
2017-11-02 11:10:55 +01:00
2017-09-01 11:59:17 +02:00
2017-11-02 11:10:55 +01:00
2017-10-16 22:38:44 -04:00
2017-11-02 11:10:55 +01:00
2017-11-02 11:10:55 +01:00
2017-08-24 22:29:01 -04:00
2017-11-02 11:10:55 +01:00
2018-02-13 21:49:15 -05:00
2018-02-13 21:49:15 -05:00
2017-12-04 20:32:52 -05:00
2017-11-02 11:10:55 +01:00
2017-10-05 15:01:17 +02:00
2017-10-05 15:01:17 +02:00
2017-08-25 17:21:11 -04:00
2017-11-02 11:10:55 +01:00
2017-08-25 17:21:11 -04:00
2017-08-28 22:15:46 -04:00
2017-11-02 11:10:55 +01:00
2018-02-12 11:43:25 -05:00
2017-12-11 21:39:39 -05:00
2018-04-05 15:05:53 -07:00
2018-01-08 22:27:32 -05:00
2018-03-21 18:34:23 -04:00
2017-12-07 21:32:03 -05:00
2018-04-03 17:38:39 -07:00
2017-08-25 17:08:07 -04:00
2017-11-02 11:10:55 +01:00
2018-04-05 15:05:53 -07:00
2017-11-14 16:23:44 -08:00
2017-12-07 21:13:45 -05:00
2017-11-02 11:10:55 +01:00
2017-11-02 11:10:55 +01:00
2017-12-14 22:30:24 -05:00
2018-04-05 15:05:53 -07:00
2017-11-02 11:10:55 +01:00
2018-01-03 22:51:02 -05:00
2017-11-14 16:23:44 -08:00
2018-03-13 11:40:24 -06:00
2018-02-15 18:20:14 -05:00
2017-11-07 09:04:32 -08:00
2018-02-27 22:26:12 -05:00
2017-11-02 11:10:55 +01:00
2017-11-02 11:10:55 +01:00
2018-04-03 17:38:39 -07:00
2018-04-05 14:27:02 -07:00
2018-01-08 22:27:32 -05:00
2017-11-02 11:10:55 +01:00
2017-12-04 22:55:59 -05:00
2018-02-11 14:34:03 -08:00
2017-08-25 17:21:10 -04:00
2017-11-02 11:10:55 +01:00
2017-11-02 11:10:55 +01:00
2018-04-11 11:26:09 -06:00
2017-11-02 11:10:55 +01:00
2017-11-02 11:10:55 +01:00
2017-12-04 20:32:53 -05:00
2017-11-02 11:10:55 +01:00
2018-04-03 17:38:39 -07:00
2017-08-25 17:21:11 -04:00
2018-03-12 22:05:43 -04:00
2017-06-27 21:46:55 -04:00
2018-03-14 23:31:13 -04:00
2017-08-25 17:21:10 -04:00
2017-12-04 20:32:55 -05:00
2017-11-02 11:10:55 +01:00
2017-06-12 21:02:04 -04:00
2017-08-22 16:34:36 +02:00