From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id A8EDAA0538; Wed, 5 Feb 2020 08:28:23 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id B40AD1C115; Wed, 5 Feb 2020 08:28:22 +0100 (CET) Received: from EUR02-VE1-obe.outbound.protection.outlook.com (mail-eopbgr20041.outbound.protection.outlook.com [40.107.2.41]) by dpdk.org (Postfix) with ESMTP id B995C1C0C5 for ; Wed, 5 Feb 2020 08:28:20 +0100 (CET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=M9KOsIpL2ATNbnRiEP1nfNbKUBtzb59rHC7cHg//QsaNKP9mFFH7Uaj+luShSiOaEmruk/hjdcxthmWyaNGdhA+eS+hYEp7KKEkut00s6UAb6fnz3sSDm/7r2p2KiDPDAoMvHIN4r1NkGNXYL06y6USMiCjhRGtC4CsvAl6WY6nz2nFDqHJv051tll0Zc7en/UZCfpurc/iH5728odhsyGU/DcHIzPZ0wPpVfRXXuht69J78Aeze2uTt5JeJoseEKuc4b/+64xogrKhlePtyr2MtIa4yEL9lSD79twca7VTVQceY++qVX8nR7dig3GEB92pp0glpW/yvqH+LFFccrA== 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-SenderADCheck; bh=MVhax24caxKhTR41oqH7h1dbOFib2arztwTLSbTtnkM=; b=naGZftHKurG5CZ3p+v/CTFhi05k9HZFIOsMGPrNrde0MjtK6tjMgfHiz4dYPWObYDDTbqL1/xdklIPd6E/StZg5Yk5cAfvC5lsqqL7/oJuy4aa6Zb4WbYhTz476/ZwwvIP+SYjdvMdMc5y0R9K31Gj8VB23kSmqc4p9RF88sRjAAe6//X6qfri62jxe1rVNtx2giFYzw/yf1neSwulPBz+LShq5KKc/dODi3axe64c4o0J4c59ZQUIAO7fcGP6DxzekpH6daHOg5Xh7uFwO8UMnoUBoD8eWxYerL8vKbPqUYUdnmo/1nx7ExCcczfNaG4vzyDBP9v5ra2++Yx7b45A== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=mellanox.com; dmarc=pass action=none header.from=mellanox.com; dkim=pass header.d=mellanox.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Mellanox.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=MVhax24caxKhTR41oqH7h1dbOFib2arztwTLSbTtnkM=; b=Nkuv9aZtpMo8mdvte3tC/TRUUx1GYx9HwOGbQURH4SfpKlqU91352E/mwqSXaKcI415Z/SqVEGNn/zYnFm5UWJgBIVxkFETHPi0RZ5gqLIojoILh24iVra3igDyJuNYe6EeU4pxUkB33Pa7eGITHZM7rVG/CC99nQhM86W8bIKc= Received: from AM4PR05MB3265.eurprd05.prod.outlook.com (10.171.188.154) by AM4PR05MB3473.eurprd05.prod.outlook.com (10.170.126.150) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2707.21; Wed, 5 Feb 2020 07:28:18 +0000 Received: from AM4PR05MB3265.eurprd05.prod.outlook.com ([fe80::68eb:ad79:71f4:110f]) by AM4PR05MB3265.eurprd05.prod.outlook.com ([fe80::68eb:ad79:71f4:110f%3]) with mapi id 15.20.2686.035; Wed, 5 Feb 2020 07:28:18 +0000 From: Slava Ovsiienko To: Dekel Peled , Matan Azrad , Raslan Darawsheh CC: "dev@dpdk.org" , Bing Zhao Thread-Topic: [PATCH] net/mlx5: fix use of uninitialized array Thread-Index: AQHV2++ExoBJbRj7iE212ierA8jgJagMM5QQ Date: Wed, 5 Feb 2020 07:28:18 +0000 Message-ID: References: In-Reply-To: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: spf=none (sender IP is ) smtp.mailfrom=viacheslavo@mellanox.com; x-originating-ip: [77.75.144.194] x-ms-publictraffictype: Email x-ms-office365-filtering-ht: Tenant x-ms-office365-filtering-correlation-id: 42eaa6e0-34b5-4246-2b0d-08d7aa0cf8dc x-ms-traffictypediagnostic: AM4PR05MB3473:|AM4PR05MB3473: x-ld-processed: a652971c-7d2e-4d9b-a6a4-d149256f461b,ExtFwd x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:6430; x-forefront-prvs: 0304E36CA3 x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(4636009)(376002)(396003)(136003)(346002)(366004)(39860400002)(189003)(199004)(86362001)(26005)(8676002)(81166006)(186003)(4326008)(81156014)(71200400001)(6506007)(2906002)(53546011)(8936002)(7696005)(76116006)(52536014)(478600001)(110136005)(107886003)(55016002)(316002)(54906003)(6636002)(66556008)(66446008)(66476007)(5660300002)(66946007)(33656002)(64756008)(9686003); DIR:OUT; SFP:1101; SCL:1; SRVR:AM4PR05MB3473; H:AM4PR05MB3265.eurprd05.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; MX:1; A:1; received-spf: None (protection.outlook.com: mellanox.com does not designate permitted sender hosts) x-ms-exchange-senderadcheck: 1 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: vWhqbVIJ72aFoLJtY+a4B5kZCoKHqpbVIKC8gS3s+HdpBILm5N8eS9niaPE4+e1mIxwmRU8nklHrvVibq/12GW+8ynBgia4MVvIK3G2+D5pjiEzqLPOiWCDXqEU+G51PlZ/L1AFgYFcTA6tRs27l/0PYe+jUYUey91lnfwJnCowUzUpEEZJnI6Y91xAKmh8qHCX+XgIoiokTgDKc7/OfYyrsj6GwZdZvvgEqXmXP+RBesaHQnGx/QBX6ic5CPCcHeY4xkU5pzaGjWCeZzrmEw7qV8LaBi/1H08TxkMTOoL3dQfQ3OusjjdrrWfqrl3/OZ5G3akyhIGAhfmUg/oLf5Zy0TC+8/BA0m6bo/S/9P5jlxtA513YNsW2zEXwFay8IP9XBtetU/6A/QwtI18x9kzkgHjHaN/c1kctKoLzYn0eun+cwbbyElwkgVRknHP5P x-ms-exchange-antispam-messagedata: 50stXdc3gXvaZMVoCT94F7oKgORFDkqL7RynSOXsWeYQwNzxt1YGoccObjPCoT4QrpCpUsqb8vkYl7kgIXEc/zu+QOQFp5jaYHfMisGnWQ24mtIBAB4QO0ruQXgYKfyK+Qrjzep76JtvVChOZeUgMw== Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: Mellanox.com X-MS-Exchange-CrossTenant-Network-Message-Id: 42eaa6e0-34b5-4246-2b0d-08d7aa0cf8dc X-MS-Exchange-CrossTenant-originalarrivaltime: 05 Feb 2020 07:28:18.6443 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: a652971c-7d2e-4d9b-a6a4-d149256f461b X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: lDfK6KjKesvMOhncbTTkNwoIS9zoy77TnRr6wMLAhw4FHF7wv48iDEixA5QOubEpezYX4whbYIk0oKbURsvBWU6+E72aPWkClRkeTEhhZmA= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM4PR05MB3473 Subject: Re: [dpdk-dev] [PATCH] net/mlx5: fix use of uninitialized array X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Very nice, Dekel, we found the root cause of the failure. Acked-by: Viacheslav Ovsiienko > -----Original Message----- > From: Dekel Peled > Sent: Wednesday, February 5, 2020 8:42 > To: Matan Azrad ; Slava Ovsiienko > ; Raslan Darawsheh > Cc: dev@dpdk.org; Bing Zhao > Subject: [PATCH] net/mlx5: fix use of uninitialized array >=20 > Previous patch changed the format of struct > mlx5_flow_dv_modify_hdr_resource, to use a flexible array for modificatio= n > actions. > In __flow_dv_translate() a union was defined with item of this struct, an= d an > array of maximal possible size. > Aray elements are filled in several functions. > In function flow_dv_convert_action_set_reg(), array element is filled par= tially, > while the other fields of this array element are left uninitialized. > This may cause failure of flow_dv_modify_hdr_resource_register() > when calling driver function with the 'dirty' array. >=20 > This patch updates flow_dv_convert_action_set_reg(), setting the selected > array element fields while clearing the other fields. > Other functions that fill the same array elements are also updated for cl= arity > and proofing future use. >=20 > Fixes: 024e957 ("net/mlx5: fix modify actions support limitation")=09 > Cc: bingz@mellanox.com >=20 > Signed-off-by: Dekel Peled > Acked-by: Matan Azrad > --- > drivers/net/mlx5/mlx5_flow_dv.c | 26 ++++++++++++++++---------- > 1 file changed, 16 insertions(+), 10 deletions(-) >=20 > diff --git a/drivers/net/mlx5/mlx5_flow_dv.c > b/drivers/net/mlx5/mlx5_flow_dv.c index 2878393..3daabd3 100644 > --- a/drivers/net/mlx5/mlx5_flow_dv.c > +++ b/drivers/net/mlx5/mlx5_flow_dv.c > @@ -385,10 +385,12 @@ struct field_modify_info modify_tcp[] =3D { > off_b - __builtin_clz(mask); > MLX5_ASSERT(size_b); > size_b =3D size_b =3D=3D sizeof(uint32_t) * CHAR_BIT ? 0 : size_b; > - actions[i].action_type =3D type; > - actions[i].field =3D field->id; > - actions[i].offset =3D off_b; > - actions[i].length =3D size_b; > + actions[i] =3D (struct mlx5_modification_cmd) { > + .action_type =3D type, > + .field =3D field->id, > + .offset =3D off_b, > + .length =3D size_b, > + }; > /* Convert entire record to expected big-endian format. */ > actions[i].data0 =3D rte_cpu_to_be_32(actions[i].data0); > if (type =3D=3D MLX5_MODIFICATION_TYPE_COPY) { @@ -578,10 > +580,12 @@ struct field_modify_info modify_tcp[] =3D { > return rte_flow_error_set(error, EINVAL, > RTE_FLOW_ERROR_TYPE_ACTION, NULL, > "too many items to modify"); > - actions[i].action_type =3D MLX5_MODIFICATION_TYPE_SET; > - actions[i].field =3D field->id; > - actions[i].length =3D field->size; > - actions[i].offset =3D field->offset; > + actions[i] =3D (struct mlx5_modification_cmd) { > + .action_type =3D MLX5_MODIFICATION_TYPE_SET, > + .field =3D field->id, > + .length =3D field->size, > + .offset =3D field->offset, > + }; > actions[i].data0 =3D rte_cpu_to_be_32(actions[i].data0); > actions[i].data1 =3D conf->vlan_vid; > actions[i].data1 =3D actions[i].data1 << 16; @@ -913,8 +917,10 @@ > struct field_modify_info modify_tcp[] =3D { > "too many items to modify"); > MLX5_ASSERT(conf->id !=3D REG_NONE); > MLX5_ASSERT(conf->id < RTE_DIM(reg_to_field)); > - actions[i].action_type =3D MLX5_MODIFICATION_TYPE_SET; > - actions[i].field =3D reg_to_field[conf->id]; > + actions[i] =3D (struct mlx5_modification_cmd) { > + .action_type =3D MLX5_MODIFICATION_TYPE_SET, > + .field =3D reg_to_field[conf->id], > + }; > actions[i].data0 =3D rte_cpu_to_be_32(actions[i].data0); > actions[i].data1 =3D rte_cpu_to_be_32(conf->data); > ++i; > -- > 1.8.3.1