Vitaly Kuznetsov
be821fd8e6
scsi_sysfs: protect against double execution of __scsi_remove_device()
...
On some host errors storvsc module tries to remove sdev by scheduling a job
which does the following:
sdev = scsi_device_lookup(wrk->host, 0, 0, wrk->lun);
if (sdev) {
scsi_remove_device(sdev);
scsi_device_put(sdev);
}
While this code seems correct the following crash is observed:
general protection fault: 0000 [#1 ] SMP DEBUG_PAGEALLOC
RIP: 0010:[<ffffffff81169979>] [<ffffffff81169979>] bdi_destroy+0x39/0x220
...
[<ffffffff814aecdc>] ? _raw_spin_unlock_irq+0x2c/0x40
[<ffffffff8127b7db>] blk_cleanup_queue+0x17b/0x270
[<ffffffffa00b54c4>] __scsi_remove_device+0x54/0xd0 [scsi_mod]
[<ffffffffa00b556b>] scsi_remove_device+0x2b/0x40 [scsi_mod]
[<ffffffffa00ec47d>] storvsc_remove_lun+0x3d/0x60 [hv_storvsc]
[<ffffffff81080791>] process_one_work+0x1b1/0x530
...
The problem comes with the fact that many such jobs (for the same device)
are being scheduled simultaneously. While scsi_remove_device() uses
shost->scan_mutex and scsi_device_lookup() will fail for a device in
SDEV_DEL state there is no protection against someone who did
scsi_device_lookup() before we actually entered __scsi_remove_device(). So
the whole scenario looks like that: two callers do simultaneous (or
preemption happens) calls to scsi_device_lookup() ant these calls succeed
for both of them, after that they try doing scsi_remove_device().
shost->scan_mutex only serializes their calls to __scsi_remove_device()
and we end up doing the cleanup path twice.
Signed-off-by: Vitaly Kuznetsov <vkuznets@redhat.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2015-11-19 12:15:09 -05:00
..
2015-05-25 08:46:25 -07:00
2015-08-07 14:36:05 +02:00
2015-11-09 19:36:50 -05:00
2015-09-08 14:35:59 -07:00
2015-05-31 18:06:28 -07:00
2015-11-11 20:25:28 -05:00
2015-09-06 11:39:53 -07:00
2015-10-27 10:29:13 +09:00
2015-06-02 17:15:24 -07:00
2015-05-25 08:46:26 -07:00
2015-06-30 19:45:00 -07:00
2015-08-26 18:08:47 -07:00
2015-08-28 13:14:57 -07:00
2015-02-11 10:28:45 -08:00
2015-09-11 18:15:18 -07:00
2015-10-27 11:05:45 +09:00
2015-11-11 21:01:15 -05:00
2015-11-09 19:36:04 -05:00
2015-09-02 12:22:54 -07:00
2015-03-24 17:08:29 -07:00
2015-10-27 10:24:46 +09:00
2015-11-09 11:07:16 -05:00
2015-11-13 15:25:11 -05:00
2015-11-13 15:44:40 -05:00
2015-04-14 09:50:27 -07:00
2015-05-31 18:06:28 -07:00
2015-11-09 19:41:31 -05:00
2015-11-17 18:21:22 -05:00
2015-06-24 16:49:49 -07:00
2015-06-19 16:57:51 -07:00
2014-11-24 14:45:27 +01:00
2015-11-09 18:03:55 -05:00
2015-10-07 10:24:48 -07:00
2015-04-27 10:10:19 -07:00
2015-04-27 10:04:39 -07:00
2015-04-27 10:04:39 -07:00
2015-04-27 10:05:55 -07:00
2015-04-27 10:05:55 -07:00
2015-08-07 14:28:45 +02:00
2015-08-07 15:03:42 +02:00
2013-11-26 11:09:07 +01:00
2014-10-20 16:21:33 +02:00
2014-10-20 16:21:33 +02:00
2015-11-18 10:16:19 -05:00
2015-05-31 18:06:28 -07:00
2015-05-31 18:06:28 -07:00
2015-04-09 18:08:31 -07:00
2015-05-31 18:06:28 -07:00
2015-05-31 18:06:28 -07:00
2015-04-17 10:13:56 -07:00
2015-03-09 10:45:26 -04:00
2015-03-09 07:18:14 -04:00
2015-05-31 18:06:28 -07:00
2015-05-31 18:06:28 -07:00
2015-02-02 09:57:45 -08:00
2013-06-26 18:32:47 -07:00
2014-10-20 16:21:33 +02:00
2015-04-14 09:50:27 -07:00
2015-01-09 15:44:31 +01:00
2015-02-02 09:57:46 -08:00
2014-11-20 09:11:11 +01:00
2015-07-31 13:31:10 +02:00
2014-07-17 22:07:37 +02:00
2014-11-20 09:11:10 +01:00
2014-11-20 09:11:10 +01:00
2015-02-02 09:57:45 -08:00
2014-11-24 14:45:27 +01:00
2015-01-09 15:44:23 +01:00
2014-11-24 16:13:16 +01:00
2015-05-31 18:06:28 -07:00
2013-06-26 18:32:47 -07:00
2015-03-09 10:45:26 -04:00
2014-11-20 09:11:10 +01:00
2015-02-02 09:57:45 -08:00
2014-11-24 20:01:40 +01:00
2013-11-26 11:09:07 +01:00
2014-11-12 11:19:41 +01:00
2015-11-09 12:39:28 -05:00
2015-11-13 16:49:35 -05:00
2015-11-09 12:39:28 -05:00
2015-08-12 13:14:57 -07:00
2015-08-12 13:14:57 -07:00
2015-05-31 18:06:28 -07:00
2015-02-02 09:57:46 -08:00
2015-05-31 18:06:28 -07:00
2015-11-09 19:32:08 -05:00
2015-11-09 19:32:41 -05:00
2015-06-02 17:24:54 -07:00
2014-03-15 10:19:19 -07:00
2014-11-24 14:45:27 +01:00
2014-04-11 16:15:36 -04:00
2014-10-20 16:21:33 +02:00
2015-11-11 19:50:11 -05:00
2014-03-15 10:19:18 -07:00
2015-09-17 07:25:02 -07:00
2015-05-31 18:06:28 -07:00
2014-10-20 16:21:33 +02:00
2015-03-09 07:18:14 -04:00
2015-11-11 19:50:11 -05:00
2015-08-26 07:23:04 -07:00
2014-03-27 08:26:31 -07:00
2015-03-23 14:29:40 +11:00
2014-10-20 16:21:33 +02:00
2015-11-11 20:45:23 -05:00
2013-04-15 14:30:44 -06:00
2014-11-24 14:45:27 +01:00
2014-07-17 22:07:35 +02:00
2015-05-31 18:06:28 -07:00
2015-03-09 10:45:26 -04:00
2014-11-20 09:11:20 +01:00
2015-05-31 18:06:28 -07:00
2014-11-24 20:01:28 +01:00
2014-11-20 09:11:10 +01:00
2014-11-20 09:11:10 +01:00
2015-11-11 20:51:04 -05:00
2015-05-31 18:06:28 -07:00
2015-05-31 18:06:28 -07:00
2015-05-31 18:06:28 -07:00
2015-05-31 18:06:28 -07:00
2015-05-31 18:06:28 -07:00
2015-07-23 22:53:05 -07:00
2015-09-06 11:03:14 -07:00
2015-10-27 11:09:41 +09:00
2015-10-01 10:46:28 -07:00
2015-09-11 19:00:42 -07:00
2014-11-12 11:16:12 +01:00
2015-08-28 13:14:57 -07:00
2015-02-04 08:00:24 -08:00
2014-11-12 11:16:05 +01:00
2014-04-24 13:44:54 -04:00
2015-08-18 08:14:14 -07:00
2015-08-28 13:14:56 -07:00
2015-02-02 09:57:46 -08:00
2015-11-19 12:12:16 -05:00
2014-06-06 16:08:16 -07:00
2015-11-19 12:15:09 -05:00
2015-02-02 09:57:46 -08:00
2015-04-10 07:40:32 -07:00
2015-09-02 12:22:54 -07:00
2015-09-06 11:13:41 -07:00
2015-08-07 14:28:45 +02:00
2015-07-14 13:20:09 -04:00
2015-06-01 07:32:43 -07:00
2014-11-12 11:15:54 +01:00
2015-04-16 10:37:12 -07:00
2015-11-11 21:10:26 -05:00
2014-11-12 11:15:57 +01:00
2015-01-09 15:44:19 +01:00
2015-11-02 23:51:25 -05:00
2014-10-20 16:21:33 +02:00
2014-10-20 16:21:33 +02:00
2015-01-20 19:43:24 +01:00
2014-07-17 22:07:39 +02:00
2014-11-24 20:01:28 +01:00
2014-11-12 11:15:57 +01:00
2015-11-19 12:12:42 -05:00
2015-06-02 08:03:25 -07:00
2014-11-12 11:19:44 +01:00
2015-08-26 22:41:36 -07:00
2014-05-28 12:16:28 +02:00
2015-03-09 07:18:14 -04:00
2014-11-20 09:11:15 +01:00
2015-08-10 23:07:05 -04:00
2014-10-20 16:21:33 +02:00
2015-05-31 18:06:28 -07:00
2014-11-20 09:11:10 +01:00
2014-11-20 09:11:10 +01:00
2014-11-24 14:45:27 +01:00
2015-07-23 13:07:04 -07:00
2014-11-24 14:45:28 +01:00
2014-09-24 11:52:09 -06:00
2015-02-02 09:57:46 -08:00
2015-08-07 14:28:45 +02:00
2015-05-31 18:06:28 -07:00
2015-02-02 09:57:45 -08:00
2015-09-08 18:03:49 +01:00
2013-11-26 11:09:07 +01:00