]> git.baikalelectronics.ru Git - kernel.git/commit
[SCSI] hpsa: fix potential overrun while memcpy'ing sense data
authorStephen M. Cameron <scameron@beardog.cce.hp.com>
Fri, 3 Jun 2011 14:57:34 +0000 (09:57 -0500)
committerJames Bottomley <JBottomley@Parallels.com>
Wed, 29 Jun 2011 17:09:56 +0000 (12:09 -0500)
commitea5eb956f2600db717353adfb2128d01c9ea1d07
treef6c18c036be2c0db91c432b80ad8f7c38e40200e
parentc1fe680b207a27598d7a5132f9eb84b65f5bf551
[SCSI] hpsa: fix potential overrun while memcpy'ing sense data

This memcpy:

   memcpy(cmd->sense_buffer, ei->SenseInfo,
   ei->SenseLen > SCSI_SENSE_BUFFERSIZE ?
   SCSI_SENSE_BUFFERSIZE :
   ei->SenseLen);

The ei->SenseLen field is filled in by the Smart Array.  For requests to
logical drives, it will not exceed 32 bytes, so should be ok, but for physical
requests it depends on the target device, not the Smart Array.  It's conceivable
that this could exceed the 32 byte size of ei->SenseInfo.  In that case, the memcpy
would read past the end of ei->SenseInfo, copying data from the next command,
as if it were sense data, or, if it happened to be the very last command in the
block of allocated commands, could fall off the end of the allocated area and
crash.  I'm not aware of anyone ever encountering this behavior, but it could
conceivably happen.  This bug was found by Coverity.

Signed-off-by: Stephen M. Cameron <scameron@beardog.cce.hp.com>
Signed-off-by: James Bottomley <JBottomley@Parallels.com>
drivers/scsi/hpsa.c