• Stephen M. Cameron's avatar
    [SCSI] hpsa: fix potential overrun while memcpy'ing sense data · db111e18
    Stephen M. Cameron authored
    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: default avatarStephen M. Cameron <scameron@beardog.cce.hp.com>
    Signed-off-by: default avatarJames Bottomley <JBottomley@Parallels.com>
    db111e18
hpsa.c 124 KB