From: James Smart <james.smart@emulex.com>
To: Hannes Reinecke <hare@suse.de>
Cc: James Bottomley <James.Bottomley@suse.de>,
"linux-scsi@vger.kernel.org" <linux-scsi@vger.kernel.org>
Subject: Re: [PATCH] Protect against overflow in dev_loss_tmo
Date: Tue, 9 Mar 2010 09:14:37 -0500 [thread overview]
Message-ID: <4B9657CD.6000805@emulex.com> (raw)
In-Reply-To: <20100309091848.4C7412BD8B@ochil.suse.de>
I don't ever expect to see large dev_loss_tmo values, but the patch is fine.
Acked-by: James Smart <james.smart@emulex.com>
-- james s
Hannes Reinecke wrote:
> 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>
>
> diff --git a/drivers/scsi/scsi_transport_fc.c b/drivers/scsi/scsi_transport_fc.c
> index 79660ee..9860322 100644
> --- a/drivers/scsi/scsi_transport_fc.c
> +++ b/drivers/scsi/scsi_transport_fc.c
> @@ -833,7 +833,7 @@ static ssize_t
> store_fc_rport_dev_loss_tmo(struct device *dev, struct device_attribute *attr,
> const char *buf, size_t count)
> {
> - int val;
> + unsigned long val;
> struct fc_rport *rport = transport_class_to_rport(dev);
> struct Scsi_Host *shost = rport_to_shost(rport);
> struct fc_internal *i = to_fc_internal(shost->transportt);
> @@ -847,6 +847,12 @@ store_fc_rport_dev_loss_tmo(struct device *dev, struct device_attribute *attr,
> return -EINVAL;
>
> /*
> + * Check for overflow; dev_loss_tmo is u32
> + */
> + if (val > UINT_MAX)
> + return -EINVAL;
> +
> + /*
> * If fast_io_fail is off we have to cap
> * dev_loss_tmo at SCSI_DEVICE_BLOCK_MAX_TIMEOUT
> */
> @@ -2852,7 +2858,7 @@ void
> fc_remote_port_delete(struct fc_rport *rport)
> {
> struct Scsi_Host *shost = rport_to_shost(rport);
> - int timeout = rport->dev_loss_tmo;
> + unsigned long timeout = rport->dev_loss_tmo;
> unsigned long flags;
>
> /*
> --
> To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
>
>
next prev parent reply other threads:[~2010-03-09 14:14 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-03-09 9:18 [PATCH] Protect against overflow in dev_loss_tmo Hannes Reinecke
2010-03-09 14:14 ` James Smart [this message]
2010-03-16 13:04 ` Christof Schmitt
2010-03-17 9:40 ` Hannes Reinecke
2010-03-18 4:33 ` Mike Christie
2010-03-18 4:24 ` Mike Christie
2010-03-22 14:12 ` Christof Schmitt
2010-03-24 16:02 ` Christof Schmitt
2010-03-26 9:50 ` Hannes Reinecke
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4B9657CD.6000805@emulex.com \
--to=james.smart@emulex.com \
--cc=James.Bottomley@suse.de \
--cc=hare@suse.de \
--cc=linux-scsi@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.