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 5D0E542DAF; Mon, 3 Jul 2023 12:57:31 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 4DB6240ED5; Mon, 3 Jul 2023 12:57:31 +0200 (CEST) Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by mails.dpdk.org (Postfix) with ESMTP id D018640156 for ; Mon, 3 Jul 2023 12:57:28 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1688381849; x=1719917849; h=from:to:cc:subject:date:message-id:references: in-reply-to:content-transfer-encoding:mime-version; bh=FRW89jI0014EydxUd6deSFYtv7yFwuoyp/F61mwfUEw=; b=WoO09zw1HY8RB06IG8lCvwR2Yx7sVnigZaE60Sax9Ah3/NZuHoBC4Gar ZBAep+4W8mm9at5CIpKlaaJLw+V/z9QwVF0N8n+0je6Lz9HbXeIyHtD5j sdru0ZFAWwdFDz1BAOWKBEmE9/PK6TOgsjKqXUS6y9T6bfnwE7dIQdbDo cibmJVHsX6yZWA5DBJK4mAT8rZVIapwUewGZwhOVWsEppAlq9iq7vd/L0 xgX+28HPTvCSin1nHVdM0ApRDsldSmS9GLaGDdHB8IM22HqTlO3FsepzE FASGkjuLSe6ws04vtNn4kNTLgCKzlyjLP0+CFNugZnDfdauBSlWPjXyE6 w==; X-IronPort-AV: E=McAfee;i="6600,9927,10759"; a="360329528" X-IronPort-AV: E=Sophos;i="6.01,178,1684825200"; d="scan'208";a="360329528" Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Jul 2023 03:57:27 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10759"; a="753711223" X-IronPort-AV: E=Sophos;i="6.01,178,1684825200"; d="scan'208";a="753711223" Received: from fmsmsx601.amr.corp.intel.com ([10.18.126.81]) by orsmga001.jf.intel.com with ESMTP; 03 Jul 2023 03:57:27 -0700 Received: from fmsmsx610.amr.corp.intel.com (10.18.126.90) by fmsmsx601.amr.corp.intel.com (10.18.126.81) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.27; Mon, 3 Jul 2023 03:57:26 -0700 Received: from fmsedg601.ED.cps.intel.com (10.1.192.135) by fmsmsx610.amr.corp.intel.com (10.18.126.90) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.27 via Frontend Transport; Mon, 3 Jul 2023 03:57:26 -0700 Received: from NAM10-BN7-obe.outbound.protection.outlook.com (104.47.70.106) by edgegateway.intel.com (192.55.55.70) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2507.27; Mon, 3 Jul 2023 03:57:26 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Du8kgjI/DW44aI3ArUhiaIzla2AFSinKgs+KR/Q0GcI/vWWylONUkHBjHaLBcUk0X20OPqfnWi9OdwwQHxwPPBUd387SF5B7x5iCrhoV7ol1/gdkYKcAIltLUQVRKO5rimofgQSmkHSg61w0hKENqvjCM8+3hiTwHM/80anhK2yrVa5stxhACL/Nm7v4J2OLfyXPcAfI0gX+ZKVrAzU/4KEN4o9GWrUBYougieOOxg4+FomFp38FGnLaMiuGCpbkAc0zZOKL3l5OxuqqwjSfAwvMJ+bgvXy/y6qmMh9XObfKHAar0ZPM404YHYYpmagcSS623KiX1fE+H1UlKgBqtg== 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=Vubaonjwz5D+U1KRxb0GF6UK7QQtgu3kquiygEjDJL0=; b=SzPZ5Ne+UTYPh63VnCEqS4gqWRBN6ZIwkH/PwtfWnXcNgjLtrZWSpci7Zw+Rs1gXtwP5NlN0eFft85IwauUbGOjcF5pS18A65aXF7FTLygwv4ikeVL86DmOSYSb3G1SQe7lcR83wFVpN9SfkwBxU3A5qe12jncsBbIf0wnb8hihd9H1nvUBioPCJwm9dHBFpeUclfUiD8YWvdqhCOOFuTY7V0FrdkKFMTYdA3nzAvtqOIlQ1st2DBx7qwmgYWdpZqm4bLOEIBpCYRvA6xA67F5qmQx0wW4p3R5ac8iRi3g+6p1FcoCG0/JfF0ypB9gUv1HVhO3FrExifRepolkhkvA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=intel.com; dmarc=pass action=none header.from=intel.com; dkim=pass header.d=intel.com; arc=none Received: from DS0PR11MB7442.namprd11.prod.outlook.com (2603:10b6:8:14d::22) by SA0PR11MB4656.namprd11.prod.outlook.com (2603:10b6:806:96::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6544.24; Mon, 3 Jul 2023 10:57:22 +0000 Received: from DS0PR11MB7442.namprd11.prod.outlook.com ([fe80::e536:321a:f1ad:7484]) by DS0PR11MB7442.namprd11.prod.outlook.com ([fe80::e536:321a:f1ad:7484%4]) with mapi id 15.20.6544.024; Mon, 3 Jul 2023 10:57:22 +0000 From: "Dumitrescu, Cristian" To: Stephen Hemminger , "Min Hu (Connor)" CC: "dev@dpdk.org" , "ferruh.yigit@intel.com" , "jerinj@marvell.com" , "jianjay.zhou@huawei.com" , "jia.guo@intel.com" , "g.singh@nxp.com" , "andrew.rybchenko@oktetlabs.ru" , "hemant.agrawal@nxp.com" , "orika@nvidia.com" Subject: RE: [dpdk-dev] [PATCH 06/10] lib/librte_pipeline: fix the use of unsafe strcpy Thread-Topic: [dpdk-dev] [PATCH 06/10] lib/librte_pipeline: fix the use of unsafe strcpy Thread-Index: AQHZq33457nc776dzUuBzdaglAiwNa+n4xFA Date: Mon, 3 Jul 2023 10:57:22 +0000 Message-ID: References: <1618839289-33224-1-git-send-email-humin29@huawei.com> <1618839289-33224-7-git-send-email-humin29@huawei.com> <20230630110851.491aa2aa@hermes.local> In-Reply-To: <20230630110851.491aa2aa@hermes.local> 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=intel.com; x-ms-publictraffictype: Email x-ms-traffictypediagnostic: DS0PR11MB7442:EE_|SA0PR11MB4656:EE_ x-ms-office365-filtering-correlation-id: 7c4052eb-e823-4656-c3b7-08db7bb44766 x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: TAHwenbY5A9dNT50+6CvrATKBprchmj94agMPNpIJ1CVLjI/Fh2EVY4dKa5VgecbvYpP+SqUMYvJ80tvGLzYr4Z7wBoEGqwde/NxAzvMbqLlDx4ycZWRLRxor+om9qvPQ75CQ/3WLnMPeUO3C93tN69o7Hycb0IrdW1Y6ahs2OJzzm0czdH4KmMHcMfEN20x7dCKqxRKU8J3l8JOWBWASP4I9wc+YSdBmoVGMtfkeIGcrRCLldoh62TzP65LrLincdpvWxQALJh47dRs4ARjJc3bmGiPicSlEgD8HyZJnqnzvRoqWfp2jGEQo4YcsHgUStRy/ECGtAg2MLbZC1x3stFYvD82+tImxGxJVVwBQyXiMb00Tissnw0aVgrUFrYq1yhoeOFWbi3V123l43KLzrpiKMj9gu0sROHhsXkhVYCZ3q6VG+IEm3+xPkEXZ2hV8F5jbz7/NiCOkqS5wT/Z9tTrs1BlnRh/ZVwwQ2cKk9euPjxGLmirwUyo9ZldHOm3z0DlbK2iypWIEdfx0cPFEIHms6rqgeS5h8jS0nNdN5KdXmSaQiWPNGBkLCv2bvsdYJ4pj78PyhjmMPKk/7lOCHKVo/C9M+yN6noxB7/RWLGgZuHGyBhuaJEDSb0GVyA/ x-forefront-antispam-report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DS0PR11MB7442.namprd11.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230028)(39860400002)(396003)(376002)(136003)(346002)(366004)(451199021)(38100700002)(71200400001)(33656002)(2906002)(7696005)(8936002)(38070700005)(110136005)(54906003)(8676002)(55016003)(41300700001)(52536014)(5660300002)(478600001)(76116006)(9686003)(53546011)(66946007)(66556008)(66476007)(64756008)(66446008)(26005)(6506007)(86362001)(186003)(4326008)(316002)(122000001)(83380400001)(82960400001); DIR:OUT; SFP:1102; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?N64++dLAZkSAv3k+4pjfcgQs9ZLx4K3fEsXBE+RlEarhU9XFJqFaSmIqLJt9?= =?us-ascii?Q?5dNIHZ69iH+28n/XDHZ4+0kEZBo8Z4ahicK0rS/nRgtwgoaaFhIdylZPqpoy?= =?us-ascii?Q?MXpjC9R3h5HGjeEQYxDL9La5LXOjoDa/FFNY1IloG8cRvLe0S/uAYn/astxi?= =?us-ascii?Q?TmZhkNdWgOv6DIimfgDVBc4tB+7NmDuG9RENmfNDeq2OQInB5tqXbLwuSV4j?= =?us-ascii?Q?3tHyXkqx9x5nH35VsrWM/jtEtp9pjfnbyFTWlqyOhd7HAKH9niOJdJLXGQzz?= =?us-ascii?Q?Zy/LV4sd+a3w2iXUE7eU5DCQHJN0DA3m/XDI7/5dQkvmR/hUxH7h+Px/BaMb?= =?us-ascii?Q?c3vAUkTnEXFl4UHH93z/tzK4Hdx013NATVimQFVDDJp52ZLh7EBg2HID0wsh?= =?us-ascii?Q?5UOZktBQIXq4UVpBl+crautKGmqVZC4Onwze/NGFclUfiZabekHeZXgskR81?= =?us-ascii?Q?zMmxEAXczsTIyyttnHtooj4iGuKUOq4IkKalri1swUOb2v7NZoe3vV7wcZjT?= =?us-ascii?Q?114CqU19r6wr1hscImhCgl+df1zIEo1/zLcWGyGqDYY8DvRXHSCbHNqHuSvm?= =?us-ascii?Q?w5uryttB/65j5Q5bBetU1NbqzZwZwyEMyikeJgYy2UFiQd9USFQmLPrWNH6X?= =?us-ascii?Q?eFVe8aWyyPCFIQGa1WXZop9R+3t+3WDLk5CfgWAYXiK83XTDVP999ftK5NCi?= =?us-ascii?Q?8QsMgX0B/gec6c3TtNtM49fNS/IoYGjBFvAs5fax6Q4s2U2PAiWiDSMxvvDE?= =?us-ascii?Q?myMaQfSimMNi8x29FMLtfaVw8x27VbtgMTOXUPKpduzZJA43bZm+cOxKDk+P?= =?us-ascii?Q?E63VTWTgZm7La8HhaFiDkkow8tJxvGWFDKS1d3isBkXatyPLXtxOC3K84J2b?= =?us-ascii?Q?NbAbve1nm9caBBd+tG906Vn1mNkWS4vZeN7Ii1sUFtPOtLhFHBJBNb+DibJB?= =?us-ascii?Q?XuPxeDapEM7dnq/FyV3hAZZQYUv68mRg7hKdK2DCUQhKhtvlb9rrTVsRk+k5?= =?us-ascii?Q?IJ2zJy6UWC2WxXWc7bIZICpmOseqBQqrTJulalsrblCDEkiXTuuWIDq1Ka8e?= =?us-ascii?Q?c1/H4kXPaFg3R6eObWM7xwox0vaUDCKSCZ8nOrZaiNB9ocLiCzdHELhxQhAC?= =?us-ascii?Q?9QSM0QyHFXnqmlz2WxyMJm6cAFEtBXNohkAHueXSCgIIimIvJzA6KGwvV2ef?= =?us-ascii?Q?3gZ/uEpY5svzTbkYKNrawbAYMA2TS5AGn2MclRRU3SgVxuKA5/ljHrpHHHOP?= =?us-ascii?Q?bMPOd7pc+PMWMj9qUSh5MQcHkORrSmc29It7juYgll41QeHbgzXOd8SMcgDB?= =?us-ascii?Q?R2GFrcSM7tBWDuWv1sTHmN9P6xlOkv+rnzmtk79fAvxnBKgbxZZYr1iQFJPo?= =?us-ascii?Q?PJlUuU3vx6gG+igGsgQ+IGb7t5GAnrEOcY2NLjD5Om54g7jzHmw+XFoxDtkM?= =?us-ascii?Q?ODwhqf7gzlEfZMuNl82VnIW0jg2uzjv1uBQuNfA0WveJTbNcR4qx+6UvfvKK?= =?us-ascii?Q?c9zFZ75CgNvdTt68J4AXD0IuP+l060EWXWHzHXqeuUIwTRhPXnq9fFovcaid?= =?us-ascii?Q?zioQ5B7bKCLYWIX4uHgb8MlUrqStgVwJ/kut1QfKzaJ0HlCpCgVkYNLoAN2w?= =?us-ascii?Q?3w=3D=3D?= Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: DS0PR11MB7442.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 7c4052eb-e823-4656-c3b7-08db7bb44766 X-MS-Exchange-CrossTenant-originalarrivaltime: 03 Jul 2023 10:57:22.5222 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 46c98d88-e344-4ed4-8496-4ed7712e255d X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: 97Qod6VlrAFneR/SximmauCih3hI7ZNawHiZ+Wj50Jer13U7JjhgHqmIjNLnaIhSOnNmWiQzsQqArxmauIWPf/dPZxwhYyCxxVbFQTr+lE8= X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA0PR11MB4656 X-OriginatorOrg: intel.com 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 > -----Original Message----- > From: Stephen Hemminger > Sent: Friday, June 30, 2023 7:09 PM > To: Min Hu (Connor) > Cc: dev@dpdk.org; ferruh.yigit@intel.com; Dumitrescu, Cristian > ; jerinj@marvell.com; > jianjay.zhou@huawei.com; jia.guo@intel.com; g.singh@nxp.com; > andrew.rybchenko@oktetlabs.ru; hemant.agrawal@nxp.com; orika@nvidia.com > Subject: Re: [dpdk-dev] [PATCH 06/10] lib/librte_pipeline: fix the use of= unsafe > strcpy >=20 > On Mon, 19 Apr 2021 21:34:45 +0800 > "Min Hu (Connor)" wrote: >=20 > > From: HongBo Zheng > > > > 'strcpy' is called in rte_swx_ctl_table_info_get, this function > > is unsafe, use 'strncpy' instead. > > > > Fixes: 393b96e2aa2a ("pipeline: add SWX pipeline query API") > > Cc: stable@dpdk.org > > > > Signed-off-by: HongBo Zheng > > Signed-off-by: Min Hu (Connor) > > --- > > lib/librte_pipeline/rte_swx_pipeline.c | 4 ++-- > > 1 file changed, 2 insertions(+), 2 deletions(-) > > > > diff --git a/lib/librte_pipeline/rte_swx_pipeline.c > b/lib/librte_pipeline/rte_swx_pipeline.c > > index 4455d91..d4db4dd 100644 > > --- a/lib/librte_pipeline/rte_swx_pipeline.c > > +++ b/lib/librte_pipeline/rte_swx_pipeline.c > > @@ -9447,8 +9447,8 @@ rte_swx_ctl_table_info_get(struct rte_swx_pipelin= e > *p, > > if (!t) > > return -EINVAL; > > > > - strcpy(table->name, t->name); > > - strcpy(table->args, t->args); > > + strncpy(table->name, t->name, RTE_SWX_CTL_NAME_SIZE); > > + strncpy(table->args, t->args, RTE_SWX_CTL_NAME_SIZE); > > table->n_match_fields =3D t->n_fields; > > table->n_actions =3D t->n_actions; > > table->default_action_is_const =3D t->default_action_is_const; >=20 > This patch is unnecessary. > Both structures declare the same size for the name and args. > Therefore the strcpy is always safe as long as the table structure > is correctly setup with null terminated string. If not there are worse bu= gs. +1 Agree with Steve, this is not necessary here.