From: Hannes Reinecke <hare@suse.de>
To: linux-hotplug@vger.kernel.org
Subject: [PATCH] restrict buffer size to 254 in scsi_id
Date: Mon, 19 Jul 2004 09:32:00 +0000 [thread overview]
Message-ID: <40FB9510.30309@suse.de> (raw)
[-- Attachment #1: Type: text/plain, Size: 550 bytes --]
Hi all,
this patch restricts the max buffer size to 254 in scsi_id. According to
our SCSI-god-in-residence this is needed as some Wide-SCSI device might
behave nasty if asked for odd lengths.
We had a rather lengthy bugzilla for it and even Patrick agreed that
this is a good thing.
Patrick, is this correct? If so, could you also apply it for the scsi_id
program?
Cheers,
Hannes
--
Dr. Hannes Reinecke hare@suse.de
SuSE Linux AG S390 & zSeries
Maxfeldstraße 5 +49 911 74053 688
90409 Nürnberg http://www.suse.de
[-- Attachment #2: udev-021-maxlen.patch --]
[-- Type: text/x-patch, Size: 2732 bytes --]
We have to restrict the maximum length to less than 0xff. However,
according to Kurt Garloff:
Also, you probably send a 6 byte command, max alloc length would be 255,
and we'd better round that down to 254 then. (Uneven counts on wide SCSI
busses are a bit nasty and tend to trigger bugs in the LLDs w.r.t. handling
of the IGNORE_RESIDUAL msg.)
So we'll be using 254 throughout.
Index: udev-021/extras/scsi_id/scsi_serial.c
===================================================================
--- udev-021.orig/extras/scsi_id/scsi_serial.c 2004-03-03 01:01:32.000000000 +0100
+++ udev-021/extras/scsi_id/scsi_serial.c 2004-06-24 17:03:16.000000000 +0200
@@ -303,7 +303,7 @@ static int scsi_inquiry(struct sysfs_dev
unsigned char *buffer;
int retry = 3; /* rather random */
- if (buflen > 255) {
+ if (buflen > 254) {
log_message(LOG_WARNING, "buflen %d too long\n", buflen);
return -1;
}
@@ -356,6 +356,7 @@ resend:
return retval;
}
+/* Get list of supported EVPD pages */
static int do_scsi_page0_inquiry(struct sysfs_device *scsi_dev, int fd,
char *buffer, int len)
{
@@ -544,6 +561,7 @@ static int check_fill_0x83_id(struct sys
return 0;
}
+/* Get device identification VPD page */
static int do_scsi_page83_inquiry(struct sysfs_device *scsi_dev, int fd,
char *serial, int len)
{
@@ -552,7 +570,7 @@ static int do_scsi_page83_inquiry(struct
unsigned char page_83[256];
memset(page_83, 0, 256);
- retval = scsi_inquiry(scsi_dev, fd, 1, 0x83, page_83, 255);
+ retval = scsi_inquiry(scsi_dev, fd, 1, 0x83, page_83, 254);
if (retval < 0)
return 1;
@@ -601,6 +619,7 @@ static int do_scsi_page83_inquiry(struct
return 1;
}
+/* Get unit serial number VPD page */
static int do_scsi_page80_inquiry(struct sysfs_device *scsi_dev, int fd,
char *serial, int max_len)
{
@@ -611,7 +630,7 @@ static int do_scsi_page80_inquiry(struct
unsigned char buf[256];
memset(buf, 0, 256);
- retval = scsi_inquiry(scsi_dev, fd, 1, 0x80, buf, 255);
+ retval = scsi_inquiry(scsi_dev, fd, 1, 0x80, buf, 254);
if (retval < 0)
return retval;
@@ -649,7 +668,8 @@ int scsi_get_serial (struct sysfs_device
int ind;
int retval;
- if (len > 255) {
+ if (len > 254) {
+ len = 254;
}
memset(serial, 0, len);
dprintf("opening %s\n", devname);
@@ -686,7 +706,7 @@ int scsi_get_serial (struct sysfs_device
* Get page 0, the page of the pages. By default, try from best to
* worst of supported pages: 0x83 then 0x80.
*/
- if (do_scsi_page0_inquiry(scsi_dev, fd, page0, 255)) {
+ if (do_scsi_page0_inquiry(scsi_dev, fd, page0, 254)) {
/*
* Don't try anything else. Black list if a specific page
* should be used for this vendor+model, or maybe have an
next reply other threads:[~2004-07-19 9:32 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-07-19 9:32 Hannes Reinecke [this message]
2004-07-30 16:48 ` [PATCH] restrict buffer size to 254 in scsi_id Patrick Mansfield
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=40FB9510.30309@suse.de \
--to=hare@suse.de \
--cc=linux-hotplug@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;
as well as URLs for NNTP newsgroup(s).