From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id B1B5DA0350; Tue, 23 Jun 2020 18:41:19 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id AC86B1D6B4; Tue, 23 Jun 2020 18:41:18 +0200 (CEST) Received: from mga06.intel.com (mga06.intel.com [134.134.136.31]) by dpdk.org (Postfix) with ESMTP id 201491D6AC for ; Tue, 23 Jun 2020 18:41:16 +0200 (CEST) IronPort-SDR: dAdPp3JoO1hAUsuxzZpIQ9uukQw3i7ls+68MbCY0daZFKN9GA2ZiXj0YG12CyVNzfsmykN3zy9 PXhBu/OwRugQ== X-IronPort-AV: E=McAfee;i="6000,8403,9661"; a="205647162" X-IronPort-AV: E=Sophos;i="5.75,271,1589266800"; d="scan'208";a="205647162" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 23 Jun 2020 09:41:15 -0700 IronPort-SDR: g5bSSMksGjO+V5n2GTJiHeUqP4u4/TbrxwkKb4DRvXD6pOc/lzHAsBuNjvjYdr2ml4pWJ4NilH Hk5h53m62nYw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.75,271,1589266800"; d="scan'208";a="319202793" Received: from silpixa00399752.ir.intel.com (HELO silpixa00399752.ger.corp.intel.com) ([10.237.222.180]) by FMSMGA003.fm.intel.com with ESMTP; 23 Jun 2020 09:41:13 -0700 From: Ferruh Yigit To: Thomas Monjalon , Andrew Rybchenko Cc: dev@dpdk.org, Ferruh Yigit , Renata Saiakhova , Anatoly Burakov Date: Tue, 23 Jun 2020 17:41:11 +0100 Message-Id: <20200623164111.1939144-1-ferruh.yigit@intel.com> X-Mailer: git-send-email 2.25.4 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [dpdk-dev] [PATCH] ethdev: verify reserved HW ring 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" Function 'rte_eth_dma_zone_reserve()' returns an existing memzone based on name match, but other requested attributes are discarded. This may cause driver using a memzone with wrong size or alignment. Verify size, alignment and socket_id for matched memzone, and do not use memzone if any one of the attributes are not justified. Reported-by: Renata Saiakhova Signed-off-by: Ferruh Yigit --- Cc: Anatoly Burakov --- lib/librte_ethdev/rte_ethdev.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/lib/librte_ethdev/rte_ethdev.c b/lib/librte_ethdev/rte_ethdev.c index 8e10a6fc3..0fe84aadc 100644 --- a/lib/librte_ethdev/rte_ethdev.c +++ b/lib/librte_ethdev/rte_ethdev.c @@ -4202,8 +4202,18 @@ rte_eth_dma_zone_reserve(const struct rte_eth_dev *dev, const char *ring_name, } mz = rte_memzone_lookup(z_name); - if (mz) + if (mz) { + if ((socket_id != SOCKET_ID_ANY && socket_id != mz->socket_id) || + size > mz->len || + (uintptr_t)mz->addr & (align - 1)) { + RTE_ETHDEV_LOG(ERR, + "memzone %s does not justify the requested attributes\n", + mz->name); + return NULL; + } + return mz; + } return rte_memzone_reserve_aligned(z_name, size, socket_id, RTE_MEMZONE_IOVA_CONTIG, align); -- 2.25.4