summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHighPoint Linux Team <linux@highpoint-tech.com>2007-10-16 14:28:24 -0700
committerGreg Kroah-Hartman <gregkh@suse.de>2007-11-16 09:30:24 -0800
commit236fc43928d4aa33065d41ee830896b56e45c477 (patch)
treeba548960818ce919e506f2cc4018c28e7038eeee
parent958765ad56cf9e4bf8898c625e1ffa454c1837a7 (diff)
hptiop: avoid buffer overflow when returning sense data
patch 0fec02c93f60fb44ba3a24a0d3e4a52521d34d3f in mainline. avoid buffer overflow when returning sense data. With current adapter firmware the driver is working but future firmware updates may return sense data larger than 96 bytes, causing overflow on scp->sense_buffer and a kernel crash. This fix should be backported to earlier kernels. Signed-off-by: HighPoint Linux Team <linux@highpoint-tech.com> Signed-off-by: James Bottomley <James.Bottomley@steeleye.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
-rw-r--r--drivers/scsi/hptiop.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/drivers/scsi/hptiop.c b/drivers/scsi/hptiop.c
index 0e579ca45814..ffdd0da55547 100644
--- a/drivers/scsi/hptiop.c
+++ b/drivers/scsi/hptiop.c
@@ -365,8 +365,9 @@ static void hptiop_host_request_callback(struct hptiop_hba *hba, u32 tag)
scp->result = SAM_STAT_CHECK_CONDITION;
memset(&scp->sense_buffer,
0, sizeof(scp->sense_buffer));
- memcpy(&scp->sense_buffer,
- &req->sg_list, le32_to_cpu(req->dataxfer_length));
+ memcpy(&scp->sense_buffer, &req->sg_list,
+ min(sizeof(scp->sense_buffer),
+ le32_to_cpu(req->dataxfer_length)));
break;
default: