Commit 041761f4 authored by Kees Cook's avatar Kees Cook Committed by Martin K. Petersen

scsi: aha1740: Avoid over-read of sense buffer

In preparation for FORTIFY_SOURCE performing compile-time and run-time
field bounds checking for memcpy(), memmove(), and memset(), avoid
intentionally reading across neighboring array fields.

SCtmp->sense_buffer is 96 bytes, but ecbptr->sense is 14 bytes. Instead of
over-reading ecbptr->sense, copy only the actual contents and zero pad the
remaining bytes, avoiding potential over-reads.

Link: https://lore.kernel.org/r/20210616212437.1727088-1-keescook@chromium.orgSigned-off-by: default avatarKees Cook <keescook@chromium.org>
Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
parent 86a6a0bd
...@@ -267,8 +267,11 @@ static irqreturn_t aha1740_intr_handle(int irq, void *dev_id) ...@@ -267,8 +267,11 @@ static irqreturn_t aha1740_intr_handle(int irq, void *dev_id)
guarantee that we will still have it in the guarantee that we will still have it in the
cdb when we come back */ cdb when we come back */
if ( (adapstat & G2INTST_MASK) == G2INTST_CCBERROR ) { if ( (adapstat & G2INTST_MASK) == G2INTST_CCBERROR ) {
memcpy(SCtmp->sense_buffer, ecbptr->sense, memcpy_and_pad(SCtmp->sense_buffer,
SCSI_SENSE_BUFFERSIZE); SCSI_SENSE_BUFFERSIZE,
ecbptr->sense,
sizeof(ecbptr->sense),
0);
errstatus = aha1740_makecode(ecbptr->sense,ecbptr->status); errstatus = aha1740_makecode(ecbptr->sense,ecbptr->status);
} else } else
errstatus = 0; errstatus = 0;
......
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