From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 8DC8645BAE; Wed, 23 Oct 2024 10:31:18 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 0B84F427D3; Wed, 23 Oct 2024 10:29:29 +0200 (CEST) Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by mails.dpdk.org (Postfix) with ESMTP id 2622F41148 for ; Wed, 23 Oct 2024 10:28:59 +0200 (CEST) Received: from mail.maildlp.com (unknown [172.19.88.105]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4XYMZq5tT6zfdSr; Wed, 23 Oct 2024 16:26:27 +0800 (CST) Received: from dggpeml500011.china.huawei.com (unknown [7.185.36.84]) by mail.maildlp.com (Postfix) with ESMTPS id 203A414039F; Wed, 23 Oct 2024 16:28:58 +0800 (CST) Received: from localhost.huawei.com (10.50.165.33) by dggpeml500011.china.huawei.com (7.185.36.84) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2507.39; Wed, 23 Oct 2024 16:28:57 +0800 From: Dengdui Huang To: CC: , , , , , , , , Subject: [PATCH v4 27/42] net/failsafe: use rte strerror Date: Wed, 23 Oct 2024 16:28:37 +0800 Message-ID: <20241023082852.2780488-28-huangdengdui@huawei.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20241023082852.2780488-1-huangdengdui@huawei.com> References: <20231114082539.1858594-44-huangdengdui@huawei.com> <20241023082852.2780488-1-huangdengdui@huawei.com> MIME-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8bit X-Originating-IP: [10.50.165.33] X-ClientProxiedBy: dggems705-chm.china.huawei.com (10.3.19.182) To dggpeml500011.china.huawei.com (7.185.36.84) X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org The function strerror() is insecure in a multi-thread environment. This patch uses rte_strerror() to replace it. Cc: stable@dpdk.org Signed-off-by: Dengdui Huang Acked-by: Chengwen Feng Acked-by: Morten Brørup --- drivers/net/failsafe/failsafe.c | 8 ++++---- drivers/net/failsafe/failsafe_args.c | 4 ++-- drivers/net/failsafe/failsafe_eal.c | 4 ++-- drivers/net/failsafe/failsafe_flow.c | 4 ++-- drivers/net/failsafe/failsafe_ops.c | 2 +- drivers/net/failsafe/failsafe_private.h | 6 +++--- 6 files changed, 14 insertions(+), 14 deletions(-) diff --git a/drivers/net/failsafe/failsafe.c b/drivers/net/failsafe/failsafe.c index 32811403b4..f89c946ce4 100644 --- a/drivers/net/failsafe/failsafe.c +++ b/drivers/net/failsafe/failsafe.c @@ -92,7 +92,7 @@ failsafe_hotplug_alarm_cancel(struct rte_eth_dev *dev) rte_eal_alarm_cancel(fs_hotplug_alarm, dev); if (rte_errno) { ERROR("rte_eal_alarm_cancel failed (errno: %s)", - strerror(rte_errno)); + rte_strerror(rte_errno)); ret = -rte_errno; } else { PRIV(dev)->pending_alarm = 0; @@ -138,18 +138,18 @@ fs_mutex_init(struct fs_priv *priv) ret = pthread_mutexattr_init(&attr); if (ret) { - ERROR("Cannot initiate mutex attributes - %s", strerror(ret)); + ERROR("Cannot initiate mutex attributes - %s", rte_strerror(ret)); return ret; } /* Allow mutex relocks for the thread holding the mutex. */ ret = pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE); if (ret) { - ERROR("Cannot set mutex type - %s", strerror(ret)); + ERROR("Cannot set mutex type - %s", rte_strerror(ret)); return ret; } ret = pthread_mutex_init(&priv->hotplug_mutex, &attr); if (ret) { - ERROR("Cannot initiate mutex - %s", strerror(ret)); + ERROR("Cannot initiate mutex - %s", rte_strerror(ret)); return ret; } return 0; diff --git a/drivers/net/failsafe/failsafe_args.c b/drivers/net/failsafe/failsafe_args.c index 1b8f1d3050..cc15428b7b 100644 --- a/drivers/net/failsafe/failsafe_args.c +++ b/drivers/net/failsafe/failsafe_args.c @@ -112,7 +112,7 @@ fs_execute_cmd(struct sub_device *sdev, char *cmdline) fp = popen(sdev->cmdline, "r"); if (fp == NULL) { ret = -errno; - ERROR("popen: %s", strerror(errno)); + ERROR("popen: %s", rte_strerror(errno)); return ret; } /* We only read one line */ @@ -131,7 +131,7 @@ fs_execute_cmd(struct sub_device *sdev, char *cmdline) ERROR("Parsing device '%s' failed", output); ret_pclose: if (pclose(fp) == -1) - ERROR("pclose: %s", strerror(errno)); + ERROR("pclose: %s", rte_strerror(errno)); return ret; } diff --git a/drivers/net/failsafe/failsafe_eal.c b/drivers/net/failsafe/failsafe_eal.c index e79d3b4120..07fa802653 100644 --- a/drivers/net/failsafe/failsafe_eal.c +++ b/drivers/net/failsafe/failsafe_eal.c @@ -52,7 +52,7 @@ fs_bus_init(struct rte_eth_dev *dev) if (ret < 0) { ERROR("sub_device %d probe failed %s%s%s", i, rte_errno ? "(" : "", - rte_errno ? strerror(rte_errno) : "", + rte_errno ? rte_strerror(rte_errno) : "", rte_errno ? ")" : ""); continue; } @@ -100,7 +100,7 @@ fs_bus_init(struct rte_eth_dev *dev) ret = rte_eth_dev_owner_set(pid, &PRIV(dev)->my_owner); if (ret < 0) { INFO("sub_device %d owner set failed (%s), " - "will try again later", i, strerror(-ret)); + "will try again later", i, rte_strerror(-ret)); continue; } else if (strncmp(rte_eth_devices[pid].device->name, da->name, strlen(da->name)) != 0) { diff --git a/drivers/net/failsafe/failsafe_flow.c b/drivers/net/failsafe/failsafe_flow.c index 707e6c63b5..5d17182cc5 100644 --- a/drivers/net/failsafe/failsafe_flow.c +++ b/drivers/net/failsafe/failsafe_flow.c @@ -33,7 +33,7 @@ fs_flow_allocate(const struct rte_flow_attr *attr, if (ret < 0) { ERROR("Unable to process flow rule (%s): %s", error.message ? error.message : "unspecified", - strerror(rte_errno)); + rte_strerror(rte_errno)); return NULL; } flow = rte_zmalloc(NULL, offsetof(struct rte_flow, rule) + ret, @@ -47,7 +47,7 @@ fs_flow_allocate(const struct rte_flow_attr *attr, if (ret < 0) { ERROR("Failed to copy flow rule (%s): %s", error.message ? error.message : "unspecified", - strerror(rte_errno)); + rte_strerror(rte_errno)); rte_free(flow); return NULL; } diff --git a/drivers/net/failsafe/failsafe_ops.c b/drivers/net/failsafe/failsafe_ops.c index 9c013e0419..f3b2daf400 100644 --- a/drivers/net/failsafe/failsafe_ops.c +++ b/drivers/net/failsafe/failsafe_ops.c @@ -452,7 +452,7 @@ fs_rx_queue_setup(struct rte_eth_dev *dev, #ifdef RTE_EXEC_ENV_LINUX rxq->event_fd = eventfd(0, EFD_NONBLOCK | EFD_CLOEXEC); if (rxq->event_fd < 0) { - ERROR("Failed to create an eventfd: %s", strerror(errno)); + ERROR("Failed to create an eventfd: %s", rte_strerror(errno)); fs_unlock(dev, 0); return -errno; } diff --git a/drivers/net/failsafe/failsafe_private.h b/drivers/net/failsafe/failsafe_private.h index babea6016e..fcbb1b771e 100644 --- a/drivers/net/failsafe/failsafe_private.h +++ b/drivers/net/failsafe/failsafe_private.h @@ -407,14 +407,14 @@ fs_lock(struct rte_eth_dev *dev, unsigned int is_alarm) ret = pthread_mutex_trylock(&PRIV(dev)->hotplug_mutex); if (ret) { DEBUG("Hot-plug mutex lock trying failed(%s), will try" - " again later...", strerror(ret)); + " again later...", rte_strerror(ret)); return ret; } PRIV(dev)->alarm_lock = 1; } else { ret = pthread_mutex_lock(&PRIV(dev)->hotplug_mutex); if (ret) { - ERROR("Cannot lock mutex(%s)", strerror(ret)); + ERROR("Cannot lock mutex(%s)", rte_strerror(ret)); return ret; } } @@ -436,7 +436,7 @@ fs_unlock(struct rte_eth_dev *dev, unsigned int is_alarm) } ret = pthread_mutex_unlock(&PRIV(dev)->hotplug_mutex); if (ret) - ERROR("Cannot unlock hot-plug mutex(%s)", strerror(ret)); + ERROR("Cannot unlock hot-plug mutex(%s)", rte_strerror(ret)); } /* -- 2.33.0