Commit 7bc2b55a authored by Dan Carpenter's avatar Dan Carpenter Committed by Martin K. Petersen

scsi: arcmsr: Buffer overflow in arcmsr_iop_message_xfer()

We need to put an upper bound on "user_len" so the memcpy() doesn't
overflow.

Cc: <stable@vger.kernel.org>
Reported-by: default avatarMarco Grassi <marco.gra@gmail.com>
Signed-off-by: default avatarDan Carpenter <dan.carpenter@oracle.com>
Reviewed-by: default avatarTomas Henzl <thenzl@redhat.com>
Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
parent 38247feb
...@@ -2388,7 +2388,8 @@ static int arcmsr_iop_message_xfer(struct AdapterControlBlock *acb, ...@@ -2388,7 +2388,8 @@ static int arcmsr_iop_message_xfer(struct AdapterControlBlock *acb,
} }
case ARCMSR_MESSAGE_WRITE_WQBUFFER: { case ARCMSR_MESSAGE_WRITE_WQBUFFER: {
unsigned char *ver_addr; unsigned char *ver_addr;
int32_t user_len, cnt2end; uint32_t user_len;
int32_t cnt2end;
uint8_t *pQbuffer, *ptmpuserbuffer; uint8_t *pQbuffer, *ptmpuserbuffer;
ver_addr = kmalloc(ARCMSR_API_DATA_BUFLEN, GFP_ATOMIC); ver_addr = kmalloc(ARCMSR_API_DATA_BUFLEN, GFP_ATOMIC);
if (!ver_addr) { if (!ver_addr) {
...@@ -2397,6 +2398,11 @@ static int arcmsr_iop_message_xfer(struct AdapterControlBlock *acb, ...@@ -2397,6 +2398,11 @@ static int arcmsr_iop_message_xfer(struct AdapterControlBlock *acb,
} }
ptmpuserbuffer = ver_addr; ptmpuserbuffer = ver_addr;
user_len = pcmdmessagefld->cmdmessage.Length; user_len = pcmdmessagefld->cmdmessage.Length;
if (user_len > ARCMSR_API_DATA_BUFLEN) {
retvalue = ARCMSR_MESSAGE_FAIL;
kfree(ver_addr);
goto message_out;
}
memcpy(ptmpuserbuffer, memcpy(ptmpuserbuffer,
pcmdmessagefld->messagedatabuffer, user_len); pcmdmessagefld->messagedatabuffer, user_len);
spin_lock_irqsave(&acb->wqbuffer_lock, flags); spin_lock_irqsave(&acb->wqbuffer_lock, flags);
......
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