[PATCH 06/17] mpi3mr: Fix out-of-bounds reply frame access
Chandrakanth Patil <[email protected]>
| Newsgroups | org.kernel.vger.linux-scsi |
|---|---|
| Message-ID | <[email protected]> |
The reply frame address reported on completion is only checked against
the start and the end of the pool. An address near the top can pass the
check while leaving less than a full frame, and an unaligned one
resolves into the middle of a frame instead of the start of one.
Require a whole frame to fit and the address to be frame aligned.
Fixes: 824a156633df ("scsi: mpi3mr: Base driver code")
Signed-off-by: Chandrakanth Patil <[email protected]>
---
drivers/scsi/mpi3mr/mpi3mr_fw.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/drivers/scsi/mpi3mr/mpi3mr_fw.c b/drivers/scsi/mpi3mr/mpi3mr_fw.c
index 681868716ebd..5e61448d8dbc 100644
--- a/drivers/scsi/mpi3mr/mpi3mr_fw.c
+++ b/drivers/scsi/mpi3mr/mpi3mr_fw.c
@@ -128,7 +128,8 @@ void *mpi3mr_get_reply_virt_addr(struct mpi3mr_ioc *mrioc,
return NULL;
if ((phys_addr < mrioc->reply_buf_dma) ||
- (phys_addr > mrioc->reply_buf_dma_max_address))
+ (phys_addr > mrioc->reply_buf_dma_max_address - mrioc->reply_sz) ||
+ ((phys_addr - mrioc->reply_buf_dma) % mrioc->reply_sz))
return NULL;
return mrioc->reply_buf + (phys_addr - mrioc->reply_buf_dma);