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 7F1C2A0613 for ; Sun, 4 Aug 2019 10:32:01 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 2B0161BED8; Sun, 4 Aug 2019 10:32:00 +0200 (CEST) Received: from EUR03-VE1-obe.outbound.protection.outlook.com (mail-eopbgr50079.outbound.protection.outlook.com [40.107.5.79]) by dpdk.org (Postfix) with ESMTP id 239A41BED7 for ; Sun, 4 Aug 2019 10:31:58 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=IxtM0hfMnCJRmfwTaPde7RxVz0lGwLWq6cG8ZbnuzHREEicdhoAvjW8Awxr2aW3+cv3GQPQuW53G8FRhXSheZQjIgWSb9Wsx+XGQEP8UXlr5UqDL30pi6ADco3T8DR0CQ7WWFk3c2HxUvpe69OcT/mRuJ5tsuVWsoD5IlRW6S77JZLKWD+NLPOTK+WA3zkqZLVCJTD13MDPrkazB8gBkpQAZ0SRg3shVfcfE1sFNoFLzNSKddCXgCbZ5TWpvFckGrJoKieTKEg9aH/d6n4hFYAzdDT43rUS/4rt5LHEgOSD+wmYRCHZ1gvliBht4jNtJFCcEgiZsAYNZTcJE6sy6pQ== 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=MNWgjYFiYUuSi2lJ3CKxK4BARfOuQpnczwD97jtORnA=; b=SKSUYcPVlOZ9UHz3y0bEaSpCJkFGD3HcYgPtjLnyVAh9maLVODDJK6xgiOZ+/ovGFWFLcVssAsr1OoqCkssDpXPWxm7QOYocqJCvTIZ1gEv7VIKk0X644Z5+aFOzG+spohi8G8wL2VhSGJa9QB5n+niGAVe+CDh8nzuNg1U0OmmMhDHko3xsY3lPg8Tc/STcNA5aiP2LW5AIxi5lGc3cf04IHuf08SlhVYLckyS9gu+uEaX/Hu6FM/nYMnhJeIPW0cF3uiVH2BIUIiB23C1QhmBD0VSuCk5lIUl0JYdG1q7lTn2A1GIM180k+GRBSH82hUZTmA90KOm4qF5L5b0UBw== 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=MNWgjYFiYUuSi2lJ3CKxK4BARfOuQpnczwD97jtORnA=; b=tAmZPnpGGCypkqUBmD6lCySWS7gHseIfNokadgkob/FyswlI01kQ3vqIy6/Gntsbh8LJvR7NSc1dnwZAZXIQuD3ii7MErRAXAUzhzyS5AVuHkQvqxuSkXLfvqbdeWefAO3xdyR1p1wDYcU0NsUPznhwqWMSxRO6aKeFKV+SoJQg= Received: from AM0PR0502MB4019.eurprd05.prod.outlook.com (52.133.39.139) by AM0PR0502MB3924.eurprd05.prod.outlook.com (52.133.48.30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2136.16; Sun, 4 Aug 2019 08:31:54 +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; Sun, 4 Aug 2019 08:31:54 +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: AQHVSUphxp1Q426sqUeRhaSMjaIUiKbqqieg Date: Sun, 4 Aug 2019 08:31:54 +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> In-Reply-To: <20190802085301.02ab5b55@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: d1efa39c-7b7e-4710-eb03-08d718b634a2 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:AM0PR0502MB3924; x-ms-traffictypediagnostic: AM0PR0502MB3924: x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:8882; x-forefront-prvs: 0119DC3B5E x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(4636009)(136003)(39830400003)(366004)(396003)(376002)(346002)(189003)(199004)(53546011)(7736002)(74316002)(305945005)(486006)(9686003)(446003)(11346002)(476003)(99286004)(52536014)(66066001)(26005)(4326008)(186003)(25786009)(33656002)(55016002)(54906003)(68736007)(86362001)(6916009)(478600001)(5660300002)(71190400001)(66946007)(66476007)(66556008)(66446008)(76116006)(64756008)(8936002)(14454004)(316002)(229853002)(8676002)(71200400001)(6116002)(3846002)(2906002)(256004)(14444005)(81156014)(81166006)(6436002)(53936002)(76176011)(7696005)(102836004)(6246003)(6506007); DIR:OUT; SFP:1101; SCL:1; SRVR:AM0PR0502MB3924; 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: cQT/WE6XTB1Pf1fa++C7q2x+rxbHim7C0aCwquKSEofzmaUwtj89rBNtd4SxeNlz3UVdmoi9AQjKLkBjkRn3hFMtZpj8asM4sWa5fEofh1yhDHcO3zByxzXJp+Gfgx+x3uLkN6BlFn6GYEueETaDrOSpr6JR71GP6G09yqz/KFa9dKh7oidPKpq2m4pI6VHYYQg18aLv6ta7SzXbKJklL9AUh1z6LAWHV9ysKNBkJLRxkZBgOYQLriUsXaC9fYHlLRJqq9xruQlJJy8+iJxqcIx8vicugR1GUV8rM/7o/OUg5lZnEhS4GsViEvlaI9pTB45uObAojiSKus5/BuImN/4XT8rV8VInrJMhxL9flZtFK24vtVdJMDHKaCtW3TftUIYWcsx4wjvZDAuaZdkFeBTGoKzBs010YWHzpvNBGVA= 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: d1efa39c-7b7e-4710-eb03-08d718b634a2 X-MS-Exchange-CrossTenant-originalarrivaltime: 04 Aug 2019 08:31:54.1032 (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: AM0PR0502MB3924 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" Hi Stephen From: Stephen Hemminger > On Fri, 2 Aug 2019 05:33:20 +0000 > Matan Azrad wrote: >=20 > > Hi Stephen > > > > One more small comment inline > > > > From: Stephen Hemminger > > > Sent: Friday, August 2, 2019 5:58 AM > > > To: dev@dpdk.org > > > Cc: Stephen Hemminger > > > Subject: [dpdk-dev] [PATCH v5 1/4] > > > examples/multi_process/client_server_mp: check port validity > > > > > > From: Stephen Hemminger > > > > > > The mp_server incorrectly allows a port mask that included hidden > > > ports and which later caused either lost packets or failed initializa= tion. > > > > > > This fixes explicitly checking that each bit in portmask is a valid > > > port before using it. > > > > > > Fixes: 5b7ba31148a8 ("ethdev: add port ownership") > > > Signed-off-by: Stephen Hemminger > > > --- > > > .../client_server_mp/mp_server/args.c | 35 ++++++++++-------= -- > > > .../client_server_mp/mp_server/args.h | 2 +- > > > .../client_server_mp/mp_server/init.c | 7 ++-- > > > 3 files changed, 22 insertions(+), 22 deletions(-) > > > > > > diff --git > > > a/examples/multi_process/client_server_mp/mp_server/args.c > > > b/examples/multi_process/client_server_mp/mp_server/args.c > > > index b0d8d7665c85..fdc008b3d677 100644 > > > --- a/examples/multi_process/client_server_mp/mp_server/args.c > > > +++ b/examples/multi_process/client_server_mp/mp_server/args.c > > > @@ -10,6 +10,7 @@ > > > #include > > > > > > #include > > > +#include > > > #include > > > > > > #include "common.h" > > > @@ -41,31 +42,33 @@ usage(void) > > > * array variable > > > */ > > > static int > > > -parse_portmask(uint8_t max_ports, const char *portmask) > > > +parse_portmask(const char *portmask) > > > { > > > char *end =3D NULL; > > > unsigned long pm; > > > - uint16_t count =3D 0; > > > + uint16_t id; > > > > > > if (portmask =3D=3D NULL || *portmask =3D=3D '\0') > > > return -1; > > > > > > /* 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 below. > > >=20 > The DPDK assumes a lot of places that unsigned long will hold a port mask= . So, all are bugs, no? > 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 port= mask 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 value= s at > all and truncate silently. Yes, maybe, but I really don't understand why you chose to limit for 16 por= ts, where this number come from? So, my approach here, 2 options: 1. Remove this line change at all. 2. Do the portmask check bug-free. Matan =20