From: James Bottomley <James.Bottomley@HansenPartnership.com>
To: Alan Stern <stern@rowland.harvard.edu>
Cc: Maciej Rutecki <maciej.rutecki@gmail.com>,
Jens Axboe <jens.axboe@oracle.com>,
Boaz Harrosh <bharrosh@panasas.com>,
USB Storage list <usb-storage@lists.one-eyed-alien.net>,
SCSI development list <linux-scsi@vger.kernel.org>
Subject: Re: [Re: Linux 2.6.26-rc2] Write protect on on
Date: Fri, 20 Jun 2008 17:09:34 -0500 [thread overview]
Message-ID: <1213999774.3443.49.camel@localhost.localdomain> (raw)
In-Reply-To: <Pine.LNX.4.44L0.0806201731300.2133-100000@iolanthe.rowland.org>
On Fri, 2008-06-20 at 17:46 -0400, Alan Stern wrote:
> On Fri, 20 Jun 2008, James Bottomley wrote:
>
> > > Not having received any comments on that earlier patch, I wrote a new
> > > version. Actually it's a pair of patches, and they have to be applied
> > > in order. They don't look as ugly as the old one and they have a
> > > decent chance of being accepted.
> >
> > Actually, just looking at this, what you're really trying to do is
> > enforce an underrun detection, which is a concept built in to the
> > command structure but not necessarily well implemented by all drivers.
> >
> > However, I had a tick on this one to go back and look at it.
> >
> > Your initial contention was that the garbage value was "left over data"
> > in the sense command. However, I don't see how we're getting this into
> > the buffer; scsi_mode_sense() clears the buffer up to the length it's
> > expecting before it executes the request. How is this getting garbage
> > data if nothing's returned ... surely it should still be all zeros?
>
> It's not true that nothing's returned. The device returns N bytes of
> garbage data (I forget just now what N was) and sets the residue equal
> to N -- meaning that none of the data was meaningful.
>
> USB mass-storage is perhaps a little strange for people accustomed to
> regular SCSI. Quoting from the relevant spec:
>
> For Data-In the device shall report in the dCSWDataResidue the
> difference between the amount of data expected as stated in the
> dCBWDataTransferLength and the actual amount of relevant data
> sent by the device.
>
> The key word here is "relevant". The device is allowed to send
> non-relevant data and then tell the host to ignore it. Later on the
> spec says:
>
> If the device intends to send less data than the host indicated, then:
> The device shall send the intended data.
> The device may send fill data to pad up to a total of dCBWDataTransferLength.
> If the device actually transfers less data than the host indicated, then:
> The device may end the transfer with a short packet.
> The device shall STALL the Bulk-In pipe.
> The device shall set bCSWStatus to 00h or 01h.
> The device shall set dCSWDataResidue to the difference between dCBWDataTransferLength
> and the actual amount of relevant data sent.
>
> In this case the fill data is getting treated as real data. Does this
> clarify the situation?
Yes, thanks. It's a bit nasty from a security point of view, since the
leaking data apparently belonged to a different command. Wouldn't a
better fix (and a more secure one) be to clear from the end of the valid
data to the end of the buffer?
James
next prev parent reply other threads:[~2008-06-20 22:09 UTC|newest]
Thread overview: 37+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <48328E81.2080504@panasas.com>
2008-05-20 14:23 ` [Re: Linux 2.6.26-rc2] Write protect on on Alan Stern
2008-06-03 15:02 ` Alan Stern
2008-06-13 16:57 ` Maciej Rutecki
2008-06-13 18:02 ` Alan Stern
2008-06-14 7:02 ` Maciej Rutecki
2008-06-20 20:22 ` Alan Stern
2008-06-20 20:56 ` James Bottomley
2008-06-20 21:46 ` Alan Stern
2008-06-20 22:09 ` James Bottomley [this message]
2008-06-21 2:17 ` Alan Stern
2008-06-23 15:04 ` Alan Stern
2008-06-24 3:25 ` Peter Teoh
2008-06-24 4:09 ` Peter Teoh
2008-06-24 18:03 ` [PATCH] SCSI: erase invalid data returned by device Alan Stern
2008-07-10 23:15 ` Cal Peake
2008-07-10 23:23 ` Linus Torvalds
2008-07-10 23:28 ` James Bottomley
2008-07-10 23:35 ` Linus Torvalds
2008-07-16 13:41 ` Elias Oltmanns
2008-07-16 13:55 ` James Bottomley
2008-07-16 14:12 ` Elias Oltmanns
2008-07-16 14:28 ` Alan Stern
2008-07-16 14:39 ` Elias Oltmanns
2008-07-16 14:01 ` Boaz Harrosh
2008-06-24 14:59 ` [Re: Linux 2.6.26-rc2] Write protect on on Alan Stern
2008-06-24 16:59 ` Maciej Rutecki
[not found] <8db1092f0805162359k2def1738s91cc78d48bea2581@mail.gmail.com>
[not found] ` <8db1092f0805162359k2def1738s91cc78d48bea2581-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2008-05-17 13:49 ` Alan Stern
[not found] ` <Pine.LNX.4.44L0.0805170933530.22979-100000-pYrvlCTfrz9XsRXLowluHWD2FQJk+8+b@public.gmane.org>
2008-05-18 16:27 ` Boaz Harrosh
[not found] ` <483058F1.4020601-C4P08NqkoRlBDgjK7y7TUQ@public.gmane.org>
2008-05-19 15:18 ` Alan Stern
2008-05-19 16:08 ` Boaz Harrosh
[not found] ` <4831A60A.5010308-C4P08NqkoRlBDgjK7y7TUQ@public.gmane.org>
2008-05-19 16:36 ` Linus Torvalds
2008-05-19 17:03 ` Boaz Harrosh
2008-05-19 17:27 ` Linus Torvalds
2008-05-19 17:45 ` Boaz Harrosh
[not found] ` <alpine.LFD.1.10.0805191026120.32253-5CScLwifNT1QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org>
2008-05-19 18:16 ` Matthew Wilcox
2008-05-22 8:23 ` James Bottomley
[not found] ` <4831B2E2.8030700-C4P08NqkoRlBDgjK7y7TUQ@public.gmane.org>
2008-05-19 19:17 ` Alan Stern
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=1213999774.3443.49.camel@localhost.localdomain \
--to=james.bottomley@hansenpartnership.com \
--cc=bharrosh@panasas.com \
--cc=jens.axboe@oracle.com \
--cc=linux-scsi@vger.kernel.org \
--cc=maciej.rutecki@gmail.com \
--cc=stern@rowland.harvard.edu \
--cc=usb-storage@lists.one-eyed-alien.net \
/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