Skip to content

Commit afe89f1

Browse files
thenzlmartinkpetersen
authored andcommitted
scsi: mptscsih: Fix read sense data size
The sense data buffer in sense_buf_pool is allocated with size of MPT_SENSE_BUFFER_ALLOC(64) (multiplied by req_depth) while SNS_LEN(sc)(96) is used when reading the data. That may lead to a read from unallocated area, sometimes from another (unallocated) page. To fix this, limit the read size to MPT_SENSE_BUFFER_ALLOC. Link: https://lore.kernel.org/r/[email protected] Co-developed-by: Stanislav Saner <[email protected]> Signed-off-by: Stanislav Saner <[email protected]> Signed-off-by: Tomas Henzl <[email protected]> Signed-off-by: Martin K. Petersen <[email protected]>
1 parent 936e6b8 commit afe89f1

File tree

1 file changed

+1
-3
lines changed

1 file changed

+1
-3
lines changed

drivers/message/fusion/mptscsih.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -118,8 +118,6 @@ int mptscsih_suspend(struct pci_dev *pdev, pm_message_t state);
118118
int mptscsih_resume(struct pci_dev *pdev);
119119
#endif
120120

121-
#define SNS_LEN(scp) SCSI_SENSE_BUFFERSIZE
122-
123121

124122
/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
125123
/*
@@ -2422,7 +2420,7 @@ mptscsih_copy_sense_data(struct scsi_cmnd *sc, MPT_SCSI_HOST *hd, MPT_FRAME_HDR
24222420
/* Copy the sense received into the scsi command block. */
24232421
req_index = le16_to_cpu(mf->u.frame.hwhdr.msgctxu.fld.req_idx);
24242422
sense_data = ((u8 *)ioc->sense_buf_pool + (req_index * MPT_SENSE_BUFFER_ALLOC));
2425-
memcpy(sc->sense_buffer, sense_data, SNS_LEN(sc));
2423+
memcpy(sc->sense_buffer, sense_data, MPT_SENSE_BUFFER_ALLOC);
24262424

24272425
/* Log SMART data (asc = 0x5D, non-IM case only) if required.
24282426
*/

0 commit comments

Comments
 (0)