Patch "scsi: core: Restrict legal sdev_state transitions via sysfs" has been added to the 5.4-stable tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This is a note to let you know that I've just added the patch titled

    scsi: core: Restrict legal sdev_state transitions via sysfs

to the 5.4-stable tree which can be found at:
    http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
     scsi-core-restrict-legal-sdev_state-transitions-via-.patch
and it can be found in the queue-5.4 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@xxxxxxxxxxxxxxx> know about it.



commit 491850c6a5a7a8a223f73135eb65de35d4d0abec
Author: Uday Shankar <ushankar@xxxxxxxxxxxxxxx>
Date:   Fri Sep 23 18:02:42 2022 -0600

    scsi: core: Restrict legal sdev_state transitions via sysfs
    
    [ Upstream commit 2331ce6126be8864b39490e705286b66e2344aac ]
    
    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@xxxxxxxxxxxxxxx
    Signed-off-by: Uday Shankar <ushankar@xxxxxxxxxxxxxxx>
    Suggested-by: Mike Christie <michael.christie@xxxxxxxxxx>
    Reviewed-by: Hannes Reinecke <hare@xxxxxxx>
    Signed-off-by: Martin K. Petersen <martin.petersen@xxxxxxxxxx>
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/drivers/scsi/scsi_sysfs.c b/drivers/scsi/scsi_sysfs.c
index 6faf1d6451b0..530b14685fd7 100644
--- a/drivers/scsi/scsi_sysfs.c
+++ b/drivers/scsi/scsi_sysfs.c
@@ -795,6 +795,14 @@ store_state_field(struct device *dev, struct device_attribute *attr,
 	}
 
 	mutex_lock(&sdev->state_mutex);
+	switch (sdev->sdev_state) {
+	case SDEV_RUNNING:
+	case SDEV_OFFLINE:
+		break;
+	default:
+		mutex_unlock(&sdev->state_mutex);
+		return -EINVAL;
+	}
 	if (sdev->sdev_state == SDEV_RUNNING && state == SDEV_RUNNING) {
 		ret = 0;
 	} else {



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux