scsi: esp: check TI buffer index before read/write
commit236039b89da8cf0a82fe32e605c1d647a13820f0
authorPrasad J Pandit <pjp@fedoraproject.org>
Mon, 6 Jun 2016 16:34:43 +0000 (6 22:04 +0530)
committerMichael Roth <mdroth@linux.vnet.ibm.com>
Tue, 9 Aug 2016 21:01:08 +0000 (9 16:01 -0500)
treeeeb13cdfdcbd3480455165eed116a699dac7d07a
parent407fb6fce916b8984b5fd288b4a97d61f014dc72
scsi: esp: check TI buffer index before read/write

The 53C9X Fast SCSI Controller(FSC) comes with internal 16-byte
FIFO buffers. One is used to handle commands and other is for
information transfer. Three control variables 'ti_rptr',
'ti_wptr' and 'ti_size' are used to control r/w access to the
information transfer buffer ti_buf[TI_BUFSZ=16]. In that,

'ti_rptr' is used as read index, where read occurs.
'ti_wptr' is a write index, where write would occur.
'ti_size' indicates total bytes to be read from the buffer.

While reading/writing to this buffer, index could exceed its
size. Add check to avoid OOB r/w access.

Reported-by: Huawei PSIRT <psirt@huawei.com>
Reported-by: Li Qiang <liqiang6-s@360.cn>
Signed-off-by: Prasad J Pandit <pjp@fedoraproject.org>
Message-Id: <1465230883-22303-1-git-send-email-ppandit@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
(cherry picked from commit ff589551c8e8e9e95e211b9d8daafb4ed39f1aec)
Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
hw/scsi/esp.c