Received: from eggs.gnu.org ([2001:4830:134:3::10]:55854) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bDlGD-0002Rk-Sl for qemu-devel@nongnu.org; Fri, 17 Jun 2016 00:20:02 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bDlG9-0004Va-L8 for qemu-devel@nongnu.org; Fri, 17 Jun 2016 00:20:00 -0400 Received: from mx1.redhat.com ([209.132.183.28]:55812) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bDlG9-0004VG-FM for qemu-devel@nongnu.org; Fri, 17 Jun 2016 00:19:57 -0400 Date: Fri, 17 Jun 2016 09:49:52 +0530 From: Amit Shah Message-ID: <20160617041952.GG29599@grmbl.mre> References: <1466012179-31839-1-git-send-email-ppandit@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1466012179-31839-1-git-send-email-ppandit@redhat.com> Subject: Re: [Qemu-devel] [PATCH v4] scsi: esp: check length before dma read List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: P J P Cc: Qemu Developers , Paolo Bonzini , Li Qiang , Prasad J Pandit , Laszlo Ersek Hi, On (Wed) 15 Jun 2016 [23:06:19], P J P wrote: > From: Prasad J Pandit > > While doing DMA read into ESP command buffer 's->cmdbuf', it could > write past the 's->cmdbuf' area, if it was partially filled; > ie. 's->cmdlen' wasn't set at the start of the buffer. > Check 'len' to avoid OOB access. Also increase the command buffer > size to 32, which is maximum when 's->do_cmd' is set. > > Reported-by: Li Qiang > Signed-off-by: Prasad J Pandit [...] > diff --git a/include/hw/scsi/esp.h b/include/hw/scsi/esp.h > index 6c79527..d2c4886 100644 > --- a/include/hw/scsi/esp.h > +++ b/include/hw/scsi/esp.h > @@ -14,6 +14,7 @@ void esp_init(hwaddr espaddr, int it_shift, > > #define ESP_REGS 16 > #define TI_BUFSZ 16 > +#define ESP_CMDBUF_SZ 32 > > typedef struct ESPState ESPState; > > @@ -31,7 +32,7 @@ struct ESPState { > SCSIBus bus; > SCSIDevice *current_dev; > SCSIRequest *current_req; > - uint8_t cmdbuf[TI_BUFSZ]; > + uint8_t cmdbuf[ESP_CMDBUF_SZ]; This was flagged as an incompatibility in the vmstate by a nightly run of the vmstate checker: Section "esp" Description "esp" Field "cmdbuf" size mismatch: 16 , 32 Section "dc390" Description "esp" Field "cmdbuf" size mismatch: 16 , 32 Section "am53c974" Description "esp" Field "cmdbuf" size mismatch: 16 , 32 Amit