From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by dpdk.org (Postfix) with ESMTP id 699A0CF90 for ; Tue, 14 Mar 2017 09:30:05 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=intel.com; i=@intel.com; q=dns/txt; s=intel; t=1489480205; x=1521016205; h=date:from:to:cc:subject:message-id:references: mime-version:in-reply-to; bh=O5AxP2FvmRZ3so8y0ITHkpmfSxP6QX793LKzj/FKsRw=; b=wUAFFbcQK86ckC9qUlATqmhY3h3xb097fkVtZQpsG7iI0plFKURi5mjX rohmYen1Nca/L2Dsr5LbQMeVaNRN1Q==; Received: from orsmga004.jf.intel.com ([10.7.209.38]) by fmsmga103.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 14 Mar 2017 01:30:04 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.36,162,1486454400"; d="scan'208";a="67201553" Received: from yliu-dev.sh.intel.com (HELO yliu-dev) ([10.239.67.162]) by orsmga004.jf.intel.com with ESMTP; 14 Mar 2017 01:30:03 -0700 Date: Tue, 14 Mar 2017 16:28:13 +0800 From: Yuanhan Liu To: Wenfeng Liu Cc: maxime.coquelin@redhat.com, dev@dpdk.org, "'Tan, Jianfeng'" Message-ID: <20170314082813.GK18844@yliu-dev.sh.intel.com> References: <1489417755-17074-1-git-send-email-liuwf@arraynetworks.com.cn> <20170314064416.GI18844@yliu-dev.sh.intel.com> <005b01d29c9b$de9e83c0$9bdb8b40$@com.cn> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <005b01d29c9b$de9e83c0$9bdb8b40$@com.cn> User-Agent: Mutt/1.5.23 (2014-03-12) Subject: Re: [dpdk-dev] =?utf-8?b?562U5aSNOiBbUEFUQ0hdIG5ldC92aXJ0aW8tdXNlcjog?= =?utf-8?q?fix_overflow?= X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 14 Mar 2017 08:30:05 -0000 On Tue, Mar 14, 2017 at 04:20:39PM +0800, Wenfeng Liu wrote: > Hi Yuanhan, > > >On Mon, Mar 13, 2017 at 03:09:15PM +0000, Wenfeng Liu wrote: > >> This commit fixes an array overflow when number of queues is higher than > 8. > > > >Firstly, this commit log could be a bit more informative, to something > >like: > > > > virtio-user limits the qeueue number to 8 but provides no limit > > check against the queue number input from user. If a bigger queue > > number (> 8) is given, there is an overflow issue. Doing a sanity > > check could avoid it. > > > > Sure, I will revise the commit log accordingly. > > >> > >> Fixes: 37a7eb2ae816 ("net/virtio-user: add device emulation layer") > >> > >> Signed-off-by: Wenfeng Liu > >> --- > >> drivers/net/virtio/virtio_pci.h | 3 ++- > >> drivers/net/virtio/virtio_user/virtio_user_dev.c | 2 +- > >> drivers/net/virtio/virtio_user/virtio_user_dev.h | 6 +++--- > >> drivers/net/virtio/virtio_user_ethdev.c | 7 +++++++ > >> 4 files changed, 13 insertions(+), 5 deletions(-) > >> > >> diff --git a/drivers/net/virtio/virtio_pci.h > >> b/drivers/net/virtio/virtio_pci.h index 59e45c4..bd940b4 100644 > >> --- a/drivers/net/virtio/virtio_pci.h > >> +++ b/drivers/net/virtio/virtio_pci.h > >> @@ -160,7 +160,8 @@ > >> /* > >> * Maximum number of virtqueues per device. > >> */ > >> -#define VIRTIO_MAX_VIRTQUEUES 8 > >> +#define VIRTIO_MAX_VIRTQUEUE_PAIRS 8 > >> +#define VIRTIO_MAX_VIRTQUEUES VIRTIO_MAX_VIRTQUEUE_PAIRS * 2 + 1 > >> > >> /* Common configuration */ > >> #define VIRTIO_PCI_CAP_COMMON_CFG 1 > >> diff --git a/drivers/net/virtio/virtio_user/virtio_user_dev.c > >> b/drivers/net/virtio/virtio_user/virtio_user_dev.c > >> index e7fd65f..5b81676 100644 > >> --- a/drivers/net/virtio/virtio_user/virtio_user_dev.c > >> +++ b/drivers/net/virtio/virtio_user/virtio_user_dev.c > >> @@ -234,7 +234,7 @@ int virtio_user_stop_device(struct virtio_user_dev > *dev) > >> uint32_t i, q; > >> > >> dev->vhostfd = -1; > >> - for (i = 0; i < VIRTIO_MAX_VIRTQUEUES * 2 + 1; ++i) { > >> + for (i = 0; i < VIRTIO_MAX_VIRTQUEUES; ++i) { > > > >Right, we don't need setup callfd and kickfd for the ctrl-queue. > > I did not remove the ctrl-queue. I just redefined the MACRO according to DRY > principle: Oh, right, sorry, I overlooked it. Then for this patch, it's okay to me. > #define VIRTIO_MAX_VIRTQUEUES VIRTIO_MAX_VIRTQUEUE_PAIRS * 2 + 1 > I noticed that I missed the bracket in the MACRO and will add it in next > version. Yes, please. Also, please put a "Cc: stable@dpdk.org" before your Signed-of-by: it's a candidate for stable releases. --yliu