]> git.baikalelectronics.ru Git - kernel.git/commit
scsi: core: Restrict legal sdev_state transitions via sysfs
authorUday Shankar <ushankar@purestorage.com>
Sat, 24 Sep 2022 00:02:42 +0000 (18:02 -0600)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 10 Nov 2022 16:57:53 +0000 (17:57 +0100)
commit6b4f2b12ced6b95bab894ed730a308f936f86cc6
tree2ff63778850b6c96dcd9b48fb37b424f7c1a87b9
parentfd208f2e3ce414889bf5bb12e9c5bf6b9099626c
scsi: core: Restrict legal sdev_state transitions via sysfs

[ Upstream commit 9b67875cc80971d7dbd2722a1683e11111357692 ]

Userspace can currently write to sysfs to transition sdev_state to RUNNING
or OFFLINE from any source state. This causes issues because proper
transitioning out of some states involves steps besides just changing
sdev_state, so allowing userspace to change sdev_state regardless of the
source state can result in inconsistencies; e.g. with ISCSI we can end up
with sdev_state == SDEV_RUNNING while the device queue is quiesced. Any
task attempting I/O on the device will then hang, and in more recent
kernels, iscsid will hang as well.

More detail about this bug is provided in my first attempt:

https://groups.google.com/g/open-iscsi/c/PNKca4HgPDs/m/CXaDkntOAQAJ

Link: https://lore.kernel.org/r/20220924000241.2967323-1-ushankar@purestorage.com
Signed-off-by: Uday Shankar <ushankar@purestorage.com>
Suggested-by: Mike Christie <michael.christie@oracle.com>
Reviewed-by: Hannes Reinecke <hare@suse.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/scsi/scsi_sysfs.c