Commit bcf2227c authored by Patrick Mansfield's avatar Patrick Mansfield Committed by James Bottomley

[PATCH] fix scsi_mode_data length result

I have some Seagate drives that apparently return to much data when asked
for 31 bytes for a MODE SENSE cache page, resulting in buffer overruns.
Requests for 4 bytes work fine.

Changing __scsi_mode_sense to correctly set the scsi_mode_data length
per the following patch fixed the problem for me.
parent 892af51c
......@@ -1426,14 +1426,14 @@ __scsi_mode_sense(struct scsi_request *sreq, int dbd, int modepage,
if(scsi_status_is_good(sreq->sr_result)) {
data->header_length = header_length;
if(use_10_for_ms) {
data->length = buffer[0]*256 + buffer[1];
data->length = buffer[0]*256 + buffer[1] + 2;
data->medium_type = buffer[2];
data->device_specific = buffer[3];
data->longlba = buffer[4] & 0x01;
data->block_descriptor_length = buffer[6]*256
+ buffer[7];
} else {
data->length = buffer[0];
data->length = buffer[0] + 1;
data->medium_type = buffer[1];
data->device_specific = buffer[3];
data->block_descriptor_length = buffer[4];
......
......@@ -56,7 +56,7 @@ extern void scsi_do_req(struct scsi_request *, const void *cmnd,
int timeout, int retries);
struct scsi_mode_data {
__u16 length;
__u32 length;
__u16 block_descriptor_length;
__u8 medium_type;
__u8 device_specific;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment