From patchwork Tue Aug 9 07:34:32 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Wang X-Patchwork-Id: 657137 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3s7mL256XKz9s3s for ; Tue, 9 Aug 2016 17:36:10 +1000 (AEST) Received: from localhost ([::1]:33984 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bX1a4-000228-Kx for incoming@patchwork.ozlabs.org; Tue, 09 Aug 2016 03:36:08 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48688) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bX1Yi-00011O-QA for qemu-devel@nongnu.org; Tue, 09 Aug 2016 03:34:45 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bX1Yh-0003hD-Uc for qemu-devel@nongnu.org; Tue, 09 Aug 2016 03:34:44 -0400 Received: from mx1.redhat.com ([209.132.183.28]:53168) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bX1Yh-0003h0-PK for qemu-devel@nongnu.org; Tue, 09 Aug 2016 03:34:43 -0400 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id D78973919C4; Tue, 9 Aug 2016 07:34:42 +0000 (UTC) Received: from jason-ThinkPad-T450s.redhat.com (vpn1-4-112.pek2.redhat.com [10.72.4.112]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u797YYPW006454; Tue, 9 Aug 2016 03:34:40 -0400 From: Jason Wang To: qemu-devel@nongnu.org, peter.maydell@linaro.org Date: Tue, 9 Aug 2016 15:34:32 +0800 Message-Id: <1470728073-30141-3-git-send-email-jasowang@redhat.com> In-Reply-To: <1470728073-30141-1-git-send-email-jasowang@redhat.com> References: <1470728073-30141-1-git-send-email-jasowang@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Tue, 09 Aug 2016 07:34:43 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 2/3] net: vmxnet3: check for device_active before write X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Jason Wang , Li Qiang , Prasad J Pandit Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Li Qiang Vmxnet3 device emulator does not check if the device is active, before using it for write. It leads to a use after free issue, if the vmxnet3_io_bar0_write routine is called after the device is deactivated. Add check to avoid it. Reported-by: Li Qiang Signed-off-by: Prasad J Pandit Acked-by: Dmitry Fleytman Signed-off-by: Jason Wang --- hw/net/vmxnet3.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/hw/net/vmxnet3.c b/hw/net/vmxnet3.c index bbf44ad..90f6943 100644 --- a/hw/net/vmxnet3.c +++ b/hw/net/vmxnet3.c @@ -1167,6 +1167,10 @@ vmxnet3_io_bar0_write(void *opaque, hwaddr addr, { VMXNET3State *s = opaque; + if (!s->device_active) { + return; + } + if (VMW_IS_MULTIREG_ADDR(addr, VMXNET3_REG_TXPROD, VMXNET3_DEVICE_MAX_TX_QUEUES, VMXNET3_REG_ALIGN)) { int tx_queue_idx =