]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
hptiop: avoid buffer overflow when returning sense data
authorHighPoint Linux Team <linux@highpoint-tech.com>
Tue, 16 Oct 2007 21:28:24 +0000 (14:28 -0700)
committerGreg Kroah-Hartman <gregkh@suse.de>
Fri, 16 Nov 2007 17:30:24 +0000 (09:30 -0800)
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>
drivers/scsi/hptiop.c

index 0e579ca45814d4a0794f99ba7594dfc315ff88b5..ffdd0da555476c6ee329dbe289d85cfbf6ace158 100644 (file)
@@ -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: