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 1222343337; Wed, 15 Nov 2023 10:40:57 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 8BFBC402B0; Wed, 15 Nov 2023 10:40:56 +0100 (CET) Received: from EUR05-DB8-obe.outbound.protection.outlook.com (mail-db8eur05on2044.outbound.protection.outlook.com [40.107.20.44]) by mails.dpdk.org (Postfix) with ESMTP id B805C40261 for ; Wed, 15 Nov 2023 03:41:17 +0100 (CET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=j3njHLN6clrY6CfJbipi1AoCa8N838ZJ7HEEhXeEvCR/8R/RaH55Nghqj8zROwYYPcUzrPRTaK6muIK9qqhuimS4m+l6A3qXBhcroTe1vOYzwfOjVqSOlzIUWurRuXRqb1wii94TeIsjCsuSuiUfn/8+kNU4WonpVXpF+a2E74fjSG1azyYaOnUS0M76tv87CLfqmOkJJWqKyit4y9M779vLZRCrkJtZCdLH8Xmg/g25K2NrvleOWaT6/Pcj3CnRcXAED1+6QFH+rSczEaOBQ3pMw0UgERNk5sth8SskfGXWzhVaQ6CYP6HlgRDIqja0wosEhNyIw9XJ09vFDGyGiw== 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=AliZlxwxiKupC2ysAiubFK6ZUVilW27RAx4CmyAkNmA=; b=D/OHVG7ftfimAF8JpuJaRXjMUP8/d3KXmYcxyd41zOvwCmIySzh1RXqwYDQVJpqj1DeeRMDjOjzOHU7Gh2qNr5ocC9MpS0n8hQu+1o7WlzoNZmhmW0QqbcB4hHhVmlN532wKfU3Na3n6XJOi2YST5fdELrBewT/5Pnx3TvRJ69i7RrVew2mRD3weC5Z1VETvBtk+DsmvvwZYImLxjJCyRxwb1mdNJovcNWWKN4rqcR+IvdVDvpUgqVOU6ym0JE0ZZZDXGYj0TwrlfVXk50h+8xTFBXNaPFZIKR3oQiT181bKaKv0ZoU9wFV91vvzL8qLo9pGcntI62NtIXPL3QPVZQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=AliZlxwxiKupC2ysAiubFK6ZUVilW27RAx4CmyAkNmA=; b=IXqOuD9/6SCHNZrOXyhekB6hHX7ystGOMOng70Al1crxBT8ZXgKWceUjGsCtYWuZSyKPZao6bAZU8/DE0vyRTBS8ae7mV8MfQb1mmG2WWEwy303wXZSNQBKCNWNA3bXKsOKmL0kzfwDaQQh+5cOzvmOQnY583CTTxv3H9kwIMU4= Received: from AS8PR04MB8562.eurprd04.prod.outlook.com (2603:10a6:20b:421::9) by DU2PR04MB8645.eurprd04.prod.outlook.com (2603:10a6:10:2dc::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7002.18; Wed, 15 Nov 2023 02:41:15 +0000 Received: from AS8PR04MB8562.eurprd04.prod.outlook.com ([fe80::1aee:7715:a032:5079]) by AS8PR04MB8562.eurprd04.prod.outlook.com ([fe80::1aee:7715:a032:5079%4]) with mapi id 15.20.7002.015; Wed, 15 Nov 2023 02:41:15 +0000 From: Sachin Saxena To: Jie Hai , "dev@dpdk.org" , Hemant Agrawal CC: "lihuisong@huawei.com" , "fengchengwen@huawei.com" Subject: RE: [PATCH 15/21] bus/fslmc: replace strtok with strtok_r Thread-Topic: [PATCH 15/21] bus/fslmc: replace strtok with strtok_r Thread-Index: AQHaFh9Pmp1I5VW1vUyPd1xhH51iP7B6rgUA Date: Wed, 15 Nov 2023 02:41:15 +0000 Message-ID: References: <20231113104550.2138654-1-haijie1@huawei.com> <20231113104550.2138654-16-haijie1@huawei.com> In-Reply-To: <20231113104550.2138654-16-haijie1@huawei.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=nxp.com; x-ms-publictraffictype: Email x-ms-traffictypediagnostic: AS8PR04MB8562:EE_|DU2PR04MB8645:EE_ x-ms-office365-filtering-correlation-id: bb3fdf77-e94e-45cc-3968-08dbe584568d x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: 9FLcJ71YWuL0Gavr6V9s/mXuEaSkjibRFqMv8CX61wUrDuPzRWx6SVUOsjsi7Qt/7/MDLC4RwL0ppD8JgldwhcCIseredVD3d1ojRkBEbbR/3tZXolEXQRa2W0M0rkFMocg/mh1zh9g9MSwpNbRpc/3TwqTLOEF1bs8RGXcAiOm+u0rH2VDmIDys5HfnnMgG9OYDpYwQ+TaYgyQu4quHsUrfkJ5sRDTob2XDxFhd5S0+RHNYLaq83kwDtm5uklro6daxxbfqPEGzBDAdPjpmCJBmV7dpycLI8ykarGl5JS3nQiJeHP1UUazEW5o1ofOIJ6h3pok4L38Ck6ZiLglPhnN85HHEFCFNqJxqCljZc3x4s6uFNYrqJPjLDLPbV6mn96QeUvQ1D07eD4t24sNMN2HpWSxuKi9pdu1eJUqSrGNip2Y2+0KE1+dm/UocVpIGd1DbYE8dwBPnK7+VkpsEiimBCnLob2+l/Hn4JeszWn1tEkAdFNIvJ0FPlFwi6aN+cmbZea6Uol40GgjQQtVHaXhXHJtgY0Dgo43VcAKr4Ef+tNfzuJsy/OMhxBXTpb/PdTL56n1NEycST17uPJ7A2mqJ//QddkMI8maD2sZVTgYSe9081/g5ZENaou0eBiHv x-forefront-antispam-report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AS8PR04MB8562.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230031)(39860400002)(376002)(346002)(396003)(366004)(136003)(230922051799003)(1800799009)(64100799003)(451199024)(186009)(9686003)(8936002)(26005)(478600001)(110136005)(86362001)(52536014)(8676002)(4326008)(41300700001)(2906002)(44832011)(5660300002)(33656002)(76116006)(38070700009)(54906003)(64756008)(66556008)(66446008)(66946007)(66476007)(6636002)(316002)(53546011)(71200400001)(6506007)(7696005)(38100700002)(55016003)(83380400001)(122000001); DIR:OUT; SFP:1101; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?2sTBvRt5ZKByhwp16tfNbgnv0qF1QNphUad111IcR+OUX0pGQ+xGTi3+PvlU?= =?us-ascii?Q?Swl6JLvYDMqf498BugNjKtoswQtjiAkyGT7fYTuMZlS3CKqxh9LqiYIIzp9q?= =?us-ascii?Q?aj0/hzDd8mSRHrrZ2e3oRbM92JTJ6dH4vCIxBzSd+U428BEfotkUJYFQv4SY?= =?us-ascii?Q?JxjW8aIVew6hozjn+cIKsA6A053S9mICmk6pZH//kMEp1fDFrmrzi7EZmeHZ?= =?us-ascii?Q?pozqAt8z/VAeWhendZW2TQnOQm2SesKqR5WLjEi2JiseSPIQsfzZClXaYVZv?= =?us-ascii?Q?+llRBSOQDJLK8oxVSNkSZcsfm5FuwKLwC2spBVOaERFuX+5ZJ1B3wDTgDOYs?= =?us-ascii?Q?phpqTmqEGG1+sUEdHbfsn8Q9caKtHisNt65PL8BV51DIFzyg8oeV1Fn9PRIQ?= =?us-ascii?Q?mNEH9+tFQ8HeolRiXvLVn+OhvPZ8ctZ5KSK2zEXjml41kWhXX3FA+2Z4oIUP?= =?us-ascii?Q?7qE+C8CdZ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V8T?= =?us-ascii?Q?SVAp55esrHHAzZ+B2G7lDF5VpJmIZI7EFX82/WFt2O940CJtvtFImyvGvxAf?= =?us-ascii?Q?IFi0YliIY/faJDmoR9j3ZravNUFisrBTAnueM1CyAtguPcQumHtml03qZ/EM?= =?us-ascii?Q?YgOriiPUai2O3OsC0Jcr/nC9DzJw3lxzljKRtSnRnJGmfClrHWAAT49jVRNV?= =?us-ascii?Q?kUojyGK4ON3Nu2ZBn/PqUpzRvE9P6IVmEYwtzvit?= Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: AS8PR04MB8562.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: bb3fdf77-e94e-45cc-3968-08dbe584568d X-MS-Exchange-CrossTenant-originalarrivaltime: 15 Nov 2023 02:41:15.3069 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: vCCcYjVB26y5EuUgvaxhh7auZCXlQYOGeTIZzMYTXdbuvy/7vyGmvMAcjFXNEXHaTSwejWqKMubjq0j74OaCHg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DU2PR04MB8645 X-Mailman-Approved-At: Wed, 15 Nov 2023 10:40:55 +0100 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 Acked-by: Sachin Saxena > -----Original Message----- > From: Jie Hai > Sent: 13 November 2023 04:16 PM > To: dev@dpdk.org; Hemant Agrawal ; Sachin > Saxena > Cc: haijie1@huawei.com; lihuisong@huawei.com; fengchengwen@huawei.com > Subject: [PATCH 15/21] bus/fslmc: replace strtok with strtok_r >=20 > Multiple threads calling the same function may cause condition race issue= s, > which often leads to abnormal behavior and can cause more serious > vulnerabilities such as abnormal termination, denial of service, and > compromised data integrity. >=20 > The strtok() is non-reentrant, it is better to replace it with a reentran= t function. >=20 > Signed-off-by: Jie Hai > --- > drivers/bus/fslmc/fslmc_bus.c | 5 +++-- > drivers/bus/fslmc/portal/dpaa2_hw_dpio.c | 4 ++-- > 2 files changed, 5 insertions(+), 4 deletions(-) >=20 > diff --git a/drivers/bus/fslmc/fslmc_bus.c b/drivers/bus/fslmc/fslmc_bus.= c > index 57bfb5111a97..7960ad3979ef 100644 > --- a/drivers/bus/fslmc/fslmc_bus.c > +++ b/drivers/bus/fslmc/fslmc_bus.c > @@ -131,6 +131,7 @@ scan_one_fslmc_device(char *dev_name) { > char *dup_dev_name, *t_ptr; > struct rte_dpaa2_device *dev =3D NULL; > + char *sp =3D NULL; > int ret =3D -1; >=20 > if (!dev_name) > @@ -168,7 +169,7 @@ scan_one_fslmc_device(char *dev_name) > } >=20 > /* Parse the device name and ID */ > - t_ptr =3D strtok(dup_dev_name, "."); > + t_ptr =3D strtok_r(dup_dev_name, ".", &sp); > if (!t_ptr) { > DPAA2_BUS_ERR("Invalid device found: (%s)", dup_dev_name); > ret =3D -EINVAL; > @@ -199,7 +200,7 @@ scan_one_fslmc_device(char *dev_name) > else > dev->dev_type =3D DPAA2_UNKNOWN; >=20 > - t_ptr =3D strtok(NULL, "."); > + t_ptr =3D strtok_r(NULL, ".", &sp); > if (!t_ptr) { > DPAA2_BUS_ERR("Skipping invalid device (%s)", > dup_dev_name); > ret =3D 0; > diff --git a/drivers/bus/fslmc/portal/dpaa2_hw_dpio.c > b/drivers/bus/fslmc/portal/dpaa2_hw_dpio.c > index 4aec7b2cd8ba..09a1a2b23787 100644 > --- a/drivers/bus/fslmc/portal/dpaa2_hw_dpio.c > +++ b/drivers/bus/fslmc/portal/dpaa2_hw_dpio.c > @@ -129,7 +129,7 @@ dpaa2_affine_dpio_intr_to_respective_core(int32_t > dpio_id, int cpu_id) > uint32_t cpu_mask =3D 1; > int ret; > size_t len =3D 0; > - char *temp =3D NULL, *token =3D NULL; > + char *temp =3D NULL, *token =3D NULL, *sp =3D NULL; > char string[STRING_LEN], command[COMMAND_LEN]; > FILE *file; >=20 > @@ -141,7 +141,7 @@ dpaa2_affine_dpio_intr_to_respective_core(int32_t > dpio_id, int cpu_id) > } > while (getline(&temp, &len, file) !=3D -1) { > if ((strstr(temp, string)) !=3D NULL) { > - token =3D strtok(temp, ":"); > + token =3D strtok_r(temp, ":", &sp); > break; > } > } > -- > 2.30.0