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 3DB0B431A0 for ; Thu, 19 Oct 2023 02:01:31 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 376624113D; Thu, 19 Oct 2023 02:01:31 +0200 (CEST) Received: from mail-wr1-f41.google.com (mail-wr1-f41.google.com [209.85.221.41]) by mails.dpdk.org (Postfix) with ESMTP id 295C64029E for ; Thu, 19 Oct 2023 02:01:29 +0200 (CEST) Received: by mail-wr1-f41.google.com with SMTP id ffacd0b85a97d-3296b49c546so5708025f8f.3 for ; Wed, 18 Oct 2023 17:01:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1697673689; x=1698278489; darn=dpdk.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=tJ/dMD03IZF5d8e/byGnoSD6VXtRjDju8VaIod0kIRk=; b=QnuC/bpy0/ic+pN8wq3BJ0txZZcKqyJM4n+vN463zvXVatQ0R4La/rZWZ4Rcnwsm1e RlJZOLu5EFiYbqNgFiy6DlMwCNMJDJafVqK+t7bEYy9q9dUmcwcKrxVr0Mf8QCKouF41 1G4khlFhXddKRFGUpKPGhFB6KLF/aRCF1Wn47o8hAPMTfNcRxPFWKnp3c+1NfWTS9Vjr XsPk2KNLOLhtDTO2tq4kH7EmPeXIR9JT9Wh8O9JfYSGQ0YG5wA/FHnH+9lAhhqx5yMdN SSWgdKpHU95WBFlA+Gw8s4hgVLKdsnVRkDdQMna8H7tMcG7Z00pB0i+pKYHqQNIPM+iE IUHQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697673689; x=1698278489; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=tJ/dMD03IZF5d8e/byGnoSD6VXtRjDju8VaIod0kIRk=; b=ewz2d+NxyKeDLE1nC0TrSTvPyUiRu9vXaU27E7e8Pkix0ki8ByFfV4hwDJnE8uQm0r 5mMWQbfr1aWMlMreaLG2LFBB+dSaGTyWQv+UsISKPPaTxY9EMIr9hO0Nbp72kDcZPSPe zUaILhXn8CRHChD1KvNpQ7slmGfTj0e8pOH28HhWvEucu7A3oCwhETUzhKK1MMF9xs9e HdmUIN/6f8MdxBlKX2dr7cUr/Xr/r/Bj5fPCR4Snfy2K2W58MlGFkpO016OAkc4H5uLy S1r60auaT1g6ZzvI1K5Kd+mfOCW5u3I8nWFSJ/B+BLIHuDbnWIBVO5JciaK8DC9u4Ech TLvg== X-Gm-Message-State: AOJu0Yykykn9X6RNemn/cQTM1Nc3wwYOAkoomdXBfu3nAJzz4teMrynG /ebRpIzBEmBoimHhY/dvJBhNoG550j8UjRvz X-Google-Smtp-Source: AGHT+IH4L8s/F7A9vhqSwlBUtBC1hXUEH2hl+dyD5u34MtBNX8KE1ANH/3jy7683s/k+8ui420TYww== X-Received: by 2002:a5d:4b05:0:b0:32d:8855:138d with SMTP id v5-20020a5d4b05000000b0032d8855138dmr383382wrq.66.1697673688862; Wed, 18 Oct 2023 17:01:28 -0700 (PDT) Received: from localhost ([137.220.119.58]) by smtp.gmail.com with ESMTPSA id m5-20020a056000180500b0031c6581d55esm3160992wrh.91.2023.10.18.17.01.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 18 Oct 2023 17:01:28 -0700 (PDT) From: luca.boccassi@gmail.com To: David Marchand Cc: Viacheslav Ovsiienko , dpdk stable Subject: patch 'net/mlx5: fix leak in sysfs port name translation' has been queued to stable release 20.11.10 Date: Thu, 19 Oct 2023 00:59:26 +0100 Message-Id: <20231018235930.3144-37-luca.boccassi@gmail.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231018235930.3144-1-luca.boccassi@gmail.com> References: <20231018235930.3144-1-luca.boccassi@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: stable-bounces@dpdk.org Hi, FYI, your patch has been queued to stable release 20.11.10 Note it hasn't been pushed to http://dpdk.org/browse/dpdk-stable yet. It will be pushed if I get no objections before 10/21/23. So please shout if anyone has objections. Also note that after the patch there's a diff of the upstream commit vs the patch applied to the branch. This will indicate if there was any rebasing needed to apply to the stable branch. If there were code changes for rebasing (ie: not only metadata diffs), please double check that the rebase was correctly done. Queued patches are on a temporary branch at: https://github.com/bluca/dpdk-stable This queued commit can be viewed at: https://github.com/bluca/dpdk-stable/commit/9a4ca1230f9b432ca22ecff70696d3644a7a41ce Thanks. Luca Boccassi --- >From 9a4ca1230f9b432ca22ecff70696d3644a7a41ce Mon Sep 17 00:00:00 2001 From: David Marchand Date: Tue, 1 Aug 2023 17:18:31 +0200 Subject: [PATCH] net/mlx5: fix leak in sysfs port name translation [ upstream commit 1296e8d0d0fe74646fbb0339969cf3946f1ce84d ] getline() may allocate a buffer even though it returns -1: """ If *lineptr is set to NULL before the call, then getline() will allocate a buffer for storing the line. This buffer should be freed by the user program even if getline() failed. """ This leak has been observed on a RHEL8 system with two CX5 PF devices (no VFs). ASan reports: ==8899==ERROR: LeakSanitizer: detected memory leaks Direct leak of 120 byte(s) in 1 object(s) allocated from: #0 0x7fe58576aba8 in __interceptor_malloc (/lib64/libasan.so.5+0xefba8) #1 0x7fe583e866b2 in __getdelim (/lib64/libc.so.6+0x886b2) #2 0x327bd23 in mlx5_sysfs_switch_info ../drivers/net/mlx5/linux/mlx5_ethdev_os.c:1084 #3 0x3271f86 in mlx5_os_pci_probe_pf ../drivers/net/mlx5/linux/mlx5_os.c:2282 #4 0x3273c83 in mlx5_os_pci_probe ../drivers/net/mlx5/linux/mlx5_os.c:2497 #5 0x327475f in mlx5_os_net_probe ../drivers/net/mlx5/linux/mlx5_os.c:2578 #6 0xc6eac7 in drivers_probe ../drivers/common/mlx5/mlx5_common.c:937 #7 0xc6f150 in mlx5_common_dev_probe ../drivers/common/mlx5/mlx5_common.c:1027 #8 0xc8ef80 in mlx5_common_pci_probe ../drivers/common/mlx5/mlx5_common_pci.c:168 #9 0xc21b67 in rte_pci_probe_one_driver ../drivers/bus/pci/pci_common.c:312 #10 0xc2224c in pci_probe_all_drivers ../drivers/bus/pci/pci_common.c:396 #11 0xc222f4 in pci_probe ../drivers/bus/pci/pci_common.c:423 #12 0xb71fff in rte_bus_probe ../lib/eal/common/eal_common_bus.c:78 #13 0xbe6888 in rte_eal_init ../lib/eal/linux/eal.c:1300 #14 0x5ec717 in main ../app/test-pmd/testpmd.c:4515 #15 0x7fe583e38d84 in __libc_start_main (/lib64/libc.so.6+0x3ad84) As far as why getline() errors, strace gives a hint: 8516 openat(AT_FDCWD, "/sys/class/net/enp130s0f0/phys_port_name", O_RDONLY) = 34 8516 fstat(34, {st_mode=S_IFREG|0444, st_size=4096, ...}) = 0 8516 read(34, 0x621000098900, 4096) = -1 EOPNOTSUPP (Operation not supported) Fixes: f8a226ed65fa ("net/mlx5: fix sysfs port name translation") Signed-off-by: David Marchand Acked-by: Viacheslav Ovsiienko --- drivers/net/mlx5/linux/mlx5_ethdev_os.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/net/mlx5/linux/mlx5_ethdev_os.c b/drivers/net/mlx5/linux/mlx5_ethdev_os.c index 473dad3851..4bf70afe4f 100644 --- a/drivers/net/mlx5/linux/mlx5_ethdev_os.c +++ b/drivers/net/mlx5/linux/mlx5_ethdev_os.c @@ -1122,6 +1122,7 @@ mlx5_sysfs_switch_info(unsigned int ifindex, struct mlx5_switch_info *info) line_size = getline(&port_name, &port_name_size, file); if (line_size < 0) { + free(port_name); fclose(file); rte_errno = errno; return -rte_errno; -- 2.39.2 --- Diff of the applied patch vs upstream commit (please double-check if non-empty: --- --- - 2023-10-19 00:28:58.107234657 +0100 +++ 0037-net-mlx5-fix-leak-in-sysfs-port-name-translation.patch 2023-10-19 00:28:56.305806847 +0100 @@ -1 +1 @@ -From 1296e8d0d0fe74646fbb0339969cf3946f1ce84d Mon Sep 17 00:00:00 2001 +From 9a4ca1230f9b432ca22ecff70696d3644a7a41ce Mon Sep 17 00:00:00 2001 @@ -5,0 +6,2 @@ +[ upstream commit 1296e8d0d0fe74646fbb0339969cf3946f1ce84d ] + @@ -55 +56,0 @@ -Cc: stable@dpdk.org @@ -64 +65 @@ -index 639e629fe4..dd5a0c546d 100644 +index 473dad3851..4bf70afe4f 100644 @@ -67 +68 @@ -@@ -1083,6 +1083,7 @@ mlx5_sysfs_switch_info(unsigned int ifindex, struct mlx5_switch_info *info) +@@ -1122,6 +1122,7 @@ mlx5_sysfs_switch_info(unsigned int ifindex, struct mlx5_switch_info *info)