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 3D3E645BAE; Wed, 23 Oct 2024 10:30:12 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 31453427A7; Wed, 23 Oct 2024 10:29:16 +0200 (CEST) Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by mails.dpdk.org (Postfix) with ESMTP id 2EB214065B for ; Wed, 23 Oct 2024 10:28:57 +0200 (CEST) Received: from mail.maildlp.com (unknown [172.19.163.252]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4XYMbL22jQz10NlN; Wed, 23 Oct 2024 16:26:54 +0800 (CST) Received: from dggpeml500011.china.huawei.com (unknown [7.185.36.84]) by mail.maildlp.com (Postfix) with ESMTPS id 1BCEE1800D9; Wed, 23 Oct 2024 16:28:56 +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:55 +0800 From: Dengdui Huang To: CC: , , , , , , , , Subject: [PATCH v4 15/42] bus/vmbus: use rte strerror Date: Wed, 23 Oct 2024 16:28:25 +0800 Message-ID: <20241023082852.2780488-16-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/bus/vmbus/linux/vmbus_bus.c | 7 ++++--- drivers/bus/vmbus/linux/vmbus_uio.c | 21 +++++++++++---------- drivers/bus/vmbus/vmbus_common.c | 4 ++-- drivers/bus/vmbus/vmbus_common_uio.c | 3 ++- 4 files changed, 19 insertions(+), 16 deletions(-) diff --git a/drivers/bus/vmbus/linux/vmbus_bus.c b/drivers/bus/vmbus/linux/vmbus_bus.c index 01d8111b85..0c92c1d4dd 100644 --- a/drivers/bus/vmbus/linux/vmbus_bus.c +++ b/drivers/bus/vmbus/linux/vmbus_bus.c @@ -18,6 +18,7 @@ #include #include #include +#include #include "eal_filesystem.h" #include "private.h" @@ -50,7 +51,7 @@ parse_sysfs_uuid(const char *filename, rte_uuid_t uu) f = fopen(filename, "r"); if (f == NULL) { VMBUS_LOG(ERR, "cannot open sysfs value %s: %s", - filename, strerror(errno)); + filename, rte_strerror(errno)); return -1; } @@ -92,7 +93,7 @@ get_sysfs_string(const char *filename, char *buf, size_t buflen) f = fopen(filename, "r"); if (f == NULL) { VMBUS_LOG(ERR, "cannot open sysfs value %s:%s", - filename, strerror(errno)); + filename, rte_strerror(errno)); return -1; } @@ -350,7 +351,7 @@ rte_vmbus_scan(void) return 0; VMBUS_LOG(ERR, "opendir %s failed: %s", - SYSFS_VMBUS_DEVICES, strerror(errno)); + SYSFS_VMBUS_DEVICES, rte_strerror(errno)); return -1; } diff --git a/drivers/bus/vmbus/linux/vmbus_uio.c b/drivers/bus/vmbus/linux/vmbus_uio.c index 26edef342d..5fce68d880 100644 --- a/drivers/bus/vmbus/linux/vmbus_uio.c +++ b/drivers/bus/vmbus/linux/vmbus_uio.c @@ -18,6 +18,7 @@ #include #include #include +#include #include "private.h" @@ -34,7 +35,7 @@ void vmbus_uio_irq_control(struct rte_vmbus_device *dev, int32_t onoff) sizeof(onoff)) < 0) { VMBUS_LOG(ERR, "cannot write to %d:%s", rte_intr_fd_get(dev->intr_handle), - strerror(errno)); + rte_strerror(errno)); } } @@ -51,7 +52,7 @@ int vmbus_uio_irq_read(struct rte_vmbus_device *dev) if (cc < (int)sizeof(count)) { if (cc < 0) { VMBUS_LOG(ERR, "IRQ read failed %s", - strerror(errno)); + rte_strerror(errno)); return -errno; } VMBUS_LOG(ERR, "can't read IRQ count"); @@ -91,7 +92,7 @@ vmbus_uio_alloc_resource(struct rte_vmbus_device *dev, fd = open(devname, O_RDWR); if (fd < 0) { VMBUS_LOG(ERR, "Cannot open %s: %s", - devname, strerror(errno)); + devname, rte_strerror(errno)); goto error; } @@ -158,7 +159,7 @@ vmbus_uio_map_resource_by_index(struct rte_vmbus_device *dev, int idx, fd = open(uio_res->path, O_RDWR); if (fd < 0) { VMBUS_LOG(ERR, "Cannot open %s: %s", - uio_res->path, strerror(errno)); + uio_res->path, rte_strerror(errno)); return -1; } @@ -256,13 +257,13 @@ static int vmbus_uio_map_subchan(const struct rte_vmbus_device *dev, fd = open(ring_path, O_RDWR); if (fd < 0) { VMBUS_LOG(ERR, "Cannot open %s: %s", - ring_path, strerror(errno)); + ring_path, rte_strerror(errno)); return -errno; } if (fstat(fd, &sb) < 0) { VMBUS_LOG(ERR, "Cannot state %s: %s", - ring_path, strerror(errno)); + ring_path, rte_strerror(errno)); close(fd); return -errno; } @@ -342,7 +343,7 @@ static int vmbus_uio_sysfs_read(const char *dir, const char *name, f = fopen(path, "r"); if (!f) { VMBUS_LOG(ERR, "can't open %s:%s", - path, strerror(errno)); + path, rte_strerror(errno)); return -errno; } @@ -404,7 +405,7 @@ int vmbus_uio_get_subchan(struct vmbus_channel *primary, chan_dir = opendir(chan_path); if (!chan_dir) { VMBUS_LOG(ERR, "cannot open %s: %s", - chan_path, strerror(errno)); + chan_path, rte_strerror(errno)); return -errno; } @@ -441,7 +442,7 @@ int vmbus_uio_get_subchan(struct vmbus_channel *primary, &subid, UINT16_MAX); if (err) { VMBUS_LOG(NOTICE, "no subchannel_id in %s:%s", - subchan_path, strerror(-err)); + subchan_path, rte_strerror(-err)); goto fail; } @@ -452,7 +453,7 @@ int vmbus_uio_get_subchan(struct vmbus_channel *primary, &monid, UINT8_MAX); if (err) { VMBUS_LOG(NOTICE, "no monitor_id in %s:%s", - subchan_path, strerror(-err)); + subchan_path, rte_strerror(-err)); goto fail; } diff --git a/drivers/bus/vmbus/vmbus_common.c b/drivers/bus/vmbus/vmbus_common.c index 8a965d10d9..ef05d62714 100644 --- a/drivers/bus/vmbus/vmbus_common.c +++ b/drivers/bus/vmbus/vmbus_common.c @@ -38,7 +38,7 @@ vmbus_map_resource(void *requested_addr, int fd, off_t offset, size_t size, VMBUS_LOG(ERR, "mmap(%d, %p, %zu, %ld) failed: %s", fd, requested_addr, size, (long)offset, - strerror(errno)); + rte_strerror(errno)); } else { VMBUS_LOG(DEBUG, " VMBUS memory mapped at %p", mapaddr); @@ -57,7 +57,7 @@ vmbus_unmap_resource(void *requested_addr, size_t size) if (munmap(requested_addr, size)) { VMBUS_LOG(ERR, "munmap(%p, 0x%lx) failed: %s", requested_addr, (unsigned long)size, - strerror(errno)); + rte_strerror(errno)); } else { VMBUS_LOG(DEBUG, " VMBUS memory unmapped at %p", requested_addr); diff --git a/drivers/bus/vmbus/vmbus_common_uio.c b/drivers/bus/vmbus/vmbus_common_uio.c index 4d4613513c..54c1187026 100644 --- a/drivers/bus/vmbus/vmbus_common_uio.c +++ b/drivers/bus/vmbus/vmbus_common_uio.c @@ -14,6 +14,7 @@ #include #include #include +#include #include "private.h" @@ -56,7 +57,7 @@ vmbus_uio_map_secondary(struct rte_vmbus_device *dev) fd = open(uio_res->path, O_RDWR); if (fd < 0) { VMBUS_LOG(ERR, "Cannot open %s: %s", - uio_res->path, strerror(errno)); + uio_res->path, rte_strerror(errno)); return -1; } -- 2.33.0