From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pg1-f193.google.com (mail-pg1-f193.google.com [209.85.215.193]) by dpdk.org (Postfix) with ESMTP id 74B2A49E0 for ; Mon, 11 Mar 2019 19:15:48 +0100 (CET) Received: by mail-pg1-f193.google.com with SMTP id a22so4633581pgg.13 for ; Mon, 11 Mar 2019 11:15:48 -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; bh=UuTj3emvtx6KJu5w593NAp+KjMf137jVCkUzPAwoNfY=; b=HWue+Rp9ZiDPpOxD2WgTzuHdC30lfhtsPhD4ZePiYGm/nqPX6OMFaqGEeMuXoXmBBB LJ7c673pBchsD8kNBfHoU3A4q2F4WUbHUXx3B/KJ8wVLgr6kEIdvTQ4Nu+IMI4brtiTn NNaTzd6auYB5eQdGGPnmFUlNbcPMgGQSdcGqxakgub6C6ffXk6iVa7Z546M4EdRHnRXs 90Z4J/Ju1sDN8m8EOe9iDZTaA2rI+8GL2hMVCcD+L2k9IAfW+RZa7JKU/5nxWh4OnWoL S3xt9GI3rP/fDv7JgF8NKAK4+g9hYXU+U9YI/1/2Rc5SZluTf2ADeynYEG5g5R3faDhw jmBQ== 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; bh=UuTj3emvtx6KJu5w593NAp+KjMf137jVCkUzPAwoNfY=; b=KLtSxTc4zThdQ5+kMY7tnQ8bZY43X4aL3TZy3Yf0RJ4rLdpVu24SSK4/kyOe0Y4093 xcAPJTWOUGYAU+WeNAa+Gpndcd+oesPXmo2T8XR+vloU9VLDyfXq6M9wcIC6KoczgCp/ B8bwNF8dsYv+5eykueKD1Gjg89yiOS8hJwoZRNcw0aOP3SmNMNV8+Ni8Xdb13IV4WuJc kkZ+RQ5ejkQ3w7nAA7sdxMpqbjm2zQOQTKBVHpEsr/bIyyQ9GA5g5WwezI1tVNmAYMLs /foJVnXuGHd5+12j51rGD2NWcoOY9qtHskX69b9rBdWzS9zNAl1rbPy4ufNeiHGlVsCA rmKA== X-Gm-Message-State: APjAAAXZP8Qz+h8PnsaoVQ9qAo9wyVH8JtqnnZDDoapflOS8XC5NL6TV L+PqUGXrdYU0V5BGlQOlLKFZboqNMDc= X-Google-Smtp-Source: APXvYqzrOnycCptuf3qcemGF1BGH2oj4SROL3EXmdZn20t1ssQbrl/iHlB6OP+scwzPRn4csozR/gQ== X-Received: by 2002:a65:6559:: with SMTP id a25mr20906109pgw.99.1552328147422; Mon, 11 Mar 2019 11:15:47 -0700 (PDT) Received: from shemminger-XPS-13-9360.lan (204-195-22-127.wavecable.com. [204.195.22.127]) by smtp.gmail.com with ESMTPSA id f192sm16171655pfc.180.2019.03.11.11.15.46 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 11 Mar 2019 11:15:46 -0700 (PDT) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger Date: Mon, 11 Mar 2019 11:15:44 -0700 Message-Id: <20190311181544.15646-1-stephen@networkplumber.org> X-Mailer: git-send-email 2.17.1 Subject: [dpdk-dev] [PATCH] ethdev: check for invalid device 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: Mon, 11 Mar 2019 18:15:48 -0000 Do not allow creating a ethernet device with a name over the allowed maximum (or zero length). This is safer than silently truncating which is what happens now. Signed-off-by: Stephen Hemminger Acked-by: Andrew Rybchenko --- v1 - previously sent as RFC 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 85c1794968dd..0b81980ff71c 100644 --- a/lib/librte_ethdev/rte_ethdev.c +++ b/lib/librte_ethdev/rte_ethdev.c @@ -439,6 +439,16 @@ rte_eth_dev_allocate(const char *name) uint16_t port_id; struct rte_eth_dev *eth_dev = NULL; + if (*name) { + RTE_ETHDEV_LOG(ERR, "Zero length Ethernet device name\n"); + return NULL; + } + + if (strnlen(name, RTE_ETH_NAME_MAX_LEN) >= RTE_ETH_NAME_MAX_LEN) { + RTE_ETHDEV_LOG(ERR, "Ethernet device name is too long\n"); + return NULL; + } + rte_eth_dev_shared_data_prepare(); /* Synchronize port creation between primary and secondary threads. */ -- 2.17.1