From: James Bottomley <James.Bottomley@suse.de>
To: Boaz Harrosh <bharrosh@panasas.com>
Cc: Roel Kluin <roel.kluin@gmail.com>,
linux-scsi@vger.kernel.org,
Andrew Morton <akpm@linux-foundation.org>,
"Martin K. Petersen" <martin.petersen@oracle.com>
Subject: Re: [PATCH] zfcp: Test kmalloc failure in scsi_get_vpd_page()
Date: Wed, 04 Nov 2009 11:50:13 -0600 [thread overview]
Message-ID: <1257357013.10416.8.camel@mulgrave.site> (raw)
In-Reply-To: <4AF1A941.3080808@panasas.com>
On Wed, 2009-11-04 at 18:18 +0200, Boaz Harrosh wrote:
> On 11/04/2009 05:09 PM, James Bottomley wrote:
> > On Wed, 2009-11-04 at 10:54 +0200, Boaz Harrosh wrote:
> >>> +
> >>> + if (i < buf[3] && i > buf_len)
> >>> + /* ran off the end of the buffer, give us benefit of doubt */
> >>> + goto found;
> >>
> >> Some cheep devices are known to break when asked for pages they do not support
> >> better return an -ETOOSMALL the user can check for. (And the comment above should
> >> also take care of it)
> >
> > OK, so I struggled with this. The reason for the behaviour is that
> > only USB devices with incredibly small page lists are likely to exhibit
> > the problem. Whereas the page lists in array type devices are likely to
> > grow. I don't want to run into the situation that your new $10m array
> > suddenly gives an error with DIF/DIX because the page list is too big
> > and the problem this is checking for only afflicts cheap and badly
> > implemented HW.
> >
>
> If I remember the standard correctly and from inspecting the code 260 is the
> maximum size for page 0. (And the maximum we supported until today for page
> 0 was 256) so there is no speculations here. 256 it should be. If you want
> you can do an:
The standard actually lists only two mandatory pages and about eight
optional ones (plus the 127 vendor specific ones that no-one seems to
use).
The point isn't to exercise the standard to the maximum, it's to
generate working code. The point is that problem devices likely only
list a couple of VPD pages, so we'll correctly not probe them.
Conforming devices don't matter because they'll do the right thing when
asked for a VPD page they don't have.
> if (i < buf[3] && i > buf_len) {
> if (likely(buf_len >= 255))
> /* ran off the end of the buffer, give us benefit of doubt */
> goto found;
> else
> return -ETOOSMALL;
> }
>
> which is only theoretical because we only check against buf[3] that cannot
> be more then 255 so all is left is return -ETOOSMALL;
>
> Callers that allocate smaller then 256 for this (hence the comment)
> must check for -ETOOSMALL;. Or should call with >= 256.
>
> <snip>
> >>> diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c
> >>> index 9093c72..fd1bd8f 100644
> >>> --- a/drivers/scsi/sd.c
> >>> +++ b/drivers/scsi/sd.c
> >>> @@ -1864,19 +1864,20 @@ void sd_read_app_tag_own(struct scsi_disk *sdkp, unsigned char *buffer)
> >>> static void sd_read_block_limits(struct scsi_disk *sdkp)
> >>> {
> >>> unsigned int sector_sz = sdkp->device->sector_size;
> >>> - char *buffer;
> >>> + const int vpd_len = 32;
> >>> + unsigned char *buffer = kmalloc(vpd_len, GFP_KERNEL);
> >>>
> >>
> >> 32 sounds two small for me. Not because of the page but because of the
> >> first pass. Why not just 255 as a rule. We kmalloc it anyway.
> >
> > It only needs 16 if you look at the code. 32 is actually the smallest
> > kmalloc slab on 32 bit systems.
> >
>
> >> We used to allocate 255 here, for some devices out there this is surly
> >> a regression.
> >
> > We did 255 because we were concerned about space for the page list ...
> > hopefully I answered that one above.
> >
>
> No, I still disagree. Whats the point of checking at all? Surly there is a device
> out there that has more then 12 pages but will breaks with wrong page. So what's
> the limit? the standards say 260 why not stick with that. It's not at any hot path.
The point of checking is not to send a VPD inquiry to USB devices that
don't support it. These have a very limited range of supported VPD
pages.
James
next prev parent reply other threads:[~2009-11-04 17:50 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-08-24 16:21 [PATCH] zfcp: Test kmalloc failure in scsi_get_vpd_page() Roel Kluin
2009-08-27 23:45 ` James Bottomley
2009-08-30 11:45 ` Boaz Harrosh
2009-08-30 14:35 ` James Bottomley
2009-11-03 18:33 ` James Bottomley
2009-11-04 8:54 ` Boaz Harrosh
2009-11-04 15:09 ` James Bottomley
2009-11-04 16:18 ` Boaz Harrosh
2009-11-04 17:50 ` James Bottomley [this message]
2009-11-05 8:29 ` Boaz Harrosh
2009-11-05 19:41 ` James Bottomley
2009-11-08 9:19 ` Boaz Harrosh
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=1257357013.10416.8.camel@mulgrave.site \
--to=james.bottomley@suse.de \
--cc=akpm@linux-foundation.org \
--cc=bharrosh@panasas.com \
--cc=linux-scsi@vger.kernel.org \
--cc=martin.petersen@oracle.com \
--cc=roel.kluin@gmail.com \
/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