Skip to contentSkip to conversation

Close list corruption window in __scsi_iterate_devices

PATCH New James Smart 1 participant 2 messages Feb 21, 2006 SCSI

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Close list corruption window in __scsi_iterate_devices

The existing code could allow the use of a list pointer that is grabbed prior to the lock, changes while waiting for the lock, thus is no longer valid while the lock is held.

-- james s

drivers/scsi/scsi.c.NEW renamed from drivers/scsi/scsi.c +2 -1
@@ -1015,11 +1015,12 @@ EXPORT_SYMBOL(scsi_device_put);
 struct scsi_device *__scsi_iterate_devices(struct Scsi_Host *shost,
 					   struct scsi_device *prev)
 {
-	struct list_head *list = (prev ? &prev->siblings : &shost->__devices);
+	struct list_head *list;
 	struct scsi_device *next = NULL;
 	unsigned long flags;
 
 	spin_lock_irqsave(shost->host_lock, flags);
+	list = (prev ? &prev->siblings : &shost->__devices);
 	while (list->next != &shost->__devices) {
 		next = list_entry(list->next, struct scsi_device, siblings);
 		/* skip devices that we can't get a reference to */
#1 lore raw

PATCH 1/1 Close list corruption window in __scsi_iterate_devices

Sorry folks - cold medicine had me seeing things. Ignore this.

-- james s

Quoted 27 lines · James Smart

The existing code could allow the use of a list pointer that is grabbed prior to the lock, changes while waiting for the lock, thus is no longer valid while the lock is held.

-- james s

drivers/scsi/scsi.c.NEW 2006-02-21 17:30:31.000000000 -0500 renamed from drivers/scsi/scsi.c 2006-02-06 06:01:12.000000000 -0500 +2 -2
@@ -1015,11 +1015,12 @@ EXPORT_SYMBOL(scsi_device_put);
 struct scsi_device *__scsi_iterate_devices(struct Scsi_Host *shost,
                        struct scsi_device *prev)
 {
-    struct list_head *list = (prev ? &prev->siblings : &shost->__devices);
+    struct list_head *list;
     struct scsi_device *next = NULL;
     unsigned long flags;
 
     spin_lock_irqsave(shost->host_lock, flags);
+    list = (prev ? &prev->siblings : &shost->__devices);
     while (list->next != &shost->__devices) {
         next = list_entry(list->next, struct scsi_device, siblings);
         /* skip devices that we can't get a reference to */
-

To unsubscribe from this list: send the line "unsubscribe linux-scsi" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html