]> git.kernelconcepts.de Git - karo-tx-linux.git/commit
scsi_dh: fix use-after-free when removing scsi device
authorJunichi Nomura <j-nomura@ce.jp.nec.com>
Tue, 6 Oct 2015 04:32:57 +0000 (04:32 +0000)
committerJames Bottomley <JBottomley@Odin.com>
Tue, 27 Oct 2015 02:22:37 +0000 (11:22 +0900)
commit23695e41a1cac017edad2b38607f33678a31b877
tree2cadb3d6276f29f8a3555b8601d91c4aaa15d50e
parent2280521719e81919283b82902ac24058f87dfc1b
scsi_dh: fix use-after-free when removing scsi device

The commit 1bab0de0274f ("dm-mpath, scsi_dh: don't let dm detach device
handlers") removed reference counting of attached scsi device handler.
As a result, handler data is freed immediately via scsi_dh->detach()
in the context of scsi_remove_device() where activation request can be
still in flight.

This patch moves scsi_dh_handler_detach() to sdev releasing function,
scsi_device_dev_release_usercontext(), at that point the device
is already in quiesced state.

Fixes: 1bab0de0274f ("dm-mpath, scsi_dh: don't let dm detach device handlers")
Signed-off-by: Jun'ichi Nomura <j-nomura@ce.jp.nec.com>
Acked-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: James Bottomley <JBottomley@Odin.com>
drivers/scsi/scsi_dh.c
drivers/scsi/scsi_priv.h
drivers/scsi/scsi_sysfs.c