From: Matthew Wilcox <matthew@wil.cx>
To: Brian King <brking@linux.vnet.ibm.com>
Cc: Daniel Debonzi <debonzi@linux.vnet.ibm.com>, linux-scsi@vger.kernel.org
Subject: [PATCH] Make host_no an unsigned int
Date: Tue, 15 Jul 2008 14:54:16 -0600 [thread overview]
Message-ID: <20080715205415.GJ14894@parisc-linux.org> (raw)
In-Reply-To: <487D0933.1010201@linux.vnet.ibm.com>
On Tue, Jul 15, 2008 at 03:31:47PM -0500, Brian King wrote:
> Matthew Wilcox wrote:
> > Or we could make the host_no a u64 and avoid the problem ever happening
> > in our lifetimes. I'm amazed that anyone's had the time to do 4 billion
> > add/removes, to be honest. Assuming it takes 1 second per add/remove
> > cycle, and there's not even time to scan a bus in that time, that's
> > still 136 years.
>
> That was my thought as well, until I checked struct scsi_host and saw
> that hostno is actually defined as a short there, which makes the problem
> slightly easier to hit. So, we could just increase both of them to u64's
> and be done with it...
Oh, right.
It's an unsigned short, between two ints, so there's no additional space
consumed by making it an unsigned int. An experienced hacker also notes
the 'SCSI_IOCTL_GET_IDLUN' comment, researches it, and finds out you
only get the bottom 8 bits of host_no anyway.
----
[PATCH] Make host_no an unsigned int
Daniel Debonzi reports that he has managed to wrap host_no. Increasing
the number of host numbers available to 32-bit from 16-bit allows the
problem to be evaded for another hundred years.
Signed-off-by: Matthew Wilcox <willy@linux.intel.com>
diff --git a/include/scsi/scsi_host.h b/include/scsi/scsi_host.h
index 1834fdf..062161d 100644
--- a/include/scsi/scsi_host.h
+++ b/include/scsi/scsi_host.h
@@ -547,7 +547,7 @@ struct Scsi_Host {
unsigned int host_failed; /* commands that failed. */
unsigned int host_eh_scheduled; /* EH scheduled without command */
- unsigned short host_no; /* Used for IOCTL_GET_IDLUN, /proc/scsi et al. */
+ unsigned int host_no; /* Used for IOCTL_GET_IDLUN, /proc/scsi et al. */
int resetting; /* if set, it means that last_reset is a valid value */
unsigned long last_reset;
--
Intel are signing my paycheques ... these opinions are still mine
"Bill, look, we understand that you're interested in selling us this
operating system, but compare it to ours. We can't possibly take such
a retrograde step."
next prev parent reply other threads:[~2008-07-15 20:54 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-07-11 13:19 scsi_host_alloc does not check for used shost->host_no Daniel Debonzi
2008-07-15 20:16 ` Brian King
2008-07-15 20:25 ` Matthew Wilcox
2008-07-15 20:31 ` Brian King
2008-07-15 20:54 ` Matthew Wilcox [this message]
2008-07-15 20:34 ` James Bottomley
2008-07-15 21:39 ` Daniel Debonzi
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=20080715205415.GJ14894@parisc-linux.org \
--to=matthew@wil.cx \
--cc=brking@linux.vnet.ibm.com \
--cc=debonzi@linux.vnet.ibm.com \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox