aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/scsi/scsi_transport_fc.c
diff options
context:
space:
mode:
authorHannes Reinecke <hare@suse.de>2010-03-09 04:18:48 -0500
committerJames Bottomley <James.Bottomley@suse.de>2010-04-11 10:23:27 -0400
commit36dd288f0f930c154ec6a4d73a6a35f3079418c6 (patch)
tree63fb1e1ec6716561051a2da94479904ffaeac016 /drivers/scsi/scsi_transport_fc.c
parentbb789d01620e5d36081b22edb6fb71cf55ff043c (diff)
[SCSI] scsi_transport_fc: Protect against overflow in dev_loss_tmo
The rport structure defines dev_loss_tmo as u32, which is later multiplied with HZ to get the actual timeout value. This might overflow for large dev_loss_tmo values. So we should be better using u64 as intermediate variables here to protect against overflow. Signed-off-by: Hannes Reinecke <hare@suse.de> Acked-by: James Smart <james.smart@emulex.com> Signed-off-by: James Bottomley <James.Bottomley@suse.de>
Diffstat (limited to 'drivers/scsi/scsi_transport_fc.c')
-rw-r--r--drivers/scsi/scsi_transport_fc.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/drivers/scsi/scsi_transport_fc.c b/drivers/scsi/scsi_transport_fc.c
index 6cfffc88022..55fe730a860 100644
--- a/drivers/scsi/scsi_transport_fc.c
+++ b/drivers/scsi/scsi_transport_fc.c
@@ -834,7 +834,7 @@ static ssize_t
834store_fc_rport_dev_loss_tmo(struct device *dev, struct device_attribute *attr, 834store_fc_rport_dev_loss_tmo(struct device *dev, struct device_attribute *attr,
835 const char *buf, size_t count) 835 const char *buf, size_t count)
836{ 836{
837 int val; 837 unsigned long val;
838 struct fc_rport *rport = transport_class_to_rport(dev); 838 struct fc_rport *rport = transport_class_to_rport(dev);
839 struct Scsi_Host *shost = rport_to_shost(rport); 839 struct Scsi_Host *shost = rport_to_shost(rport);
840 struct fc_internal *i = to_fc_internal(shost->transportt); 840 struct fc_internal *i = to_fc_internal(shost->transportt);
@@ -848,6 +848,12 @@ store_fc_rport_dev_loss_tmo(struct device *dev, struct device_attribute *attr,
848 return -EINVAL; 848 return -EINVAL;
849 849
850 /* 850 /*
851 * Check for overflow; dev_loss_tmo is u32
852 */
853 if (val > UINT_MAX)
854 return -EINVAL;
855
856 /*
851 * If fast_io_fail is off we have to cap 857 * If fast_io_fail is off we have to cap
852 * dev_loss_tmo at SCSI_DEVICE_BLOCK_MAX_TIMEOUT 858 * dev_loss_tmo at SCSI_DEVICE_BLOCK_MAX_TIMEOUT
853 */ 859 */
@@ -2865,7 +2871,7 @@ void
2865fc_remote_port_delete(struct fc_rport *rport) 2871fc_remote_port_delete(struct fc_rport *rport)
2866{ 2872{
2867 struct Scsi_Host *shost = rport_to_shost(rport); 2873 struct Scsi_Host *shost = rport_to_shost(rport);
2868 int timeout = rport->dev_loss_tmo; 2874 unsigned long timeout = rport->dev_loss_tmo;
2869 unsigned long flags; 2875 unsigned long flags;
2870 2876
2871 /* 2877 /*