Linux SCSI subsystem development
 help / color / mirror / Atom feed
From: Boaz Harrosh <bharrosh-C4P08NqkoRlBDgjK7y7TUQ@public.gmane.org>
To: Mark Glines <mark-6pk7R1svBr8dnm+yROfE0A@public.gmane.org>
Cc: Alan Stern
	<stern-nwvwT67g6+6dFdvTe/nMLpVzexx5G7lz@public.gmane.org>,
	USB list <linux-usb-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>,
	linux-scsi <linux-scsi-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>
Subject: Re: [linux-usb-devel] 2.6.24: NULL scatter-gather pointer in usb_storage:usb_stor_access_xfer_buf?
Date: Thu, 31 Jan 2008 17:17:52 +0200	[thread overview]
Message-ID: <47A1E6A0.8050500@panasas.com> (raw)
In-Reply-To: <20080131070846.4464eb3c-uevSgErl2ChVvDCLMmKh5Q@public.gmane.org>

On Thu, Jan 31 2008 at 17:08 +0200, Mark Glines <mark-6pk7R1svBr8dnm+yROfE0A@public.gmane.org> wrote:
> On Thu, 31 Jan 2008 11:27:39 +0200
> Boaz Harrosh <bharrosh-C4P08NqkoRlBDgjK7y7TUQ@public.gmane.org> wrote:
> 
>> Please check the below patch.
>>
>> one thing that I can see is that the isd200 does an INQUARY transfer
>> of sizeof(struct inquiry_data) which is 96 bytes, when scsi_scan.c
>> sends an INQUARY with 36 bytes buffer. So we have an underflow in 
>> usb_stor_access_xfer_buf().
>>
>> The below patch will only check my theory. I will send a proper fix
>> later, please confirm that this fixes it.
>>
>> What kills me is that this condition has existed before my patch, I'll
>> try to see why it is triggered now
> 
> I applied this patch to 2.6.24, and it now works for me.  It was
> crashing consistently whenever I'd plug this device in, now it goes
> through successfully:
> 
Yes Thanks this is grate :)

I will send a proper patch to scsi maintainer. Alan is it OK to send this
patch threw James's scsi-misc?

> 
> [24775.788039] usb 3-2: new full speed USB device using uhci_hcd and address 3
> [24775.939275] usb 3-2: configuration #1 chosen from 1 choice
> [24776.084409] usbcore: registered new interface driver libusual
> [24776.103604] Initializing USB Mass Storage driver...
> [24776.213916] scsi3 : SCSI emulation for USB Mass Storage devices
> [24776.214366] usbcore: registered new interface driver usb-storage
> [24776.214377] USB Mass Storage support registered.
> [24776.215604] usb-storage: device found at 3
> [24776.215724] usb-storage: waiting for device to settle before scanning
> [24778.333378] scsi 3:0:0:0: Direct-Access     SAMSUNG  HM120JC          YL10 PQ: 0 ANSI: 0
> [24778.333715] sd 3:0:0:0: [sdb] 234441648 512-byte hardware sectors (120034 MB)
> [24778.333841] sd 3:0:0:0: [sdb] Write Protect is off
> [24778.333848] sd 3:0:0:0: [sdb] Mode Sense: 00 00 00 00
> [24778.333853] sd 3:0:0:0: [sdb] Assuming drive cache: write through
> [24778.334196] sd 3:0:0:0: [sdb] 234441648 512-byte hardware sectors (120034 MB)
> [24778.334396] sd 3:0:0:0: [sdb] Write Protect is off
> [24778.334403] sd 3:0:0:0: [sdb] Mode Sense: 00 00 00 00
> [24778.334408] sd 3:0:0:0: [sdb] Assuming drive cache: write through
> [24778.334414]  sdb: sdb1
> [24778.824103] sd 3:0:0:0: [sdb] Attached SCSI disk
> [24778.824210] sd 3:0:0:0: Attached scsi generic sg1 type 0
> [24778.825119] usb-storage: device scan complete
> 
> 
> I'm happy to test further patches.  Let me know if you need more
> testing.
> 
> Do you still want me to try out the scsi-misc branch?
> 
No, That was my mistake, scsi-misc is now identical to mainline.

This here is a new fix that will need to go in. I will send a patch
soonish. If you can test it and send a Tested-by: it could be grate

> Mark
> 
> 
>> ---
>>  drivers/usb/storage/protocol.c |    6 ++++++
>>  1 files changed, 6 insertions(+), 0 deletions(-)
>>
>> diff --git a/drivers/usb/storage/protocol.c
>> b/drivers/usb/storage/protocol.c index a41ce21..d0ff1f6 100644
>> --- a/drivers/usb/storage/protocol.c
>> +++ b/drivers/usb/storage/protocol.c
>> @@ -229,6 +229,12 @@ void usb_stor_set_xfer_buf(unsigned char *buffer,
>>  	unsigned int offset = 0;
>>  	struct scatterlist *sg = NULL;
>>  
>> +	BUG_ON(!scsi_sglist(srb));
>> +
>> +	if(buflen > scsi_bufflen(srb))
>> +		buflen = scsi_bufflen(srb);
>> +		/*FIXME: should we set an underflow condition here*/
>> +
>>  	usb_stor_access_xfer_buf(buffer, buflen, srb, &sg, &offset,
>>  			TO_XFER_BUF);
>>  	if (buflen < scsi_bufflen(srb))
>>

Thanks Mark
(CCing linux-scsi ml)

Boaz

       reply	other threads:[~2008-01-31 15:17 UTC|newest]

Thread overview: 36+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <Pine.LNX.4.44L0.0801301807420.17156-100000@iolanthe.rowland.org>
     [not found] ` <47A1948B.2010402@panasas.com>
     [not found]   ` <20080131070846.4464eb3c@chirp.tahoe>
     [not found]     ` <20080131070846.4464eb3c-uevSgErl2ChVvDCLMmKh5Q@public.gmane.org>
2008-01-31 15:17       ` Boaz Harrosh [this message]
2008-01-31 16:45         ` [linux-usb-devel] 2.6.24: NULL scatter-gather pointer in usb_storage:usb_stor_access_xfer_buf? Alan Stern
     [not found]           ` <Pine.LNX.4.44L0.0801311143180.3970-100000-IYeN2dnnYyZXsRXLowluHWD2FQJk+8+b@public.gmane.org>
2008-01-31 17:20             ` Boaz Harrosh
     [not found]         ` <47A1E6A0.8050500-C4P08NqkoRlBDgjK7y7TUQ@public.gmane.org>
2008-01-31 17:19           ` [PATCH] bugfix for an underflow condition in usb storage & isd200.c Boaz Harrosh
     [not found]             ` <47A2033D.2050502-C4P08NqkoRlBDgjK7y7TUQ@public.gmane.org>
2008-01-31 17:49               ` Alan Stern
     [not found]                 ` <Pine.LNX.4.44L0.0801311244430.4373-100000-IYeN2dnnYyZXsRXLowluHWD2FQJk+8+b@public.gmane.org>
2008-01-31 19:00                   ` Boaz Harrosh
2008-01-31 19:34                     ` Alan Stern
2008-01-31 19:53                       ` Boaz Harrosh
2008-01-31 20:56                         ` Alan Stern
     [not found]                           ` <Pine.LNX.4.44L0.0801311546450.22845-100000-IYeN2dnnYyZXsRXLowluHWD2FQJk+8+b@public.gmane.org>
2008-02-03  8:59                             ` Boaz Harrosh
     [not found]                               ` <47A5825D.2030901-C4P08NqkoRlBDgjK7y7TUQ@public.gmane.org>
2008-02-03 16:01                                 ` Alan Stern
2008-02-03 16:28                                   ` Boaz Harrosh
2008-02-03 19:23                                     ` Matthew Dharm
2008-02-04  9:05                                       ` Boaz Harrosh
2008-02-04 20:05                                       ` Alan Stern
     [not found]                                         ` <Pine.LNX.4.44L0.0802041500420.5186-100000-IYeN2dnnYyZXsRXLowluHWD2FQJk+8+b@public.gmane.org>
2008-02-05  8:41                                           ` Boaz Harrosh
     [not found]                                             ` <47A8213B.9050705-C4P08NqkoRlBDgjK7y7TUQ@public.gmane.org>
2008-02-05 15:42                                               ` Alan Stern
2008-02-05 16:54                                                 ` Boaz Harrosh
2008-02-05 17:54                                         ` Matthew Dharm
     [not found]                                           ` <20080205175403.GA31714-JGfshJpz5UybPZpvUQj5UqxOck334EZe@public.gmane.org>
2008-02-06 20:23                                             ` Alan Stern
2008-02-06 21:05                                               ` Matthew Dharm
2008-02-06 22:18                                                 ` Alan Stern
2008-02-06 23:01                                                   ` James Bottomley
     [not found]                                                     ` <1202338869.3112.138.camel-bi+AKbBUZKY6gyzm1THtWbp2dZbC/Bob@public.gmane.org>
2008-02-06 23:25                                                       ` Alan Stern
2008-02-06 23:55                                                         ` James Bottomley
     [not found]                                                           ` <1202342108.3112.146.camel-bi+AKbBUZKY6gyzm1THtWbp2dZbC/Bob@public.gmane.org>
2008-02-07 16:35                                                             ` Alan Stern
2008-02-08 16:46                                             ` Alan Stern
     [not found]                                               ` <Pine.LNX.4.44L0.0802081143010.4593-100000-IYeN2dnnYyZXsRXLowluHWD2FQJk+8+b@public.gmane.org>
2008-02-08 16:59                                                 ` Mark Glines
     [not found]                                     ` <47A5EBC0.3060401-C4P08NqkoRlBDgjK7y7TUQ@public.gmane.org>
2008-02-03 21:09                                       ` Matthew Dharm
2008-01-31 18:00               ` Greg KH
2008-01-31 18:32                 ` Boaz Harrosh
2008-01-31 19:37                 ` [PATCH 2.6.24] bugfix for an overflow " Boaz Harrosh
     [not found]                   ` <47A22369.80906-C4P08NqkoRlBDgjK7y7TUQ@public.gmane.org>
2008-01-31 19:49                     ` Matthew Dharm
2008-01-31 20:05                       ` Boaz Harrosh
     [not found]                       ` <47A229FF.4040404@panasas.com>
2008-01-31 20:16                         ` Matthew Dharm
2008-02-02  0:55                     ` Mark Glines

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=47A1E6A0.8050500@panasas.com \
    --to=bharrosh-c4p08nqkorlbdgjk7y7tuq@public.gmane.org \
    --cc=linux-scsi-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=linux-usb-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=mark-6pk7R1svBr8dnm+yROfE0A@public.gmane.org \
    --cc=stern-nwvwT67g6+6dFdvTe/nMLpVzexx5G7lz@public.gmane.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