From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from huawei.com (szxga07-in.huawei.com [45.249.212.35]) by dpdk.org (Postfix) with ESMTP id 9D5802C55 for ; Sat, 27 Apr 2019 11:47:56 +0200 (CEST) Received: from DGGEMS407-HUB.china.huawei.com (unknown [172.30.72.58]) by Forcepoint Email with ESMTP id D3D79BC10941641A1AA1 for ; Sat, 27 Apr 2019 17:47:53 +0800 (CST) Received: from localhost (10.177.24.66) by DGGEMS407-HUB.china.huawei.com (10.3.19.207) with Microsoft SMTP Server id 14.3.439.0; Sat, 27 Apr 2019 17:47:47 +0800 From: wangyunjian To: CC: , Yunjian Wang Date: Sat, 27 Apr 2019 17:47:42 +0800 Message-ID: <1556358462-9920-1-git-send-email-wangyunjian@huawei.com> X-Mailer: git-send-email 1.9.5.msysgit.1 MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.177.24.66] X-CFilter-Loop: Reflected Subject: [dpdk-dev] [PATCH] ethdev: add size and align to compose dma zone name strings 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: Sat, 27 Apr 2019 09:48:06 -0000 From: Yunjian Wang The current dma zone name consists of the port_id, queue_id and ring_name. If a port_id is reused, a new nic maybe use same dma zone name. At this time, the zone size of the new driver is differnt. When the zone is reused, it may cause illegal access to memory. Signed-off-by: Yunjian Wang --- lib/librte_ethdev/rte_ethdev.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/librte_ethdev/rte_ethdev.c b/lib/librte_ethdev/rte_ethdev.c index d7cfa3d..0703cda 100644 --- a/lib/librte_ethdev/rte_ethdev.c +++ b/lib/librte_ethdev/rte_ethdev.c @@ -3630,9 +3630,9 @@ int rte_eth_set_queue_rate_limit(uint16_t port_id, uint16_t queue_idx, const struct rte_memzone *mz; int rc; - rc = snprintf(z_name, sizeof(z_name), "eth_p%d_q%d_%s", - dev->data->port_id, queue_id, ring_name); - if (rc >= RTE_MEMZONE_NAMESIZE) { + rc = snprintf(z_name, sizeof(z_name), "p%dq%d%s0x%zx_%d", + dev->data->port_id, queue_id, ring_name, size, align); + if (rc >= RTE_MEMZONE_NAMESIZE || rc < 0) { RTE_ETHDEV_LOG(ERR, "ring name too long\n"); rte_errno = ENAMETOOLONG; return NULL; -- 1.8.3.1 From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by dpdk.space (Postfix) with ESMTP id 85364A05D3 for ; Sat, 27 Apr 2019 11:48:09 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 371091B659; Sat, 27 Apr 2019 11:48:08 +0200 (CEST) Received: from huawei.com (szxga07-in.huawei.com [45.249.212.35]) by dpdk.org (Postfix) with ESMTP id 9D5802C55 for ; Sat, 27 Apr 2019 11:47:56 +0200 (CEST) Received: from DGGEMS407-HUB.china.huawei.com (unknown [172.30.72.58]) by Forcepoint Email with ESMTP id D3D79BC10941641A1AA1 for ; Sat, 27 Apr 2019 17:47:53 +0800 (CST) Received: from localhost (10.177.24.66) by DGGEMS407-HUB.china.huawei.com (10.3.19.207) with Microsoft SMTP Server id 14.3.439.0; Sat, 27 Apr 2019 17:47:47 +0800 From: wangyunjian To: CC: , Yunjian Wang Date: Sat, 27 Apr 2019 17:47:42 +0800 Message-ID: <1556358462-9920-1-git-send-email-wangyunjian@huawei.com> X-Mailer: git-send-email 1.9.5.msysgit.1 MIME-Version: 1.0 Content-Type: text/plain; charset="UTF-8" X-Originating-IP: [10.177.24.66] X-CFilter-Loop: Reflected Subject: [dpdk-dev] [PATCH] ethdev: add size and align to compose dma zone name strings 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" Message-ID: <20190427094742.jyUiQSZG26D6rqw428Xs8szbT4P1L0zUDzoFfLRu1Ok@z> From: Yunjian Wang The current dma zone name consists of the port_id, queue_id and ring_name. If a port_id is reused, a new nic maybe use same dma zone name. At this time, the zone size of the new driver is differnt. When the zone is reused, it may cause illegal access to memory. Signed-off-by: Yunjian Wang --- lib/librte_ethdev/rte_ethdev.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/librte_ethdev/rte_ethdev.c b/lib/librte_ethdev/rte_ethdev.c index d7cfa3d..0703cda 100644 --- a/lib/librte_ethdev/rte_ethdev.c +++ b/lib/librte_ethdev/rte_ethdev.c @@ -3630,9 +3630,9 @@ int rte_eth_set_queue_rate_limit(uint16_t port_id, uint16_t queue_idx, const struct rte_memzone *mz; int rc; - rc = snprintf(z_name, sizeof(z_name), "eth_p%d_q%d_%s", - dev->data->port_id, queue_id, ring_name); - if (rc >= RTE_MEMZONE_NAMESIZE) { + rc = snprintf(z_name, sizeof(z_name), "p%dq%d%s0x%zx_%d", + dev->data->port_id, queue_id, ring_name, size, align); + if (rc >= RTE_MEMZONE_NAMESIZE || rc < 0) { RTE_ETHDEV_LOG(ERR, "ring name too long\n"); rte_errno = ENAMETOOLONG; return NULL; -- 1.8.3.1