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 2C62045CAB; Thu, 7 Nov 2024 03:52:32 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id E3422402EA; Thu, 7 Nov 2024 03:52:30 +0100 (CET) Received: from szxga04-in.huawei.com (szxga04-in.huawei.com [45.249.212.190]) by mails.dpdk.org (Postfix) with ESMTP id 22B78402D8 for ; Thu, 7 Nov 2024 03:52:28 +0100 (CET) Received: from mail.maildlp.com (unknown [172.19.163.44]) by szxga04-in.huawei.com (SkyGuard) with ESMTP id 4XkRRB2vMpz20nXN; Thu, 7 Nov 2024 10:51:18 +0800 (CST) Received: from dggpeml500011.china.huawei.com (unknown [7.185.36.84]) by mail.maildlp.com (Postfix) with ESMTPS id 1637E1402CB; Thu, 7 Nov 2024 10:52:26 +0800 (CST) Received: from [10.67.121.193] (10.67.121.193) 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; Thu, 7 Nov 2024 10:52:25 +0800 Message-ID: <5f47ce56-2dd9-4898-b0cd-58cb783f9e69@huawei.com> Date: Thu, 7 Nov 2024 10:52:25 +0800 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH 00/43] replace strerror Content-Language: en-US To: Stephen Hemminger CC: , , , , References: <20231114082539.1858594-1-huangdengdui@huawei.com> <20241106105708.2891c287@hermes.local> From: huangdengdui In-Reply-To: <20241106105708.2891c287@hermes.local> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit X-Originating-IP: [10.67.121.193] X-ClientProxiedBy: dggems703-chm.china.huawei.com (10.3.19.180) 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 On 2024/11/7 2:57, Stephen Hemminger wrote: > On Tue, 14 Nov 2023 16:24:56 +0800 > Dengdui Huang wrote: > >> The function strerror() is insecure in a multi-thread environment. >> This series of patches fix it. In this patchset, only the libs and >> drivers are modified. > > strerror is ok in multi-threaded environment, look at what glibc does. > Yes, it's safe in the latest version.[1] But, static variables used in previous versions, so it is insecure in multi-threaded environment.[2][3] [1]:https://elixir.bootlin.com/glibc/glibc-2.40/source/string/strerror.c#L24 [2]:https://elixir.bootlin.com/glibc/glibc-2.31/source/string/strerror.c#L26 [3]:https://elixir.bootlin.com/glibc/glibc-2.3/source/string/strerror.c#L29 > The bigger problem is where DPDK code is calling strerror() on rte_errno. > This should be flagged by checkpatch (but isn't now). I found it, too, and have fixed it in this patchset. But I didn't add it to the checkpatch script. > > Examples: > $ git grep 'strerror(rte_errno)' | grep -v rte_strerror > app/dumpcap/main.c: strerror(rte_errno)); > app/test/test_bpf.c: __func__, __LINE__, rte_errno, strerror(rte_errno)); > app/test/test_bpf.c: __func__, __LINE__, str, rte_errno, strerror(rte_errno)); > app/test/test_bpf.c: __func__, __LINE__, rte_errno, strerror(rte_errno)); > app/test/test_bpf.c: __func__, __LINE__, s, rte_errno, strerror(rte_errno)); > app/test/test_bpf.c: __func__, __LINE__, rte_errno, strerror(rte_errno)); > drivers/bus/vdev/vdev.c: devname, strerror(rte_errno)); > drivers/common/mlx5/linux/mlx5_nl.c: iface_idx, strerror(rte_errno)); > drivers/common/mlx5/linux/mlx5_nl.c: add ? "add" : "remove", m, strerror(rte_errno)); > drivers/common/mlx5/linux/mlx5_nl.c: strerror(rte_errno)); > drivers/common/mlx5/linux/mlx5_nl.c: strerror(rte_errno)); > drivers/common/mlx5/linux/mlx5_nl.c: strerror(rte_errno)); > drivers/common/mlx5/mlx5_common.c: strerror(rte_errno)); > drivers/common/mlx5/mlx5_common.c: strerror(rte_errno)); > drivers/common/mlx5/mlx5_common.c: strerror(rte_errno)); > drivers/net/af_xdp/rte_eth_af_xdp.c: name, strerror(rte_errno)); > drivers/net/bonding/rte_eth_bond_flow.c: strerror(rte_errno)); > drivers/net/bonding/rte_eth_bond_flow.c: strerror(rte_errno)); > drivers/net/failsafe/failsafe.c: strerror(rte_errno)); > drivers/net/failsafe/failsafe_eal.c: rte_errno ? strerror(rte_errno) : "", > drivers/net/failsafe/failsafe_flow.c: strerror(rte_errno)); > drivers/net/failsafe/failsafe_flow.c: strerror(rte_errno)); > drivers/net/memif/rte_eth_memif.c: strerror(rte_errno)); > drivers/net/mlx4/mlx4.c: strerror(rte_errno)); > drivers/net/mlx4/mlx4_ethdev.c: mode, rte_errno, strerror(rte_errno), error.type, error.cause, > drivers/net/mlx4/mlx4_ethdev.c: index, rte_errno, strerror(rte_errno), error.type, error.cause, > drivers/net/mlx4/mlx4_ethdev.c: index, rte_errno, strerror(rte_errno), error.type, error.cause, > drivers/net/mlx4/mlx4_ethdev.c: rte_errno, strerror(rte_errno), error.type, error.cause, > drivers/net/mlx4/mlx4_ethdev.c: rte_errno, strerror(rte_errno), error.type, error.cause, > drivers/net/mlx4/mlx4_ethdev.c: WARN("ioctl(SIOCGIFFLAGS) failed: %s", strerror(rte_errno)); > drivers/net/mlx4/mlx4_ethdev.c: strerror(rte_errno)); > drivers/net/mlx4/mlx4_ethdev.c: strerror(rte_errno)); > drivers/net/mlx4/mlx4_ethdev.c: strerror(rte_errno)); > drivers/net/mlx4/mlx4_rxq.c: (void *)dev, strerror(rte_errno)); > drivers/net/mlx4/mlx4_rxq.c: (void *)dev, strerror(rte_errno)); > drivers/net/mlx4/mlx4_txq.c: (void *)dev, strerror(rte_errno)); > drivers/net/mlx4/mlx4_txq.c: (void *)dev, strerror(rte_errno)); > drivers/net/mlx4/mlx4_txq.c: (void *)dev, strerror(rte_errno)); > drivers/net/mlx4/mlx4_txq.c: (void *)dev, strerror(rte_errno)); > drivers/net/mlx4/mlx4_txq.c: (void *)dev, strerror(rte_errno)); > drivers/net/mlx5/hws/mlx5dr_matcher.c: strerror(rte_errno)); > drivers/net/mlx5/linux/mlx5_ethdev_os.c: dev->data->port_id, strerror(rte_errno)); > drivers/net/mlx5/linux/mlx5_ethdev_os.c: dev->data->port_id, strerror(rte_errno)); > drivers/net/mlx5/linux/mlx5_ethdev_os.c: dev->data->port_id, strerror(rte_errno)); > drivers/net/mlx5/linux/mlx5_ethdev_os.c: dev->data->port_id, strerror(rte_errno)); > drivers/net/mlx5/linux/mlx5_ethdev_os.c: dev->data->port_id, strerror(rte_errno)); > drivers/net/mlx5/linux/mlx5_ethdev_os.c: dev->data->port_id, strerror(rte_errno)); > drivers/net/mlx5/linux/mlx5_ethdev_os.c: dev->data->port_id, strerror(rte_errno)); > drivers/net/mlx5/linux/mlx5_ethdev_os.c: bond->ifname, strerror(rte_errno)); > drivers/net/mlx5/linux/mlx5_ethdev_os.c: dev->data->port_id, strerror(rte_errno)); > drivers/net/mlx5/linux/mlx5_ethdev_os.c: dev->data->port_id, strerror(rte_errno)); > drivers/net/mlx5/linux/mlx5_ethdev_os.c: dev->data->port_id, strerror(rte_errno)); > drivers/net/mlx5/linux/mlx5_os.c: strerror(rte_errno)); > drivers/net/mlx5/linux/mlx5_os.c: strerror(rte_errno)); > drivers/net/mlx5/linux/mlx5_os.c: strerror(rte_errno)); > drivers/net/mlx5/linux/mlx5_os.c: eth_dev->data->port_id, strerror(rte_errno)); > drivers/net/mlx5/linux/mlx5_os.c: strerror(rte_errno)); > drivers/net/mlx5/linux/mlx5_os.c: strerror(rte_errno)); > drivers/net/mlx5/linux/mlx5_os.c: strerror(rte_errno)); > drivers/net/mlx5/linux/mlx5_os.c: strerror(rte_errno)); > drivers/net/mlx5/mlx5.c: strerror(rte_errno)); > drivers/net/mlx5/mlx5.c: strerror(rte_errno)); > drivers/net/mlx5/mlx5.c: strerror(rte_errno)); > drivers/net/mlx5/mlx5.c: strerror(rte_errno)); > drivers/net/mlx5/mlx5_mac.c: dev->data->port_id, strerror(rte_errno)); > drivers/net/mlx5/mlx5_rxmode.c: dev->data->port_id, strerror(rte_errno)); > drivers/net/mlx5/mlx5_rxmode.c: dev->data->port_id, strerror(rte_errno)); > drivers/net/mlx5/mlx5_rxmode.c: dev->data->port_id, strerror(rte_errno)); > drivers/net/mlx5/mlx5_rxmode.c: dev->data->port_id, strerror(rte_errno)); > drivers/net/mlx5/mlx5_stats.c: dev->data->port_id, strerror(rte_errno)); > drivers/net/mlx5/mlx5_testpmd.c: tlv_mng.nb_options, strerror(rte_errno)); > drivers/net/mlx5/mlx5_testpmd.c: fprintf(stderr, "File Access Error (%s)\n", strerror(rte_errno)); > drivers/net/mlx5/mlx5_testpmd.c: fprintf(stderr, "Unable to dump SQ/CQ HW Context (%s)\n", strerror(rte_errno)); > drivers/net/mlx5/mlx5_testpmd.c: fprintf(stderr, "File Access Error (%s)\n", strerror(rte_errno)); > drivers/net/mlx5/mlx5_testpmd.c: fprintf(stderr, "Unable to dump RQ/CQ HW Context (%s)\n", strerror(rte_errno)); > drivers/net/mlx5/mlx5_trigger.c: dev->data->port_id, strerror(rte_errno)); > drivers/net/mlx5/mlx5_trigger.c: dev->data->port_id, strerror(rte_errno)); > drivers/net/mlx5/mlx5_trigger.c: dev->data->port_id, strerror(rte_errno)); > drivers/net/mlx5/mlx5_trigger.c: dev->data->port_id, strerror(rte_errno)); > drivers/net/mlx5/mlx5_trigger.c: dev->data->port_id, strerror(rte_errno)); > drivers/net/mlx5/mlx5_trigger.c: dev->data->port_id, strerror(rte_errno)); > drivers/net/mlx5/mlx5_vlan.c: " %s", dev->data->port_id, strerror(rte_errno)); > drivers/net/mlx5/windows/mlx5_ethdev_os.c: dev->data->port_id, strerror(rte_errno)); > drivers/net/mlx5/windows/mlx5_os.c: strerror(rte_errno)); > drivers/net/mlx5/windows/mlx5_os.c: strerror(rte_errno)); > drivers/net/mlx5/windows/mlx5_os.c: eth_dev->data->port_id, strerror(rte_errno)); > drivers/net/mlx5/windows/mlx5_os.c: dev->data->port_id, strerror(rte_errno)); > drivers/net/mlx5/windows/mlx5_os.c: strerror(rte_errno)); > drivers/net/tap/rte_eth_tap.c: strerror(rte_errno)); > drivers/net/tap/rte_eth_tap.c: strerror(rte_errno)); > lib/eal/linux/eal_dev.c: "(rte_errno: %s)!", strerror(rte_errno)); > lib/eal/unix/eal_unix_memory.c: virt, size, flags, strerror(rte_errno)); > lib/pdump/rte_pdump.c: strerror(rte_errno));