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 5743CA0093; Sun, 17 May 2020 14:39:34 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 8A4621D595; Sun, 17 May 2020 14:39:33 +0200 (CEST) Received: from EUR04-VI1-obe.outbound.protection.outlook.com (mail-eopbgr80087.outbound.protection.outlook.com [40.107.8.87]) by dpdk.org (Postfix) with ESMTP id 12B661D567; Sun, 17 May 2020 14:39:32 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=i4bRqgA3Vo60N9XBuzTSkG382Mmeyca/oSBUFxY7z1k7LHnLjhhlmFNfre4Wa3ByLQwQTwFKgX+INexWQMHGe0EDsPP6Drcka/2HePAaF6H4tYUwpxpYamDzXq+kvWEuTN8s0lYDpx1URSZ+17eQ6+9/LqrEZtx/7lMeA+ABbb2KweTq9qrfcR/ZS2Akye7J+9Lyhr+OcdYmb43NReWM2tKYyya2GuipDbj+Tq5KacZmtdYZKLuoEN503PC/GIhQ6rBi71KS61Iq3Ih6Lcuel3+s3vrMgfxKP5QT3TWDGvX5aGj+EfqCfbmkznKx9EMW3cZJxZrwIem7c0ZLrZn6Zg== 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=98j7i1tR6kHFEnIWYuhKrQB3GIqdkS//P9VWR9zKlUc=; b=YXT6lTAkfTA0wHo1igqb5L2IgaklNY1U3CQV1oSxPYuuncMmfXx+ShajH41PcSaxCqvdmKSqmqSL1/w51HEHSKYXPDD1UrZvtUAJX6mpoGhmIeVLXkMCMXspe342h9xqU7K+te+u+dmHFdd+GUngkUSUeN9K813dTy69426dxUnvfAy4n2XTfp8OuB88MXf1eML7er3slOI7qyyVm4y+5pQntqGz/JLPMOFJR9arig/xm59Q9gU8JKUvr+FeNT4QJbrot3dm6mC3yPwIMbKuzA6BPvJpCk2dKw1lG3Gf4ykhKCBuM8FKLMMOeCS4VrWbwHZ8vOGCrWYf+b6OsGRgkQ== 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=98j7i1tR6kHFEnIWYuhKrQB3GIqdkS//P9VWR9zKlUc=; b=IZ+P7QxgtICmAoxjqNPgefzoL+FGCpyXscuv3JfRumBjG05nt0kxzzZwJ9ZevjScRUnxP0q1vJCf7+M/LKm5wCbU8kWtzBZ2cW3lGESeVDCO6yL+A/jDmDrzoOhCCIOve9rKwm7b8IDUXhHBORNlevtwvh1EFlODCrKiruSOBE8= Received: from AM0PR05MB6707.eurprd05.prod.outlook.com (10.186.174.145) by AM0PR05MB6241.eurprd05.prod.outlook.com (20.178.203.89) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3000.25; Sun, 17 May 2020 12:39:31 +0000 Received: from AM0PR05MB6707.eurprd05.prod.outlook.com ([fe80::508:747b:cc12:5f6e]) by AM0PR05MB6707.eurprd05.prod.outlook.com ([fe80::508:747b:cc12:5f6e%6]) with mapi id 15.20.3000.022; Sun, 17 May 2020 12:39:30 +0000 From: Raslan Darawsheh To: Slava Ovsiienko , "dev@dpdk.org" CC: Matan Azrad , "stephen@networkplumber.org" , Alexander Kozyrev , "stable@dpdk.org" Thread-Topic: [PATCH v2] common/mlx5: fix bogus assert Thread-Index: AQHWKb6tg7WQHggHsk6g8o605oXdlKisPMlg Date: Sun, 17 May 2020 12:39:30 +0000 Message-ID: References: <20200331060247.10954-1-stephen@networkplumber.org> <1589440142-7197-1-git-send-email-viacheslavo@mellanox.com> In-Reply-To: <1589440142-7197-1-git-send-email-viacheslavo@mellanox.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: mellanox.com; dkim=none (message not signed) header.d=none;mellanox.com; dmarc=none action=none header.from=mellanox.com; x-originating-ip: [188.161.229.217] x-ms-publictraffictype: Email x-ms-office365-filtering-ht: Tenant x-ms-office365-filtering-correlation-id: dc455341-c98a-44af-0d64-08d7fa5f587e x-ms-traffictypediagnostic: AM0PR05MB6241: x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:5516; x-forefront-prvs: 040655413E x-ms-exchange-senderadcheck: 1 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: iWu+D59c3AWK+4PBK+uRqD7lUDIXr0392lRDxAt/xUYkxSFhiVe0c1wZ9/dMCt3M4IE+ZELZx0zjO29iLUPc9ykHDqdNN933hU8ETuFnp2IU6jddmQWCWwVQwSe5PuuY44r3wYizKPb8ma7DV6Xnd4vFLoQHtE9TCZkDbTkMUJymZMFV81bfd/chGFMycuXaGceY6jghxSo/+Calk79hreXkiTZY0B6ISm5iH+wbwqdRvZ6HILcU/oq8EWC2XPNDhwmpSkYECj1KNmywWHLqAB6mZqST7gFQXiIYy7tCTBQ8RCsz7mmisRWFust+EmGM8QrImJK7QXZkBDxSUfazwfVNn+bQFleMHseJDcNSuMwtCzQ4AtmRHLMO3hf/Me/K6oeWv5oDGiGHdNSkSHdD8V+10ZA97RVaSAo5fov7YO34jRISZL1HyAZh/emtNCHHo9Kz0jZqLb8U39jGmMze/wzLqTE5hgCfRWFXvog3e6SiFTw9DltRACpDkGY+omsOG54Nxh5zNJMpdLAUSwt1SQ== x-forefront-antispam-report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM0PR05MB6707.eurprd05.prod.outlook.com; PTR:; CAT:NONE; SFTY:; SFS:(4636009)(396003)(346002)(136003)(366004)(376002)(39860400002)(66946007)(64756008)(110136005)(7696005)(54906003)(83080400001)(66556008)(66446008)(478600001)(33656002)(86362001)(5660300002)(52536014)(966005)(55016002)(9686003)(76116006)(53546011)(6506007)(45080400002)(4326008)(316002)(71200400001)(8936002)(8676002)(2906002)(66476007)(26005)(186003); DIR:OUT; SFP:1101; x-ms-exchange-antispam-messagedata: osg3KyWroFwA7Ht4C3m1OR61a6mcyH3tfpDjNls1YzwI1DJZako8WiH7INo9mEMqRLzLtQWOyxdaHLU05xOuc4QsuNGdlbP4YMicNAGwfV7LgubRTL5/CmB4gIByelgn+GKvgLJXJDgML8NIX1w072KphWK9cyV02MWg+NqtMN4Um7TYPgLT+7bFVPNOvxk1B+gbKO3hdfQm16O2ZBc4SXoG3iC1jZyXr5uoeq8kAaxcHvknllLI4Va04MczxMeZIb6NlnfuNxxV//ruVtvc+1SeXakWJbI07bO2JohlxG3em1jH8h0dvN1Hw/DVSaUwY8tpGh3Y18nTO8D9wOy/ejkAC58uWHoGva6ZEK6XnhLaAZYbXIztg4Q35gJ422xxDxlr3FivrALdTfInurlYtK5yEvTiuEcsjHdVA+WhqPEOGBLKAahQOTyXAiot7gyKecL19EXRujMnq5NFMfCRVNF92zpqH9/pHVBn9UBWILhvSk+k3rT2qrK5f4cjmOfs 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: dc455341-c98a-44af-0d64-08d7fa5f587e X-MS-Exchange-CrossTenant-originalarrivaltime: 17 May 2020 12:39:30.8911 (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: HqaOCfiHkN3bFk7q2r7IZTr5iNtLCue7ZGHuIHWGyo4qIkKu5HZ2vx1YUdV654g7UYp6XvqnbYmffe9WLWOWVQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR05MB6241 Subject: Re: [dpdk-dev] [PATCH v2] common/mlx5: fix bogus assert 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" Hi, > -----Original Message----- > From: Viacheslav Ovsiienko > Sent: Thursday, May 14, 2020 10:09 AM > To: dev@dpdk.org > Cc: Matan Azrad ; Raslan Darawsheh > ; stephen@networkplumber.org; Alexander > Kozyrev ; stable@dpdk.org > Subject: [PATCH v2] common/mlx5: fix bogus assert >=20 > The MLX5 device supports up to MLX5_MAX_MAC_ADDRESSES (256) MAC > addresses. > The code flushes all MAC devices. >=20 > If DPDK is compiled with MLX5_DEBUG this would an assert. > PANIC in mlx5_nl_mac_addr_flush(): > line 775 assert "(size_t)(i) < sizeof(mac_own) * 8" failed >=20 > The root cause is that mac_own is a pointer and is being used as > a bitmap array. The sizeof(mac_own) would therefore be 64 but the > number of entries to be flushed would be 256. >=20 > There is a whole set of asserts in MLX5 netlink code with > the same bug; that should just be changed into proper error checks. >=20 > Fixes: 8e46d4e18f09 ("common/mlx5: improve assert control") > Cc: akozyrev@mellanox.com > Cc: stable@dpdk.org >=20 > Signed-off-by: Stephen Hemminger > Signed-off-by: Viacheslav Ovsiienko >=20 > --- > v2: fix asserts > v1: > https://eur03.safelinks.protection.outlook.com/?url=3Dhttp%3A%2F%2Fpatch > es.dpdk.org%2Fpatch%2F67453%2F&data=3D02%7C01%7Crasland%40mell > anox.com%7C71b3b1e727b8493f98fe08d7f7d5ce48%7Ca652971c7d2e4d9ba6 > a4d149256f461b%7C0%7C0%7C637250369975781842&sdata=3DRI5eahOH > MTb7khPqPkYe0AD3bRB6vPtuRh9INSJa8N0%3D&reserved=3D0 > --- > drivers/common/mlx5/mlx5_nl.c | 14 +++++++++++--- > 1 file changed, 11 insertions(+), 3 deletions(-) >=20 > diff --git a/drivers/common/mlx5/mlx5_nl.c > b/drivers/common/mlx5/mlx5_nl.c > index c144223..65efcd3 100644 > --- a/drivers/common/mlx5/mlx5_nl.c > +++ b/drivers/common/mlx5/mlx5_nl.c > @@ -671,7 +671,10 @@ struct mlx5_nl_ifindex_data { >=20 > ret =3D mlx5_nl_mac_addr_modify(nlsk_fd, iface_idx, mac, 1); > if (!ret) { > - MLX5_ASSERT((size_t)(index) < sizeof(mac_own) * > CHAR_BIT); > + MLX5_ASSERT(index < MLX5_MAX_MAC_ADDRESSES); > + if (index >=3D MLX5_MAX_MAC_ADDRESSES) > + return -EINVAL; > + > BITFIELD_SET(mac_own, index); > } > if (ret =3D=3D -EEXIST) > @@ -700,7 +703,10 @@ struct mlx5_nl_ifindex_data { > mlx5_nl_mac_addr_remove(int nlsk_fd, unsigned int iface_idx, uint64_t > *mac_own, > struct rte_ether_addr *mac, uint32_t index) > { > - MLX5_ASSERT((size_t)(index) < sizeof(mac_own) * CHAR_BIT); > + MLX5_ASSERT(index < MLX5_MAX_MAC_ADDRESSES); > + if (index >=3D MLX5_MAX_MAC_ADDRESSES) > + return -EINVAL; > + > BITFIELD_RESET(mac_own, index); > return mlx5_nl_mac_addr_modify(nlsk_fd, iface_idx, mac, 0); > } > @@ -769,10 +775,12 @@ struct mlx5_nl_ifindex_data { > { > int i; >=20 > + if (n <=3D 0 || n >=3D MLX5_MAX_MAC_ADDRESSES) > + return; > + > for (i =3D n - 1; i >=3D 0; --i) { > struct rte_ether_addr *m =3D &mac_addrs[i]; >=20 > - MLX5_ASSERT((size_t)(i) < sizeof(mac_own) * CHAR_BIT); > if (BITFIELD_ISSET(mac_own, i)) > mlx5_nl_mac_addr_remove(nlsk_fd, iface_idx, > mac_own, m, > i); > -- > 1.8.3.1 Patch applied to next-net-mlx, Kindest regards Raslan Darawsheh