From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pf1-f194.google.com (mail-pf1-f194.google.com [209.85.210.194]) by dpdk.org (Postfix) with ESMTP id 8FDAD4CA7 for ; Tue, 23 Apr 2019 18:53:50 +0200 (CEST) Received: by mail-pf1-f194.google.com with SMTP id w25so7781969pfi.9 for ; Tue, 23 Apr 2019 09:53:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=uOyDKtvz7UbmBWCKoGXvUGPdqVmyNcBK16SpXqQX4cc=; b=aPQvCCt6ZBCxmBZ37xM7D/65eunzjFrBOyVP/p1n8zPZqG1HAuErQBpEHKQuZMtMWJ YTmLWamqpVmLx/8ch6s5iltLY7k8MD0Pyf8PWtQCHm/Oxg69j5f0Jy0418khsx8Us3sj qvnpq0G4WrG2zEOG8pZmjNdipKmyWCoxrzOUeCfSFFUIind+HS9iSFPjkcGyRFwY3Ca6 diotKqibx2+Q/eSSg/2g7lVtH71+HL1vQ/su2sX/9h1uAKq51hTEKn0CD2m5excLVJ8d A5EGBGoPNWTdn/6lzrpNTWTi5F8VmRU8Mu8jaI738GWfsjH2rlXSIsdl8k0hSCiqNJC1 BBcQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=uOyDKtvz7UbmBWCKoGXvUGPdqVmyNcBK16SpXqQX4cc=; b=AjSML8x2UOZRgpiL3edTKA/kUWPuZzO5WuuMjI+TOicZu4ny58VnQagvQ32LzOiWYI PPVv7F3L8749TNB7aUHIUNrKp+mdbTfCwQPoKQ725kK+HsV9a6pdLi6vIVaozY8cPZOE ehgZ9D6tMwip0QpKvjgKCjXDh7Tu+5YCexi4flA1dO6piLFDCLgM6pKtpZPbcCVarPjF Gix/pHZlYj3FEzmKs7i667aKY4zwK9SvuXlttFVPgaHMwKmGx7xcfp8QXRsRzFOZQSy5 B0aMvSpjH1aLykrB1TToUyP9BEa2Ny84pK/67UpxDhdkIv9HsiHJb+NOLC79ltZ6366a rlJg== X-Gm-Message-State: APjAAAWuhSeDayt8o5lvisedhCwHYobH65j9YnC6kszdfKx6OqrE4Coy szLK9+4noJNJ9EQmQ34ba8VgKA== X-Google-Smtp-Source: APXvYqw+il1jO/8li5BBYPsOHa/dR3SgOyViPxFwdgCMRuy5zDnPmwIKS0vL3iozpA654F+kBve+ag== X-Received: by 2002:a63:6fcd:: with SMTP id k196mr25424457pgc.238.1556038429736; Tue, 23 Apr 2019 09:53:49 -0700 (PDT) Received: from hermes.lan (204-195-22-127.wavecable.com. [204.195.22.127]) by smtp.gmail.com with ESMTPSA id 71sm47194750pfs.36.2019.04.23.09.53.47 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 23 Apr 2019 09:53:48 -0700 (PDT) From: Stephen Hemminger To: bruce.richardson@intel.com Cc: dev@dpdk.org, Stephen Hemminger Date: Tue, 23 Apr 2019 09:53:35 -0700 Message-Id: <20190423165335.4025-5-stephen@networkplumber.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190423165335.4025-1-stephen@networkplumber.org> References: <20190423164812.3427-1-stephen@networkplumber.org> <20190423165335.4025-1-stephen@networkplumber.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [dpdk-dev] [PATCH v2 4/4] net/ring: check length of ring name 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, 23 Apr 2019 16:53:51 -0000 The ring name is passed in as part of this drivers API, but it doesn't check that the name is not truncated. Signed-off-by: Stephen Hemminger --- v2 - fix whitespace creep drivers/net/ring/rte_eth_ring.c | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/drivers/net/ring/rte_eth_ring.c b/drivers/net/ring/rte_eth_ring.c index 0355f2b7c4d8..979993fd3e11 100644 --- a/drivers/net/ring/rte_eth_ring.c +++ b/drivers/net/ring/rte_eth_ring.c @@ -383,7 +383,12 @@ rte_eth_from_rings(const char *name, struct rte_ring *const rx_queues[], snprintf(args_str, sizeof(args_str), "%s=%p", ETH_RING_INTERNAL_ARG, &args); - snprintf(ring_name, sizeof(ring_name), "net_ring_%s", name); + + ret = snprintf(ring_name, sizeof(ring_name), "net_ring_%s", name); + if (ret >= (int)sizeof(ring_name)) { + rte_errno = ENAMETOOLONG; + return -1; + } ret = rte_vdev_init(ring_name, args_str); if (ret) { @@ -417,7 +422,15 @@ eth_dev_ring_create(const char *name, const unsigned int numa_node, RTE_PMD_RING_MAX_TX_RINGS); for (i = 0; i < num_rings; i++) { - snprintf(rng_name, sizeof(rng_name), "ETH_RXTX%u_%s", i, name); + int cc; + + cc = snprintf(rng_name, sizeof(rng_name), + "ETH_RXTX%u_%s", i, name); + if (cc >= (int)sizeof(rng_name)) { + rte_errno = ENAMETOOLONG; + return -1; + } + rxtx[i] = (action == DEV_CREATE) ? rte_ring_create(rng_name, 1024, numa_node, RING_F_SP_ENQ|RING_F_SC_DEQ) : -- 2.20.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 76B08A05D3 for ; Tue, 23 Apr 2019 18:54:21 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 2FE801B4F0; Tue, 23 Apr 2019 18:54:00 +0200 (CEST) Received: from mail-pf1-f194.google.com (mail-pf1-f194.google.com [209.85.210.194]) by dpdk.org (Postfix) with ESMTP id 8FDAD4CA7 for ; Tue, 23 Apr 2019 18:53:50 +0200 (CEST) Received: by mail-pf1-f194.google.com with SMTP id w25so7781969pfi.9 for ; Tue, 23 Apr 2019 09:53:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=uOyDKtvz7UbmBWCKoGXvUGPdqVmyNcBK16SpXqQX4cc=; b=aPQvCCt6ZBCxmBZ37xM7D/65eunzjFrBOyVP/p1n8zPZqG1HAuErQBpEHKQuZMtMWJ YTmLWamqpVmLx/8ch6s5iltLY7k8MD0Pyf8PWtQCHm/Oxg69j5f0Jy0418khsx8Us3sj qvnpq0G4WrG2zEOG8pZmjNdipKmyWCoxrzOUeCfSFFUIind+HS9iSFPjkcGyRFwY3Ca6 diotKqibx2+Q/eSSg/2g7lVtH71+HL1vQ/su2sX/9h1uAKq51hTEKn0CD2m5excLVJ8d A5EGBGoPNWTdn/6lzrpNTWTi5F8VmRU8Mu8jaI738GWfsjH2rlXSIsdl8k0hSCiqNJC1 BBcQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=uOyDKtvz7UbmBWCKoGXvUGPdqVmyNcBK16SpXqQX4cc=; b=AjSML8x2UOZRgpiL3edTKA/kUWPuZzO5WuuMjI+TOicZu4ny58VnQagvQ32LzOiWYI PPVv7F3L8749TNB7aUHIUNrKp+mdbTfCwQPoKQ725kK+HsV9a6pdLi6vIVaozY8cPZOE ehgZ9D6tMwip0QpKvjgKCjXDh7Tu+5YCexi4flA1dO6piLFDCLgM6pKtpZPbcCVarPjF Gix/pHZlYj3FEzmKs7i667aKY4zwK9SvuXlttFVPgaHMwKmGx7xcfp8QXRsRzFOZQSy5 B0aMvSpjH1aLykrB1TToUyP9BEa2Ny84pK/67UpxDhdkIv9HsiHJb+NOLC79ltZ6366a rlJg== X-Gm-Message-State: APjAAAWuhSeDayt8o5lvisedhCwHYobH65j9YnC6kszdfKx6OqrE4Coy szLK9+4noJNJ9EQmQ34ba8VgKA== X-Google-Smtp-Source: APXvYqw+il1jO/8li5BBYPsOHa/dR3SgOyViPxFwdgCMRuy5zDnPmwIKS0vL3iozpA654F+kBve+ag== X-Received: by 2002:a63:6fcd:: with SMTP id k196mr25424457pgc.238.1556038429736; Tue, 23 Apr 2019 09:53:49 -0700 (PDT) Received: from hermes.lan (204-195-22-127.wavecable.com. [204.195.22.127]) by smtp.gmail.com with ESMTPSA id 71sm47194750pfs.36.2019.04.23.09.53.47 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 23 Apr 2019 09:53:48 -0700 (PDT) From: Stephen Hemminger To: bruce.richardson@intel.com Cc: dev@dpdk.org, Stephen Hemminger Date: Tue, 23 Apr 2019 09:53:35 -0700 Message-Id: <20190423165335.4025-5-stephen@networkplumber.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190423165335.4025-1-stephen@networkplumber.org> References: <20190423164812.3427-1-stephen@networkplumber.org> <20190423165335.4025-1-stephen@networkplumber.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [dpdk-dev] [PATCH v2 4/4] net/ring: check length of ring name 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" Content-Type: text/plain; charset="UTF-8" Message-ID: <20190423165335.e0CwyJ9mVFwHhKdEY2fCpFlpj5Xad8usjI5ZnykhPMs@z> The ring name is passed in as part of this drivers API, but it doesn't check that the name is not truncated. Signed-off-by: Stephen Hemminger --- v2 - fix whitespace creep drivers/net/ring/rte_eth_ring.c | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/drivers/net/ring/rte_eth_ring.c b/drivers/net/ring/rte_eth_ring.c index 0355f2b7c4d8..979993fd3e11 100644 --- a/drivers/net/ring/rte_eth_ring.c +++ b/drivers/net/ring/rte_eth_ring.c @@ -383,7 +383,12 @@ rte_eth_from_rings(const char *name, struct rte_ring *const rx_queues[], snprintf(args_str, sizeof(args_str), "%s=%p", ETH_RING_INTERNAL_ARG, &args); - snprintf(ring_name, sizeof(ring_name), "net_ring_%s", name); + + ret = snprintf(ring_name, sizeof(ring_name), "net_ring_%s", name); + if (ret >= (int)sizeof(ring_name)) { + rte_errno = ENAMETOOLONG; + return -1; + } ret = rte_vdev_init(ring_name, args_str); if (ret) { @@ -417,7 +422,15 @@ eth_dev_ring_create(const char *name, const unsigned int numa_node, RTE_PMD_RING_MAX_TX_RINGS); for (i = 0; i < num_rings; i++) { - snprintf(rng_name, sizeof(rng_name), "ETH_RXTX%u_%s", i, name); + int cc; + + cc = snprintf(rng_name, sizeof(rng_name), + "ETH_RXTX%u_%s", i, name); + if (cc >= (int)sizeof(rng_name)) { + rte_errno = ENAMETOOLONG; + return -1; + } + rxtx[i] = (action == DEV_CREATE) ? rte_ring_create(rng_name, 1024, numa_node, RING_F_SP_ENQ|RING_F_SC_DEQ) : -- 2.20.1