From mboxrd@z Thu Jan 1 00:00:00 1970 From: Hannes Reinecke Date: Mon, 19 Jul 2004 09:32:00 +0000 Subject: [PATCH] restrict buffer size to 254 in scsi_id Message-Id: <40FB9510.30309@suse.de> MIME-Version: 1 Content-Type: multipart/mixed; boundary="------------020609050300000503090804" List-Id: To: linux-hotplug@vger.kernel.org This is a multi-part message in MIME format. --------------020609050300000503090804 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: quoted-printable Hi all, this patch restricts the max buffer size to 254 in scsi_id. According to=20 our SCSI-god-in-residence this is needed as some Wide-SCSI device might=20 behave nasty if asked for odd lengths. We had a rather lengthy bugzilla for it and even Patrick agreed that=20 this is a good thing. Patrick, is this correct? If so, could you also apply it for the scsi_id=20 program? Cheers, Hannes --=20 Dr. Hannes Reinecke hare@suse.de SuSE Linux AG S390 & zSeries Maxfeldstra=DFe 5 +49 911 74053 688 90409 N=FCrnberg http://www.suse.de --------------020609050300000503090804 Content-Type: text/x-patch; name="udev-021-maxlen.patch" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="udev-021-maxlen.patch" 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 --------------020609050300000503090804-- ------------------------------------------------------- This SF.Net email is sponsored by BEA Weblogic Workshop FREE Java Enterprise J2EE developer tools! Get your free copy of BEA WebLogic Workshop 8.1 today. http://ads.osdn.com/?ad_id=4721&alloc_id=10040&op=click _______________________________________________ Linux-hotplug-devel mailing list http://linux-hotplug.sourceforge.net Linux-hotplug-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel