All of lore.kernel.org
 help / color / mirror / Atom feed
* [GIT PULL] SCSI bug fixes for 2.6.36-rc7
@ 2010-10-13 13:45 James Bottomley
  2010-10-13 23:49 ` Linus Torvalds
  0 siblings, 1 reply; 7+ messages in thread
From: James Bottomley @ 2010-10-13 13:45 UTC (permalink / raw)
  To: Andrew Morton, Linus Torvalds; +Cc: linux-scsi, linux-kernel

This patch set fixes a couple of longstanding bugs in SCSI.  The VPD
patch fix a possible buffer overrun in the VPD code (only tripped if the
device has a huge number of VPD pages).  The other is where the status
return code on our BSG interface is wrongly right shifted one place.

The patch is available here:

master.kernel.org:/pub/scm/linux/kernel/git/jejb/scsi-rc-fixes-2.6.git

The short changelog is:

FUJITA Tomonori (1):
      bsg: fix incorrect device_status value

Martin K. Petersen (1):
      Fix VPD inquiry page wrapper


The diffstat is:

 block/bsg.c         |    2 +-
 drivers/scsi/scsi.c |    4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)

And the full diff is below.

James

---

diff --git a/block/bsg.c b/block/bsg.c
index 82d5882..5974682 100644
--- a/block/bsg.c
+++ b/block/bsg.c
@@ -426,7 +426,7 @@ static int blk_complete_sgv4_hdr_rq(struct request *rq, struct sg_io_v4 *hdr,
 	/*
 	 * fill in all the output members
 	 */
-	hdr->device_status = status_byte(rq->errors);
+	hdr->device_status = rq->errors && 0xff;
 	hdr->transport_status = host_byte(rq->errors);
 	hdr->driver_status = driver_byte(rq->errors);
 	hdr->info = 0;
diff --git a/drivers/scsi/scsi.c b/drivers/scsi/scsi.c
index ad0ed21..348fba0 100644
--- a/drivers/scsi/scsi.c
+++ b/drivers/scsi/scsi.c
@@ -1046,13 +1046,13 @@ int scsi_get_vpd_page(struct scsi_device *sdev, u8 page, unsigned char *buf,
 
 	/* If the user actually wanted this page, we can skip the rest */
 	if (page == 0)
-		return -EINVAL;
+		return 0;
 
 	for (i = 0; i < min((int)buf[3], buf_len - 4); i++)
 		if (buf[i + 4] == page)
 			goto found;
 
-	if (i < buf[3] && i > buf_len)
+	if (i < buf[3] && i >= buf_len - 4)
 		/* ran off the end of the buffer, give us benefit of doubt */
 		goto found;
 	/* The device claims it doesn't support the requested page */



^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [GIT PULL] SCSI bug fixes for 2.6.36-rc7
  2010-10-13 13:45 [GIT PULL] SCSI bug fixes for 2.6.36-rc7 James Bottomley
@ 2010-10-13 23:49 ` Linus Torvalds
  2010-10-14  0:24   ` James Bottomley
  0 siblings, 1 reply; 7+ messages in thread
From: Linus Torvalds @ 2010-10-13 23:49 UTC (permalink / raw)
  To: James Bottomley; +Cc: Andrew Morton, linux-scsi, linux-kernel

On Wed, Oct 13, 2010 at 6:45 AM, James Bottomley
<James.Bottomley@suse.de> wrote:
> This patch set fixes a couple of longstanding bugs in SCSI.  The VPD
> patch fix a possible buffer overrun in the VPD code (only tripped if the
> device has a huge number of VPD pages).  The other is where the status
> return code on our BSG interface is wrongly right shifted one place.

Umm. That other patch seems to be utter crap.

> -       hdr->device_status = status_byte(rq->errors);
> +       hdr->device_status = rq->errors && 0xff;

That's pure shit. Please look at it for one second, and don't send me
crap like this.

                        Linus "grumpy" Torvalds

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [GIT PULL] SCSI bug fixes for 2.6.36-rc7
  2010-10-13 23:49 ` Linus Torvalds
@ 2010-10-14  0:24   ` James Bottomley
  2010-10-14  0:29       ` Harvey Harrison
  2010-10-14  0:34     ` James Bottomley
  0 siblings, 2 replies; 7+ messages in thread
From: James Bottomley @ 2010-10-14  0:24 UTC (permalink / raw)
  To: Linus Torvalds; +Cc: Andrew Morton, linux-scsi, linux-kernel

On Wed, 2010-10-13 at 16:49 -0700, Linus Torvalds wrote:
> On Wed, Oct 13, 2010 at 6:45 AM, James Bottomley
> <James.Bottomley@suse.de> wrote:
> > This patch set fixes a couple of longstanding bugs in SCSI.  The VPD
> > patch fix a possible buffer overrun in the VPD code (only tripped if the
> > device has a huge number of VPD pages).  The other is where the status
> > return code on our BSG interface is wrongly right shifted one place.
> 
> Umm. That other patch seems to be utter crap.
> 
> > -       hdr->device_status = status_byte(rq->errors);
> > +       hdr->device_status = rq->errors && 0xff;
> 
> That's pure shit. Please look at it for one second, and don't send me
> crap like this.

What's wrong with it? device_status() is an ancient SCSI-1 macro that
dates from the time the status was left shifted by 1, which makes the
value wrong according to the sg interface spec.  We should really remove
it, but there's still a few ancient drivers using it.  the SG interface
requires the full status byte, which is what the bottom most byte of
req_errors is ... hence the change.

James



^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [GIT PULL] SCSI bug fixes for 2.6.36-rc7
  2010-10-14  0:24   ` James Bottomley
@ 2010-10-14  0:29       ` Harvey Harrison
  2010-10-14  0:34     ` James Bottomley
  1 sibling, 0 replies; 7+ messages in thread
From: Harvey Harrison @ 2010-10-14  0:29 UTC (permalink / raw)
  To: James Bottomley; +Cc: Linus Torvalds, Andrew Morton, linux-scsi, linux-kernel

On Wed, Oct 13, 2010 at 5:24 PM, James Bottomley
<James.Bottomley@suse.de> wrote:
> On Wed, 2010-10-13 at 16:49 -0700, Linus Torvalds wrote:
>> On Wed, Oct 13, 2010 at 6:45 AM, James Bottomley
>> <James.Bottomley@suse.de> wrote:

>>
>> Umm. That other patch seems to be utter crap.
>>
>> > -       hdr->device_status = status_byte(rq->errors);
>> > +       hdr->device_status = rq->errors && 0xff;
>>
>> That's pure shit. Please look at it for one second, and don't send me
>> crap like this.
>
> What's wrong with it? device_status() is an ancient SCSI-1 macro that
> dates from the time the status was left shifted by 1, which makes the
> value wrong according to the sg interface spec.  We should really remove
> it, but there's still a few ancient drivers using it.  the SG interface
> requires the full status byte, which is what the bottom most byte of
> req_errors is ... hence the change.
>

How about & instead of &&

Harvey

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [GIT PULL] SCSI bug fixes for 2.6.36-rc7
@ 2010-10-14  0:29       ` Harvey Harrison
  0 siblings, 0 replies; 7+ messages in thread
From: Harvey Harrison @ 2010-10-14  0:29 UTC (permalink / raw)
  To: James Bottomley; +Cc: Linus Torvalds, Andrew Morton, linux-scsi, linux-kernel

On Wed, Oct 13, 2010 at 5:24 PM, James Bottomley
<James.Bottomley@suse.de> wrote:
> On Wed, 2010-10-13 at 16:49 -0700, Linus Torvalds wrote:
>> On Wed, Oct 13, 2010 at 6:45 AM, James Bottomley
>> <James.Bottomley@suse.de> wrote:

>>
>> Umm. That other patch seems to be utter crap.
>>
>> > -       hdr->device_status = status_byte(rq->errors);
>> > +       hdr->device_status = rq->errors && 0xff;
>>
>> That's pure shit. Please look at it for one second, and don't send me
>> crap like this.
>
> What's wrong with it? device_status() is an ancient SCSI-1 macro that
> dates from the time the status was left shifted by 1, which makes the
> value wrong according to the sg interface spec.  We should really remove
> it, but there's still a few ancient drivers using it.  the SG interface
> requires the full status byte, which is what the bottom most byte of
> req_errors is ... hence the change.
>

How about & instead of &&

Harvey
--
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

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [GIT PULL] SCSI bug fixes for 2.6.36-rc7
  2010-10-14  0:24   ` James Bottomley
  2010-10-14  0:29       ` Harvey Harrison
@ 2010-10-14  0:34     ` James Bottomley
  2010-10-14  6:36       ` FUJITA Tomonori
  1 sibling, 1 reply; 7+ messages in thread
From: James Bottomley @ 2010-10-14  0:34 UTC (permalink / raw)
  To: Linus Torvalds; +Cc: Andrew Morton, linux-scsi, linux-kernel

On Wed, 2010-10-13 at 20:24 -0400, James Bottomley wrote:
> On Wed, 2010-10-13 at 16:49 -0700, Linus Torvalds wrote:
> > On Wed, Oct 13, 2010 at 6:45 AM, James Bottomley
> > <James.Bottomley@suse.de> wrote:
> > > This patch set fixes a couple of longstanding bugs in SCSI.  The VPD
> > > patch fix a possible buffer overrun in the VPD code (only tripped if the
> > > device has a huge number of VPD pages).  The other is where the status
> > > return code on our BSG interface is wrongly right shifted one place.
> > 
> > Umm. That other patch seems to be utter crap.
> > 
> > > -       hdr->device_status = status_byte(rq->errors);
> > > +       hdr->device_status = rq->errors && 0xff;
> > 
> > That's pure shit. Please look at it for one second, and don't send me
> > crap like this.
> 
> What's wrong with it? device_status() is an ancient SCSI-1 macro that
> dates from the time the status was left shifted by 1, which makes the
> value wrong according to the sg interface spec.  We should really remove
> it, but there's still a few ancient drivers using it.  the SG interface
> requires the full status byte, which is what the bottom most byte of
> req_errors is ... hence the change.

OK, right ... several people pointed out in private email that it was &&
not & ... I'll fix it when I'm slightly less jet lagged.

James



^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [GIT PULL] SCSI bug fixes for 2.6.36-rc7
  2010-10-14  0:34     ` James Bottomley
@ 2010-10-14  6:36       ` FUJITA Tomonori
  0 siblings, 0 replies; 7+ messages in thread
From: FUJITA Tomonori @ 2010-10-14  6:36 UTC (permalink / raw)
  To: James.Bottomley; +Cc: torvalds, akpm, linux-scsi, linux-kernel

On Wed, 13 Oct 2010 20:34:37 -0400
James Bottomley <James.Bottomley@suse.de> wrote:

> On Wed, 2010-10-13 at 20:24 -0400, James Bottomley wrote:
> > On Wed, 2010-10-13 at 16:49 -0700, Linus Torvalds wrote:
> > > On Wed, Oct 13, 2010 at 6:45 AM, James Bottomley
> > > <James.Bottomley@suse.de> wrote:
> > > > This patch set fixes a couple of longstanding bugs in SCSI.  The VPD
> > > > patch fix a possible buffer overrun in the VPD code (only tripped if the
> > > > device has a huge number of VPD pages).  The other is where the status
> > > > return code on our BSG interface is wrongly right shifted one place.
> > > 
> > > Umm. That other patch seems to be utter crap.
> > > 
> > > > -       hdr->device_status = status_byte(rq->errors);
> > > > +       hdr->device_status = rq->errors && 0xff;
> > > 
> > > That's pure shit. Please look at it for one second, and don't send me
> > > crap like this.
> > 
> > What's wrong with it? device_status() is an ancient SCSI-1 macro that
> > dates from the time the status was left shifted by 1, which makes the
> > value wrong according to the sg interface spec.  We should really remove
> > it, but there's still a few ancient drivers using it.  the SG interface
> > requires the full status byte, which is what the bottom most byte of
> > req_errors is ... hence the change.
> 
> OK, right ... several people pointed out in private email that it was &&
> not & ... I'll fix it when I'm slightly less jet lagged.

Really sorry about that.

=
From: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
Subject: [PATCH] bsg: fix incorrect device_status value

bsg incorrectly returns sg's masked_status value for device_status.

Reported-by: Douglas Gilbert <dgilbert@interlog.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
---
 block/bsg.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/block/bsg.c b/block/bsg.c
index 82d5882..0c00870 100644
--- a/block/bsg.c
+++ b/block/bsg.c
@@ -426,7 +426,7 @@ static int blk_complete_sgv4_hdr_rq(struct request *rq, struct sg_io_v4 *hdr,
 	/*
 	 * fill in all the output members
 	 */
-	hdr->device_status = status_byte(rq->errors);
+	hdr->device_status = rq->errors & 0xff;
 	hdr->transport_status = host_byte(rq->errors);
 	hdr->driver_status = driver_byte(rq->errors);
 	hdr->info = 0;
-- 
1.7.1



^ permalink raw reply related	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2010-10-14  6:38 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-10-13 13:45 [GIT PULL] SCSI bug fixes for 2.6.36-rc7 James Bottomley
2010-10-13 23:49 ` Linus Torvalds
2010-10-14  0:24   ` James Bottomley
2010-10-14  0:29     ` Harvey Harrison
2010-10-14  0:29       ` Harvey Harrison
2010-10-14  0:34     ` James Bottomley
2010-10-14  6:36       ` FUJITA Tomonori

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.