scsi: esp: check TI buffer index before read/write
commitff589551c8e8e9e95e211b9d8daafb4ed39f1aec
authorPrasad J Pandit <pjp@fedoraproject.org>
Mon, 6 Jun 2016 16:34:43 +0000 (6 22:04 +0530)
committerPaolo Bonzini <pbonzini@redhat.com>
Mon, 6 Jun 2016 16:57:15 +0000 (6 18:57 +0200)
treef69445ba7c289117434875f104dbaf65f9ab0a5b
parent4b3eec91b90346c57ec99694ddc806b70a54ff90
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>
hw/scsi/esp.c