From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41795) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Vnsmx-0005wO-SC for qemu-devel@nongnu.org; Tue, 03 Dec 2013 11:25:37 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Vnsmr-0006md-Qp for qemu-devel@nongnu.org; Tue, 03 Dec 2013 11:25:31 -0500 Date: Tue, 3 Dec 2013 18:28:53 +0200 From: "Michael S. Tsirkin" Message-ID: <1386087086-3691-13-git-send-email-mst@redhat.com> References: <1386087086-3691-1-git-send-email-mst@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1386087086-3691-1-git-send-email-mst@redhat.com> Subject: [Qemu-devel] [PATCH 12/23] stellaris_enet: avoid buffer orerrun on incoming migration (part 3) List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Peter Maydell , qemu-stable@nongnu.org, Michael Roth From: Michael Roth CVE-2013-4532 s->tx_frame_len is read from the wire and can later used as an index into s->tx_fifo[] for memset() when a DATA command is issued by the guest. In this case s->tx_frame_len is checked to avoid an overrun, but if the value is negative a subsequently executed guest can underrun the buffer with zeros via the memset() call. Fix this by failing migration if the incoming value is of s->tx_frame_len is less than -1 (the emulation code allows from -1 as a special case) Signed-off-by: Michael Roth Signed-off-by: Michael S. Tsirkin --- hw/net/stellaris_enet.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/hw/net/stellaris_enet.c b/hw/net/stellaris_enet.c index 65f0ba8..6eca31e 100644 --- a/hw/net/stellaris_enet.c +++ b/hw/net/stellaris_enet.c @@ -375,6 +375,9 @@ static int stellaris_enet_load(QEMUFile *f, void *opaque, int version_id) s->mrxd = qemu_get_be32(f); s->np = qemu_get_be32(f); s->tx_frame_len = qemu_get_be32(f); + if (s->tx_frame_len < -1) { + return -EINVAL; + } s->tx_fifo_len = qemu_get_be32(f); if (s->tx_fifo_len < 0 || s->tx_fifo_len > SE_FIFO_LEN) { return -EINVAL; -- MST