Received: from eggs.gnu.org ([2001:4830:134:3::10]:36214) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bXaGf-0005UJ-Hw for qemu-devel@nongnu.org; Wed, 10 Aug 2016 16:38:26 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bXaGb-0003aR-A9 for qemu-devel@nongnu.org; Wed, 10 Aug 2016 16:38:25 -0400 Received: from mx1.redhat.com ([209.132.183.28]:36832) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bXaGb-0003aL-4F for qemu-devel@nongnu.org; Wed, 10 Aug 2016 16:38:21 -0400 From: P J P Date: Thu, 11 Aug 2016 02:08:14 +0530 Message-Id: <1470861494-17834-1-git-send-email-ppandit@redhat.com> Subject: [Qemu-devel] [PATCH] net: vmxnet: check fragments count at pkt initialisation List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Qemu developers Cc: Li Qiang , Dmitry Fleytman , Jason Wang From: Li Qiang When net transport abstraction layer initialises the pkt, the maximum fragmentation count is not checked. This could lead to an integer overflow causing a NULL pointer dereference. Add check to avoid it. Reported-by: Li Qiang Signed-off-by: Prasad J Pandit --- hw/net/net_tx_pkt.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/hw/net/net_tx_pkt.c b/hw/net/net_tx_pkt.c index 53dfaa2..7ea3c17 100644 --- a/hw/net/net_tx_pkt.c +++ b/hw/net/net_tx_pkt.c @@ -58,9 +58,12 @@ struct NetTxPkt { bool is_loopback; }; +#define NET_PKT_MAX_FRAGS 16 /* ref: MAX_SKB_FRAGS in kernel driver */ + void net_tx_pkt_init(struct NetTxPkt **pkt, PCIDevice *pci_dev, uint32_t max_frags, bool has_virt_hdr) { + assert(max_frags <= NET_PKT_MAX_FRAGS); struct NetTxPkt *p = g_malloc0(sizeof *p); p->pci_dev = pci_dev; -- 2.5.5