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 7348342F7F for ; Wed, 2 Aug 2023 13:56:12 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 697EC4282D; Wed, 2 Aug 2023 13:56:12 +0200 (CEST) Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10on2071.outbound.protection.outlook.com [40.107.94.71]) by mails.dpdk.org (Postfix) with ESMTP id 64EEE4021D; Wed, 2 Aug 2023 13:56:09 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=OJJ93LRDX6/LKZif1wCw5qdOL2UTGSx6M0vJgW7jI9Q8nBp95YltFC+S5R3f8XQR/6pui5YvbjmiUrJY2cVzG3nVbQ6oPJGyLa1AOeoCtbhq91uHoSroz51hOlFrmJo4tf1T4qQrM5Bax9JURaLsIKpQ3s7t/lw4HTF8ksRiNX3U7u5EsIJfiyli7rbvLPi8JHm6XQr4IuTnkKGGCAtflEH4Wq9H0OmHmV9twZii5lSeFq2+2QkFtGhnoAMffEVT2OI1L5JMY2DF3nxkJmM2IZ1DASwmTzP3S2ARpTaDCmfBh9vGdGPPPXnFEH9hn3TC8nO5vNjR2LlIOTk89Gie2w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=OJL5jqcbnHYAmtsGSlWPhhMSbJxPbFaRgnARI8+eF7c=; b=f+mMrWFKwEA1NtbUQ8KQh65PIZnsMNgO13nKcpt6s0T4BVIdLqdXtSfyq7IoQCDaRBoZmNGs9fzIkY8QrQPSbs8DFFxR0mh/FErMgL8C7ZB1NVQu+htw7HemPEOZgGprSWC22db2HIgf07dwaXCRYBPtgZflfDFEAFcWANFk1sZBvAVs39fI1mm8x3rc99pfVHr4c2JFDhxss5p7I6JIzt1FT31JZDmLqHcshOpy9of4FpsyoisNF6347+GD1adZXOrH2lN1LiiDrEldEo5Sv6gwNbzDpZe6d4HLiH/qMac8jh67eEbK5BZS0A0GFFAV3S10raXkFiagY6Q9ec9wYw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nvidia.com; dmarc=pass action=none header.from=nvidia.com; dkim=pass header.d=nvidia.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=OJL5jqcbnHYAmtsGSlWPhhMSbJxPbFaRgnARI8+eF7c=; b=bqQi53s7LJ3FM9ESbD53fYqaCcPyQBOZG+7CxI2/UDUAIuG8g18R6H5DmSii8eUZiTSHW70Mqq5bF7VoioRyOTv5M2/cxGOHTdck9+9oPuG2FpgiYs8v85EsoFWdpA2N2lAyJyKtCH4EZFEqeX9rtW2sv1yp8abXYfAtc60RbUHBP9xAaHcIjh4L7g7jvJJcFfTcX6S0gM4OxJN0fiXmgPFry854aSYUoZD29eOlJ5uBmWCNjBdXaHCVfu0p2PBqQyAYFPI1vDULXcZknDEe8TS+HhuHh5w/G9SW+/ZttY9DXS5wQHpI5VV0hVrnz14jzH1HpfMnhoeT14CmbzZcJQ== Received: from DM6PR12MB3753.namprd12.prod.outlook.com (2603:10b6:5:1c7::18) by MN6PR12MB8514.namprd12.prod.outlook.com (2603:10b6:208:474::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6631.45; Wed, 2 Aug 2023 11:56:06 +0000 Received: from DM6PR12MB3753.namprd12.prod.outlook.com ([fe80::35:6c75:37b5:a973]) by DM6PR12MB3753.namprd12.prod.outlook.com ([fe80::35:6c75:37b5:a973%3]) with mapi id 15.20.6631.045; Wed, 2 Aug 2023 11:56:06 +0000 From: Slava Ovsiienko To: David Marchand , "dev@dpdk.org" CC: "stable@dpdk.org" , Matan Azrad , Ori Kam , Suanming Mou , Bing Zhao Subject: RE: [PATCH] net/mlx5: fix leak in sysfs port name translation Thread-Topic: [PATCH] net/mlx5: fix leak in sysfs port name translation Thread-Index: AQHZxIt1j54FFRFqdk2nMoeneBae9a/W51TQ Date: Wed, 2 Aug 2023 11:56:06 +0000 Message-ID: References: <20230801151831.3703427-1-david.marchand@redhat.com> In-Reply-To: <20230801151831.3703427-1-david.marchand@redhat.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nvidia.com; x-ms-publictraffictype: Email x-ms-traffictypediagnostic: DM6PR12MB3753:EE_|MN6PR12MB8514:EE_ x-ms-office365-filtering-correlation-id: 3a0280ec-991e-4bcd-cf2c-08db934f746a x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: nidbXbKMGbhhCbEWO4guHfDfm0PEZLbEdh8nve0z1MTpMiL0NA2IsXfD99Xgj0oO4AdwVdDYAYhPvItLRRphvx8ppL3hM7C1saFtndBLf8kKLUrhBivD7n8pS/XSBgV0JuT2RWITj/gcsiN7EGMI1CSrdSfeTGW0tWHK98vRRNLl3v5+IIFyeX+73g7OxiTHwAPZnERbD6vNa6DWM949rzAnNfztw1NQptwppqnzs4Gv/IhPOX+ZpRIA6Q2i2gX4rmPg1g9IjbVTrUwdCbjgQ/Ah/I1f8nQqMvOnULH158JxY0Wft8C2ekG35FffDfSenIli2WdbaB2nL/ZvI336qe978nxWxPM5YU6Crra4tJCyJePJU6g1pqexcyhSvpvAQ9LyijwLNQ/nMLKBd4jbgk/m913GYFbBKWpuw2ZNKZNKuNy2oEyHKzMQwpUGgWeW9iYrpRvr12csgsglM3FQnHCfEYoGuhST5gQ+bYUHiZn5K5+HPfEjuSsbSd+6UcNBQfvOJQfkKVCb91QKdA9F1rK2lVGYXR+hdr+bZ05rRLszPJCCkWc37oSrRn2rNxOJtrz0ImP4EN7a/ze3d8oEOFjhWp7K3l94gQV1/zc/NdsnVZ6bUCBvyLSuCHbPkPrj x-forefront-antispam-report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DM6PR12MB3753.namprd12.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230028)(4636009)(346002)(39860400002)(366004)(136003)(396003)(376002)(451199021)(8676002)(5660300002)(83380400001)(122000001)(41300700001)(38100700002)(316002)(186003)(8936002)(53546011)(6506007)(38070700005)(107886003)(4326008)(66446008)(86362001)(66946007)(64756008)(66556008)(66476007)(76116006)(9686003)(2906002)(7696005)(71200400001)(52536014)(33656002)(478600001)(110136005)(54906003)(55016003); DIR:OUT; SFP:1101; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?BUXfRhgLL8f+xHna4pLyapj7I+S09oTMNKD+51/bOE1osMXrzPnRCgaQZ+EA?= =?us-ascii?Q?XjKD+uWGYxAu6dvwm8OvXy+0uC34n6pXkfw4hpRbOlV/+SrrMe0UqbsmrAEI?= =?us-ascii?Q?y51pWDO4BVqveSenXTFQX+9SGM9UVEwuzoOCpKk+ZqWtkVA9BwrlSbVIH2Uk?= =?us-ascii?Q?cvle4cSZvKwZ6fJHSAng2siNW4KKu+RhIBhyqGULbcY2k0fHA5I5twfh3XBd?= =?us-ascii?Q?SUmSufROnOJqw29GJhPpIuDo6bZ1Fr5LOh+kJnZ5EZXdQOpdC+TSyfv0/NyM?= =?us-ascii?Q?84fC7LikyFZa5zxl6HXQPs2Xo2FQ3G2chIAuZB5fB0XH3pFDvKLn9VWHnI0E?= =?us-ascii?Q?cVhAg7Tnhc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?us-ascii?Q?hQt2++zsnfvBQ1UQ1pdzLsfs3NNVt+A8s/QE+NZ+dBN6zxETcxCb0TIrd+br?= =?us-ascii?Q?7UQOe82UDHe03YZsmtxpwd0FUhKrR9GbFDIfZITyRKj5QZEmQSVJtoS4gdP6?= =?us-ascii?Q?XLouPbUMHxUMGS8ywoB+JxiintbCYt8EIdx7nDkDxViL9O7ZtnwzqIpC1Om5?= =?us-ascii?Q?9ZftF60gNp76Z42wMvXWI0K0WThctMfnySY/QCia1Atxm9z1IGWgP9a12iUF?= =?us-ascii?Q?VtzEHT5jGi1ArAqpzQnwp3X69RLUXIpg2WNCKi8Syz97I9k5tcSHr9FOCekX?= =?us-ascii?Q?C+D+kEIWFXvcsij9b2E=3D?= Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: DM6PR12MB3753.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 3a0280ec-991e-4bcd-cf2c-08db934f746a X-MS-Exchange-CrossTenant-originalarrivaltime: 02 Aug 2023 11:56:06.7759 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: q1KthZuRJaehYAxD4l9hz6TUQZtys4dWpFpe+5HqShkJ03fN1XyIS4tV0OFmuJtMlCaGkxSLxGlByA1DMOF26g== X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN6PR12MB8514 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 > -----Original Message----- > From: David Marchand > Sent: Tuesday, August 1, 2023 6:19 PM > To: dev@dpdk.org > Cc: stable@dpdk.org; Matan Azrad ; Slava Ovsiienko > ; Ori Kam ; Suanming Mou > ; Bing Zhao > Subject: [PATCH] net/mlx5: fix leak in sysfs port name translation >=20 > getline() may allocate a buffer even though it returns -1: > """ > If *lineptr is set to NULL before the call, then getline() will allocat= e a buffer > for storing the line. This buffer should be freed by the user program ev= en if > getline() failed. > """ >=20 > This leak has been observed on a RHEL8 system with two CX5 PF devices (no > VFs). >=20 > ASan reports: > =3D=3D8899=3D=3DERROR: LeakSanitizer: detected memory leaks >=20 > 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) >=20 > As far as why getline() errors, strace gives a hint: > 8516 openat(AT_FDCWD, "/sys/class/net/enp130s0f0/phys_port_name", > O_RDONLY) =3D 34 > 8516 fstat(34, {st_mode=3DS_IFREG|0444, st_size=3D4096, ...}) =3D 0 > 8516 read(34, 0x621000098900, 4096) =3D -1 EOPNOTSUPP (Operation > not supported) >=20 > Fixes: f8a226ed65fa ("net/mlx5: fix sysfs port name translation") > Cc: stable@dpdk.org >=20 > Signed-off-by: David Marchand > --- > drivers/net/mlx5/linux/mlx5_ethdev_os.c | 1 + > 1 file changed, 1 insertion(+) >=20 > diff --git a/drivers/net/mlx5/linux/mlx5_ethdev_os.c > b/drivers/net/mlx5/linux/mlx5_ethdev_os.c > index 639e629fe4..dd5a0c546d 100644 > --- a/drivers/net/mlx5/linux/mlx5_ethdev_os.c > +++ b/drivers/net/mlx5/linux/mlx5_ethdev_os.c > @@ -1083,6 +1083,7 @@ mlx5_sysfs_switch_info(unsigned int ifindex, > struct mlx5_switch_info *info) >=20 > line_size =3D getline(&port_name, &port_name_size, file); > if (line_size < 0) { > + free(port_name); > fclose(file); > rte_errno =3D errno; > return -rte_errno; > -- > 2.41.0 Good catch, thank you Acked-by: Viacheslav Ovsiienko