From patchwork Wed Apr 3 16:07:26 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mohammad Abdul Awal X-Patchwork-Id: 52205 Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 0D3C51B483; Wed, 3 Apr 2019 18:08:01 +0200 (CEST) Received: from mga06.intel.com (mga06.intel.com [134.134.136.31]) by dpdk.org (Postfix) with ESMTP id 33BEF1B45B; Wed, 3 Apr 2019 18:07:59 +0200 (CEST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga003.jf.intel.com ([10.7.209.27]) by orsmga104.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 03 Apr 2019 09:07:58 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.60,305,1549958400"; d="scan'208";a="139687837" Received: from awal-z170x.ir.intel.com ([163.33.210.59]) by orsmga003.jf.intel.com with ESMTP; 03 Apr 2019 09:07:56 -0700 From: Mohammad Abdul Awal To: dev@dpdk.org Cc: thomas@monjalon.net, ferruh.yigit@intel.com, arybchenko@solarflare.com, Mohammad Abdul Awal , stable@dpdk.org Date: Wed, 3 Apr 2019 17:07:26 +0100 Message-Id: <20190403160726.1231-1-mohammad.abdul.awal@intel.com> X-Mailer: git-send-email 2.17.1 Subject: [dpdk-dev] [PATCH 1/3] ethdev: fix null pointer checking 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: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Null value for parameter name will cause segfault for the strnlen and strcmp functions. Fixes: 0b33b68d12 ("ethdev: export allocate function") Fixes: 942661004c ("ethdev: export secondary attach function") Cc: stable@dpdk.org Signed-off-by: Mohammad Abdul Awal --- lib/librte_ethdev/rte_ethdev.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/lib/librte_ethdev/rte_ethdev.c b/lib/librte_ethdev/rte_ethdev.c index 10bdfb37e..26898ed08 100644 --- a/lib/librte_ethdev/rte_ethdev.c +++ b/lib/librte_ethdev/rte_ethdev.c @@ -440,6 +440,11 @@ rte_eth_dev_allocate(const char *name) struct rte_eth_dev *eth_dev = NULL; size_t name_len; + if (name == NULL) { + RTE_ETHDEV_LOG(ERR, "Null pointer is specified\n"); + return NULL; + } + name_len = strnlen(name, RTE_ETH_NAME_MAX_LEN); if (name_len == 0) { RTE_ETHDEV_LOG(ERR, "Zero length Ethernet device name\n"); @@ -492,6 +497,11 @@ rte_eth_dev_attach_secondary(const char *name) uint16_t i; struct rte_eth_dev *eth_dev = NULL; + if (name == NULL) { + RTE_ETHDEV_LOG(ERR, "Null pointer is specified\n"); + return NULL; + } + rte_eth_dev_shared_data_prepare(); /* Synchronize port attachment to primary port creation and release. */ From patchwork Wed Apr 3 16:08:11 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mohammad Abdul Awal X-Patchwork-Id: 52206 Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 06E061B48E; Wed, 3 Apr 2019 18:08:40 +0200 (CEST) Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) by dpdk.org (Postfix) with ESMTP id 0E44D1B447 for ; Wed, 3 Apr 2019 18:08:37 +0200 (CEST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmsmga106.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 03 Apr 2019 09:08:37 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.60,305,1549958400"; d="scan'208";a="147742069" Received: from awal-z170x.ir.intel.com ([163.33.210.59]) by orsmga002.jf.intel.com with ESMTP; 03 Apr 2019 09:08:35 -0700 From: Mohammad Abdul Awal To: dev@dpdk.org Cc: maxime.coquelin@redhat.com, tiwei.bie@intel.com, zhihong.wang@intel.com, Mohammad Abdul Awal Date: Wed, 3 Apr 2019 17:08:11 +0100 Message-Id: <20190403160811.1282-1-mohammad.abdul.awal@intel.com> X-Mailer: git-send-email 2.17.1 Subject: [dpdk-dev] [PATCH 2/3] net/virtio: fix null pointer checking 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: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Null value of device name should return error without further processing. Fixes: 1c8489da56 ("net/virtio-user: fix multi-process support") Signed-off-by: Mohammad Abdul Awal --- drivers/net/virtio/virtio_user_ethdev.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/net/virtio/virtio_user_ethdev.c b/drivers/net/virtio/virtio_user_ethdev.c index 129c2b9ef..cefc6da66 100644 --- a/drivers/net/virtio/virtio_user_ethdev.c +++ b/drivers/net/virtio/virtio_user_ethdev.c @@ -516,6 +516,10 @@ virtio_user_pmd_probe(struct rte_vdev_device *dev) if (rte_eal_process_type() == RTE_PROC_SECONDARY) { const char *name = rte_vdev_device_name(dev); + if (name == NULL) { + RTE_LOG(ERR, PMD, "Device name is NULL\n"); + return -1; + } eth_dev = rte_eth_dev_attach_secondary(name); if (!eth_dev) { RTE_LOG(ERR, PMD, "Failed to probe %s\n", name); From patchwork Wed Apr 3 16:08:23 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mohammad Abdul Awal X-Patchwork-Id: 52207 X-Patchwork-Delegate: maxime.coquelin@redhat.com Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 085831B4CB; Wed, 3 Apr 2019 18:08:52 +0200 (CEST) Received: from mga06.intel.com (mga06.intel.com [134.134.136.31]) by dpdk.org (Postfix) with ESMTP id ED90F1B4B9; Wed, 3 Apr 2019 18:08:49 +0200 (CEST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga002.jf.intel.com ([10.7.209.21]) by orsmga104.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 03 Apr 2019 09:08:49 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.60,305,1549958400"; d="scan'208";a="147742116" Received: from awal-z170x.ir.intel.com ([163.33.210.59]) by orsmga002.jf.intel.com with ESMTP; 03 Apr 2019 09:08:47 -0700 From: Mohammad Abdul Awal To: dev@dpdk.org Cc: maxime.coquelin@redhat.com, tiwei.bie@intel.com, zhihong.wang@intel.com, Mohammad Abdul Awal , stable@dpdk.org Date: Wed, 3 Apr 2019 17:08:23 +0100 Message-Id: <20190403160823.1337-1-mohammad.abdul.awal@intel.com> X-Mailer: git-send-email 2.17.1 Subject: [dpdk-dev] [PATCH 3/3] vhost: fix null pointer checking 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: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Null value for parameters will cause segfault. Fuxes: d7280c9fff ("vhost: support selective datapath") Fixes: 72e8543093 ("vhost: add external message handling to the API") Fixes: a277c71598 ("vhost: refactor code structure") Fixes: ca33faf9ef ("vhost: introduce API to fetch negotiated features") Fixes: eb32247457 ("vhost: export guest memory regions") Fixes: 40ef286f23 ("vhost: export vhost vring info") Fixes: bd2e0c3fe5 ("vhost: add APIs for live migration") Fixes: 0b8572a0c1 ("vhost: add external message handling to the API") Cc: stable@dpdk.org Signed-off-by: Mohammad Abdul Awal --- lib/librte_vhost/vdpa.c | 5 ++++- lib/librte_vhost/vhost.c | 16 ++++++++-------- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/lib/librte_vhost/vdpa.c b/lib/librte_vhost/vdpa.c index 321e11f17..814082479 100644 --- a/lib/librte_vhost/vdpa.c +++ b/lib/librte_vhost/vdpa.c @@ -49,7 +49,7 @@ rte_vdpa_register_device(struct rte_vdpa_dev_addr *addr, char device_name[MAX_VDPA_NAME_LEN]; int i; - if (vdpa_device_num >= MAX_VHOST_DEVICE) + if (vdpa_device_num >= MAX_VHOST_DEVICE || !addr || !ops) return -1; for (i = 0; i < MAX_VHOST_DEVICE; i++) { @@ -99,6 +99,9 @@ rte_vdpa_find_device_id(struct rte_vdpa_dev_addr *addr) struct rte_vdpa_device *dev; int i; + if (!addr) + return -1; + for (i = 0; i < MAX_VHOST_DEVICE; ++i) { dev = vdpa_devices[i]; if (dev && is_same_vdpa_device(&dev->addr, addr)) diff --git a/lib/librte_vhost/vhost.c b/lib/librte_vhost/vhost.c index e480aeac9..27fe87188 100644 --- a/lib/librte_vhost/vhost.c +++ b/lib/librte_vhost/vhost.c @@ -447,7 +447,7 @@ rte_vhost_get_mtu(int vid, uint16_t *mtu) { struct virtio_net *dev = get_device(vid); - if (!dev) + if (!dev || !mtu) return -ENODEV; if (!(dev->flags & VIRTIO_DEV_READY)) @@ -515,7 +515,7 @@ rte_vhost_get_ifname(int vid, char *buf, size_t len) { struct virtio_net *dev = get_device(vid); - if (dev == NULL) + if (dev == NULL || !buf) return -1; len = RTE_MIN(len, sizeof(dev->ifname)); @@ -532,7 +532,7 @@ rte_vhost_get_negotiated_features(int vid, uint64_t *features) struct virtio_net *dev; dev = get_device(vid); - if (!dev) + if (!dev || !features) return -1; *features = dev->features; @@ -547,7 +547,7 @@ rte_vhost_get_mem_table(int vid, struct rte_vhost_memory **mem) size_t size; dev = get_device(vid); - if (!dev) + if (!dev || !mem) return -1; size = dev->mem->nregions * sizeof(struct rte_vhost_mem_region); @@ -570,7 +570,7 @@ rte_vhost_get_vhost_vring(int vid, uint16_t vring_idx, struct vhost_virtqueue *vq; dev = get_device(vid); - if (!dev) + if (!dev || !vring) return -1; if (vring_idx >= VHOST_MAX_VRING) @@ -763,7 +763,7 @@ int rte_vhost_get_log_base(int vid, uint64_t *log_base, { struct virtio_net *dev = get_device(vid); - if (!dev) + if (!dev || !log_base || !log_size) return -1; *log_base = dev->log_base; @@ -777,7 +777,7 @@ int rte_vhost_get_vring_base(int vid, uint16_t queue_id, { struct virtio_net *dev = get_device(vid); - if (!dev) + if (!dev || !last_avail_idx || !last_used_idx) return -1; *last_avail_idx = dev->virtqueue[queue_id]->last_avail_idx; @@ -805,7 +805,7 @@ int rte_vhost_extern_callback_register(int vid, { struct virtio_net *dev = get_device(vid); - if (!dev) + if (!dev || !ops) return -1; dev->extern_ops = *ops;