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 84894A00E6 for ; Tue, 6 Aug 2019 10:19:05 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 602351BD62; Tue, 6 Aug 2019 10:19:05 +0200 (CEST) Received: from EUR02-AM5-obe.outbound.protection.outlook.com (mail-eopbgr00076.outbound.protection.outlook.com [40.107.0.76]) by dpdk.org (Postfix) with ESMTP id DF0F51BACA for ; Tue, 6 Aug 2019 10:19:03 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=GAjzmNruy6VSihfA+0ZY9/tQsbdc7u3UthyjTn4XBJXUXJTZPW7JfAeMnBDS3ZedHjxsIzdsOmMQw6T/AiTZcE52F04L6YGeuyVYqoPwuDbxnNa+OoVMLfoxxFRNmeC1ql8wNAtE8xPLDoYIt/CEnXsxq/xPG6eidobkiRkC5Ysy/jSphXE6od4zK1mP6pUbNRqiPfWIHemt6tA0c65Rlg81QopIzjVoVeHMtkGwHxx/8P6ZtO+xVe9GOz5+KtJYtE+C8IyL/KNKsXBnUv42hW/Zyepe2YZctYwYBzGG6qOsjhkukJT3FuWTr4VBMWjBFR8mT/PNAv3upbSy8ZAbvw== 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=aeXfzduBx9xc0FkwG8NXfcl6W/aP8HbJA+FmV3yOOZU=; b=c3/GilJmCPYxJpCwG9sP5Nv1AsihOU7N2RbX0PQoMcrIToITziBXRMuQR+e/rIagUTPl8+18HwNaGrAR1LVaJKCChqizp4goVR6Js2Lw72mupk7srMESM7WDdEykuMzLag4tHAkmblLNiYBbTpBOlwlwW6YTEY6GMZK2H+vZ1qfngiA5EXWCfaf0GoXR+EpSinbj5IkZWNq8ksRbDPRVOzzmC0WX1dIGAlaNn2VV2ZltfG65UJ5ufrlu7Ze2SfaVEO92zFZMVFveLAgdFJT24SAwB1BxUMR8Sa5tHuPjcDh7EgVO6/6N98dHv/xVLM4JAmQYsMF5eywFSKzVipbgCA== 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=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=aeXfzduBx9xc0FkwG8NXfcl6W/aP8HbJA+FmV3yOOZU=; b=T+cXlG5QyLomUkEKUU4IrZ6qpQEY8MpyXn7SbhoyyWN/HTd9t6gVSEssNiR9KNNYRqAG1eNiDJYpn1zLJg5Kx0zUGxlB1eJcIOqY3cRTa71Megu+z8Jq2PwU15YvLvPhPwu6ubuKHa3exlEaI96PcXHHLxVFhw8FDZTD7dKqRks= Received: from AM0PR0502MB4019.eurprd05.prod.outlook.com (52.133.39.139) by AM0PR0502MB3858.eurprd05.prod.outlook.com (52.133.48.12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2136.12; Tue, 6 Aug 2019 08:19:02 +0000 Received: from AM0PR0502MB4019.eurprd05.prod.outlook.com ([fe80::ccc2:2dd4:ca86:7639]) by AM0PR0502MB4019.eurprd05.prod.outlook.com ([fe80::ccc2:2dd4:ca86:7639%3]) with mapi id 15.20.2136.010; Tue, 6 Aug 2019 08:19:02 +0000 From: Matan Azrad To: Stephen Hemminger CC: "dev@dpdk.org" , Stephen Hemminger Thread-Topic: [dpdk-dev] [PATCH v5 1/4] examples/multi_process/client_server_mp: check port validity Thread-Index: AQHVSUphxp1Q426sqUeRhaSMjaIUiKbqqieggAIRMACAAQvgMA== Date: Tue, 6 Aug 2019 08:19:01 +0000 Message-ID: References: <20190726165054.24078-1-stephen@networkplumber.org> <20190802025826.1174-1-stephen@networkplumber.org> <20190802025826.1174-2-stephen@networkplumber.org> <20190802085301.02ab5b55@hermes.lan> <20190805090054.1511b033@hermes.lan> In-Reply-To: <20190805090054.1511b033@hermes.lan> Accept-Language: en-US, he-IL Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: spf=none (sender IP is ) smtp.mailfrom=matan@mellanox.com; x-originating-ip: [193.47.165.251] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: e99384e4-7c28-4476-455d-08d71a46bd34 x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: BCL:0; PCL:0; RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600148)(711020)(4605104)(1401327)(4618075)(2017052603328)(7193020); SRVR:AM0PR0502MB3858; x-ms-traffictypediagnostic: AM0PR0502MB3858: x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:10000; x-forefront-prvs: 0121F24F22 x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(979002)(4636009)(346002)(396003)(39860400002)(136003)(366004)(376002)(189003)(199004)(54906003)(6506007)(102836004)(99286004)(4326008)(81166006)(7696005)(7736002)(26005)(186003)(53936002)(8676002)(6116002)(3846002)(68736007)(476003)(2906002)(76176011)(6246003)(305945005)(66066001)(81156014)(256004)(446003)(316002)(86362001)(11346002)(9686003)(25786009)(14444005)(5660300002)(55016002)(66446008)(66476007)(52536014)(229853002)(486006)(66556008)(6916009)(71200400001)(478600001)(14454004)(8936002)(74316002)(64756008)(66946007)(71190400001)(76116006)(33656002)(6436002)(969003)(989001)(999001)(1009001)(1019001); DIR:OUT; SFP:1101; SCL:1; SRVR:AM0PR0502MB3858; H:AM0PR0502MB4019.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-message-info: 0F5kcC96RapE632k0LScmxvhzP5ZCjgE1yPQksVf/N0JXElZcJsqq2UunwtAtROElfomzdVvabbUzkBt4zWD5qQeudxgo8h5XsGb5Mb3jMVOSJDfZtMQzgWFVBlCfGZMFW++mJ0BYbVmZ10uub3UKG4XkYF9E7weLAWlo/fG1NXh3+QA+5U1LDebTXjEJyf/jJyxPhL/7m+30CzfqWzt2G0qWpmYsbZcO1euIx6RTcctZWVU3KQa1vN1mqyV4cVx3sJU2C1mVpgfeMD6JBOyoqmVu993jAz8+nxX1tGX+GAx42ALTgTvFZL5sOoj+MGEVkgj5nCO2wcBnRdkzoOIzcOE8Wbn1oc2abbxXOvPUrOHQ24jzhBzm1u/i9DLQbstyxgQ3PbY0ULzEiifUjQ+MUYfAdvHZtTWNeU+Lq4ACtM= 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: e99384e4-7c28-4476-455d-08d71a46bd34 X-MS-Exchange-CrossTenant-originalarrivaltime: 06 Aug 2019 08:19:01.9167 (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: matan@mellanox.com X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR0502MB3858 Subject: Re: [dpdk-dev] [PATCH v5 1/4] examples/multi_process/client_server_mp: check port validity 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" From: Stephen Hemminger > On Sun, 4 Aug 2019 08:31:54 +0000 > Matan Azrad wrote: >=20 > > > > > /* convert parameter to a number and verify */ > > > > > pm =3D strtoul(portmask, &end, 16); > > > > > - if (end =3D=3D NULL || *end !=3D '\0' || pm =3D=3D 0) > > > > > + if (end =3D=3D NULL || *end !=3D '\0' || pm > UINT16_MAX || pm > =3D=3D 0) > > > > > > > > Why pm > UINT16_MAX ? should be something like > (1 << > > > RTE_MAX_ETHPORTS) - 1. > > > > And need to be sure pm type can hold RTE_MAX_ETHPORTS bits, > > > otherwise port 0 may unlikely be all the time visible in the loop bel= ow. > > > > > > > > > > The DPDK assumes a lot of places that unsigned long will hold a port > mask. > > > > So, all are bugs, no? >=20 > I don't think 32 bit build is that well tested. But yes a mask needs to h= old 64 > ports. What if someone changes RTE_MAX_ETHPORTS to be bigger than 64 in config fil= e? Assume the user changes RTE_MAX_ETHPORTS to 128, and there is a valid port = in range [64, 127]. Then, assume the failsafe sub device owns port ID 0. Because the mask bits are not enough to handle the above range, you will ge= t port 0 as valid port - bug. I think you need one more check to the RTE_MAX_ETHPORTS > 64 case.=20 > > > If some extra bits are set, the error is visible later when the bits > > > are leftover after finding ports. > > > > Yes, but if there is a valid port which its port id is bigger than the = portmask > bits number - port 0 will be all the time visible in the check -> bug. > > > > > The original code had worse problems, it would not catch invalid pm > > > values at all and truncate silently. > > > > Yes, maybe, but I really don't understand why you chose to limit for 16 > ports, where this number come from? > > So, my approach here, 2 options: >=20 > The problem here was my mistake for not having wide enough portmask.