Discussion:
[PATCH] Fix off-by-one LUN check in scsi_scan_host_selected()
Mark Knibbs
2014-10-09 11:39:48 UTC
Permalink
Hi,

The Scsi_Host structure max_lun field is the maximum allowed LUN plus 1. So
a LUN value is invalid if >= max_lun.

Signed-off-by: Mark Knibbs <***@clara.co.uk>

---
diff -upN linux-3.17/drivers/scsi/scsi_scan.c.orig linux-3.17/drivers/scsi/scsi_scan.c
--- linux-3.17/drivers/scsi/scsi_scan.c.orig 2014-10-05 20:23:04.000000000 +0100
+++ linux-3.17/drivers/scsi/scsi_scan.c 2014-10-09 12:26:45.000000000 +0100
@@ -1704,7 +1704,7 @@ int scsi_scan_host_selected(struct Scsi_

if (((channel != SCAN_WILD_CARD) && (channel > shost->max_channel)) ||
((id != SCAN_WILD_CARD) && (id >= shost->max_id)) ||
- ((lun != SCAN_WILD_CARD) && (lun > shost->max_lun)))
+ ((lun != SCAN_WILD_CARD) && (lun >= shost->max_lun)))
return -EINVAL;

mutex_lock(&shost->scan_mutex);
--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to ***@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Christoph Hellwig
2014-10-17 13:24:36 UTC
Permalink
Post by Mark Knibbs
Hi,
The Scsi_Host structure max_lun field is the maximum allowed LUN plus 1. So
a LUN value is invalid if >= max_lun.
Ah, there we go. Thanks!


Reviewed-by: Christoph Hellwig <***@lst.de>
--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to ***@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Martin K. Petersen
2014-10-17 23:30:56 UTC
Permalink
Mark> Hi, The Scsi_Host structure max_lun field is the maximum allowed
Mark> LUN plus 1. So a LUN value is invalid if >= max_lun.

Reviewed-by: Martin K. Petersen <***@oracle.com>
--
Martin K. Petersen Oracle Linux Engineering
--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to ***@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Christoph Hellwig
2014-10-23 17:13:06 UTC
Permalink
Thanks,

applied to the core-for-3.19 branch.
--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to ***@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Loading...