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 F13ABA0573; Thu, 5 Mar 2020 10:17:32 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 5B42E1BFCD; Thu, 5 Mar 2020 10:17:32 +0100 (CET) Received: from EUR02-AM5-obe.outbound.protection.outlook.com (mail-eopbgr00096.outbound.protection.outlook.com [40.107.0.96]) by dpdk.org (Postfix) with ESMTP id 5882D1BFDD for ; Tue, 3 Mar 2020 19:13:25 +0100 (CET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Ijcwbdr685yPizbIeM1VMorHKTC46F6GQrs8Po3XbZcqrT/9SGc4krHIf22P2aYdlXWQfYLShZT0TuT731lEDXbo/9R7tthJxeemX4+MZnmqV0u908bkRD1bSGhWVLCvhoPfBnHpaPEWUUdo1kurFOTMt5J+JFKgBOvDSSbcoI0v0iMhtVVscjsJ7ZTr2RAofIdOLPbW9IyWEqL61+s7raAZSTPy0HEg3TC3m6cZfO7vfmNkAUw6xJnthmnVTZrglI56MtHB7e9uza8SlHZE0dGUpeG3U/4Rxa//DlSt84APezRNBtsjZbmth8oQ71Qkx1SksgOVRFxs+/545GFnIQ== 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=cp7dhs3OmprYdY/wtBJwQPJnsfTBlABwdOnj+TVQA44=; b=R0oZzy49NkEgSrKXX6xHv8cMkDkF6sthhT3plPxwPZ+8ZekrMiqoR7pOwiB5H9YwidPafqDqKXywk1E048RK8rda4C4go1YpRz4kc7yr+Gnz0+3n1ekxZ7AbqSbCuH2BXRG3t93EYDany4og+PHNrgVIghkqVaizWZVlWPfaIs4BbCSE3Ng/ssM/SrL7C3FueCsQ7gi6kXGjqDZSgxxd4T4LPqDwD7irnBqVT4cI1JW9MQ7I02JMUGin6Q1oX6f0OO28Juqg14ylSunWzzFiYcvNdZ3w6zi49C9BoVKtNuHAdhgzcI9sN2m1S6BhLH8kb6qECnesSue7Q0MYkbtz0w== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=microsoft.com; dmarc=pass action=none header.from=microsoft.com; dkim=pass header.d=microsoft.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=cp7dhs3OmprYdY/wtBJwQPJnsfTBlABwdOnj+TVQA44=; b=XZHz8EEAdYeXa+iWAiKwvBfaDWIXF2KEZfcBm6a9i9WawkL7AtFYxmM6n0S3O3lccoDfkGVRpLsVyBS3W9arJAYxWnra2kGq8yfFkN/JA/tqN1e0vaYFhyyADCf9diBt4fMfZLW0q5zJrcVbp8Vr7R8ffsH69QHfgjREKAfHOpE= Received: from DB6PR83MB0183.EURPRD83.prod.outlook.com (10.165.187.32) by DB6PR83MB0344.EURPRD83.prod.outlook.com (10.165.187.21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2814.1; Tue, 3 Mar 2020 18:13:22 +0000 Received: from DB6PR83MB0183.EURPRD83.prod.outlook.com ([fe80::70a6:97d:c160:f768]) by DB6PR83MB0183.EURPRD83.prod.outlook.com ([fe80::70a6:97d:c160:f768%7]) with mapi id 15.20.2772.018; Tue, 3 Mar 2020 18:13:22 +0000 From: Christopher Ertl To: Stephen Hemminger , Ajit Kumar Khaparde , "somnath.kotur@broadcom.com" CC: "dev@dpdk.org" Thread-Topic: [EXTERNAL] [PATCH 2/6] net/bnxt: fix potential data race Thread-Index: AQHV8YWIo3rq4lcu50CFe4zTg23+EKg3KvSQ Date: Tue, 3 Mar 2020 18:13:22 +0000 Message-ID: References: <20200303175938.14292-1-stephen@networkplumber.org> <20200303175938.14292-3-stephen@networkplumber.org> In-Reply-To: <20200303175938.14292-3-stephen@networkplumber.org> Accept-Language: en-GB, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: msip_labels: MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_Enabled=True; MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_SiteId=72f988bf-86f1-41af-91ab-2d7cd011db47; MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_Owner=chertl@microsoft.com; MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_SetDate=2020-03-03T18:13:20.1595591Z; MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_Name=General; MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_Application=Microsoft Azure Information Protection; MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_ActionId=d8740d6f-19a0-4368-8fda-7cd54aaf2a78; MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_Extended_MSFT_Method=Automatic authentication-results: spf=none (sender IP is ) smtp.mailfrom=Christopher.Ertl@microsoft.com; x-originating-ip: [2a01:110:8012:1010:a3e4:89a0:7aec:2267] x-ms-publictraffictype: Email x-ms-office365-filtering-ht: Tenant x-ms-office365-filtering-correlation-id: e7835708-822a-4f65-7568-08d7bf9e8f3c x-ms-traffictypediagnostic: DB6PR83MB0344:|DB6PR83MB0344: x-ld-processed: 72f988bf-86f1-41af-91ab-2d7cd011db47,ExtAddr x-microsoft-antispam-prvs: x-o365-sonar-daas-pilot: True x-ms-oob-tlc-oobclassifiers: OLM:6430; x-forefront-prvs: 03319F6FEF x-forefront-antispam-report: SFV:NSPM; SFS:(10019020)(4636009)(39860400002)(396003)(376002)(366004)(136003)(346002)(189003)(199004)(186003)(52536014)(8676002)(81156014)(5660300002)(8936002)(4326008)(110136005)(33656002)(8990500004)(2906002)(86362001)(81166006)(10290500003)(9686003)(478600001)(55016002)(76116006)(7696005)(316002)(66476007)(66946007)(6506007)(66446008)(53546011)(66556008)(71200400001)(64756008); DIR:OUT; SFP:1102; SCL:1; SRVR:DB6PR83MB0344; H:DB6PR83MB0183.EURPRD83.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; MX:1; A:1; received-spf: None (protection.outlook.com: microsoft.com does not designate permitted sender hosts) x-ms-exchange-senderadcheck: 1 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: WsIEwBGlaBg8kS+XzWYMQT9+Sznyi205AxKFT48OXRfgMli0VS34HT2ZT6E1KC7MWt3nJVC20escQ5EP2Ri4fDuAgtgxCbblB9lovdwTlSsKpVqoNIZQrTAl44E+AxqTt3bPhddjm0Bww+BWB+ZBM3X8ThScUD+XX/FQDDxwsnXbbq6eMDYNUOcetUjqSySBG8S7XdVR8+SNu0FzPFTABBGgCDs+ky4laGJNsQTcFuwJ5CSF7D7UlSnAvE5QvPUdrJC4eytsBnHMICWbXg6K8+H7Ko2I5znY3GNZilXDyfw+3ZtYZYrvgwbb38L8865ioJyYnpcqI5nqLxSKra4MFUhWkPlmbze786K6MzNlltnaxVcB9lzdgBdXostq2jSZ7ZQ5SKmIympU1LSRrSwHXdyoeNFSsOmd6JObCO7i9iNtA65aUX6d/BznKLF3jZTk x-ms-exchange-antispam-messagedata: Gf0dfQAkYgXmWQrSqKJmCE2EM695MOz37Ezihd8roMMOu0H7mT1OKKdfsZWvkgTUHgPzSt9c5Y+RTVgM0ZUz2QQn6tZBvpzIcGVQzqmqi6NOzmqKPnAHGG9/o///XidjHiDdbB6I3lGyeKY5+Yf7jGvEphIGhpuMZVMb186as9YItmWFBWvZop90ut1PZPbItwId3PvV4aPVN9iNr0RIOA== x-ms-exchange-transport-forked: True Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: microsoft.com X-MS-Exchange-CrossTenant-Network-Message-Id: e7835708-822a-4f65-7568-08d7bf9e8f3c X-MS-Exchange-CrossTenant-originalarrivaltime: 03 Mar 2020 18:13:22.2418 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 72f988bf-86f1-41af-91ab-2d7cd011db47 X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: LA/WzvSNJvrdShlfGRrkCiHdFa/06NYqO0f5lrWxJIQLIFJaLiQg4c7bFRoaA1NHtLtD5F7zYKy/lnyyPhlZ9w== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB6PR83MB0344 X-Mailman-Approved-At: Thu, 05 Mar 2020 10:17:31 +0100 Subject: Re: [dpdk-dev] [EXTERNAL] [PATCH 2/6] net/bnxt: fix potential data race 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" Can we add the `volatile` qualifier to the `hwrm_cmd_resp_addr` member (in = drivers/net/bnxt/bnxt.h) to get a stronger guarantee that the compiler won'= t insert TOCTOU races in the output? Christopher Ertl | MSRC Vulnerabilities & Mitigations | Microsoft Limited |= +44 7773976589 | Christopher.Ertl@microsoft.com =A0 Microsoft Limited (company number 01624297) is a company registered in Engl= and and Wales whose registered office is at Microsoft Campus, Thames Valley= Park, Reading. RG6 1WG -----Original Message----- From: Stephen Hemminger =20 Sent: Tuesday, March 3, 2020 6:00 PM To: Ajit Kumar Khaparde ; somnath.kotur@broadco= m.com Cc: dev@dpdk.org; Stephen Hemminger ; Christoph= er Ertl Subject: [EXTERNAL] [PATCH 2/6] net/bnxt: fix potential data race The response from the firmware is accessed multiple times. This is a potential TOCTOU error. Reported-by: Christopher Ertl Signed-off-by: Stephen Hemminger --- drivers/net/bnxt/bnxt_hwrm.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/net/bnxt/bnxt_hwrm.c b/drivers/net/bnxt/bnxt_hwrm.c in= dex a9c9c7297cab..20e2f6a36713 100644 --- a/drivers/net/bnxt/bnxt_hwrm.c +++ b/drivers/net/bnxt/bnxt_hwrm.c @@ -3746,6 +3746,7 @@ int bnxt_hwrm_port_led_qcaps(struct bnxt *bp) { struct hwrm_port_led_qcaps_output *resp =3D bp->hwrm_cmd_resp_addr; struct hwrm_port_led_qcaps_input req =3D {0}; + uint8_t num_leds; int rc; =20 if (BNXT_VF(bp)) @@ -3757,10 +3758,11 @@ int bnxt_hwrm_port_led_qcaps(struct bnxt *bp) =20 HWRM_CHECK_RESULT(); =20 - if (resp->num_leds > 0 && resp->num_leds < BNXT_MAX_LED) { + num_leds =3D resp->num_leds; + if (num_leds > 0 && num_leds < BNXT_MAX_LED) { unsigned int i; =20 - bp->num_leds =3D resp->num_leds; + bp->num_leds =3D num_leds; memcpy(bp->leds, &resp->led0_id, sizeof(bp->leds[0]) * bp->num_leds); for (i =3D 0; i < bp->num_leds; i++) { -- 2.20.1