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 B8541A04F6 for ; Wed, 11 Dec 2019 22:29:02 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 987201B994; Wed, 11 Dec 2019 22:29:02 +0100 (CET) Received: from us-smtp-delivery-1.mimecast.com (us-smtp-2.mimecast.com [205.139.110.61]) by dpdk.org (Postfix) with ESMTP id 48CBA1D9E for ; Wed, 11 Dec 2019 22:29:01 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1576099740; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=k5iDP25vp6O66fMgzbhywTdlLzo/V1cKOm5nIQWFmpE=; b=USI0oB1Fxl6Bmcbprm7njYt3FnS87QBtt8yMhPRTPM2qflLSDRuSEr2sPG3MXqmnl1KWFZ WhSrICXHcyJ48cj+whMQRh62j0z4W5DUYlhoU5tH8s0v4+Pz03LsYxkIA3x3iAqLqyoNIS D5ULh/g5vmHz+ydYRp6a/iw7JotmR2M= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-292-M7Ta02awMp6MgSTjwWajUA-1; Wed, 11 Dec 2019 16:28:57 -0500 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id A075E477; Wed, 11 Dec 2019 21:28:56 +0000 (UTC) Received: from rh.redhat.com (ovpn-116-64.ams2.redhat.com [10.36.116.64]) by smtp.corp.redhat.com (Postfix) with ESMTP id B863410013A1; Wed, 11 Dec 2019 21:28:55 +0000 (UTC) From: Kevin Traynor To: Stephen Hemminger Cc: Matan Azrad , dpdk stable Date: Wed, 11 Dec 2019 21:26:40 +0000 Message-Id: <20191211212702.27851-48-ktraynor@redhat.com> In-Reply-To: <20191211212702.27851-1-ktraynor@redhat.com> References: <20191211212702.27851-1-ktraynor@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-MC-Unique: M7Ta02awMp6MgSTjwWajUA-1 X-Mimecast-Spam-Score: 0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: quoted-printable Subject: [dpdk-stable] patch 'examples/multi_process: check server port validity' has been queued to LTS release 18.11.6 X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: stable-bounces@dpdk.org Sender: "stable" Hi, FYI, your patch has been queued to LTS release 18.11.6 Note it hasn't been pushed to http://dpdk.org/browse/dpdk-stable yet. It will be pushed if I get no objections before 12/17/19. So please shout if anyone has objections. Also note that after the patch there's a diff of the upstream commit vs the patch applied to the branch. This will indicate if there was any rebasing needed to apply to the stable branch. If there were code changes for rebasi= ng (ie: not only metadata diffs), please double check that the rebase was correctly done. Queued patches are on a temporary branch at: https://github.com/kevintraynor/dpdk-stable-queue This queued commit can be viewed at: https://github.com/kevintraynor/dpdk-stable-queue/commit/573bdb4f37ca0a1659= e5b2ba8e611832a4c0c9f6 Thanks. Kevin. --- >From 573bdb4f37ca0a1659e5b2ba8e611832a4c0c9f6 Mon Sep 17 00:00:00 2001 From: Stephen Hemminger Date: Mon, 5 Aug 2019 09:38:16 -0700 Subject: [PATCH] examples/multi_process: check server port validity [ upstream commit 1f41d98c207aee8982ced709864c96c463d4503a ] The mp_server incorrectly allows a port mask that included hidden ports and which later caused either lost packets or failed initialization. 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 Acked-by: Matan Azrad --- .../client_server_mp/mp_server/args.c | 40 ++++++++++--------- .../client_server_mp/mp_server/args.h | 2 +- .../client_server_mp/mp_server/init.c | 7 +--- 3 files changed, 25 insertions(+), 24 deletions(-) diff --git a/examples/multi_process/client_server_mp/mp_server/args.c b/exa= mples/multi_process/client_server_mp/mp_server/args.c index b0d8d7665..3c2ca266b 100644 --- a/examples/multi_process/client_server_mp/mp_server/args.c +++ b/examples/multi_process/client_server_mp/mp_server/args.c @@ -11,4 +11,5 @@ =20 #include +#include #include =20 @@ -42,9 +43,9 @@ usage(void) */ static int -parse_portmask(uint8_t max_ports, const char *portmask) +parse_portmask(const char *portmask) { =09char *end =3D NULL; -=09unsigned long pm; -=09uint16_t count =3D 0; +=09unsigned long long pm; +=09uint16_t id; =20 =09if (portmask =3D=3D NULL || *portmask =3D=3D '\0') @@ -52,19 +53,22 @@ parse_portmask(uint8_t max_ports, const char *portmask) =20 =09/* convert parameter to a number and verify */ -=09pm =3D strtoul(portmask, &end, 16); -=09if (end =3D=3D NULL || *end !=3D '\0' || pm =3D=3D 0) +=09errno =3D 0; +=09pm =3D strtoull(portmask, &end, 16); +=09if (errno !=3D 0 || end =3D=3D NULL || *end !=3D '\0') =09=09return -1; =20 -=09/* loop through bits of the mask and mark ports */ -=09while (pm !=3D 0){ -=09=09if (pm & 0x01){ /* bit is set in mask, use port */ -=09=09=09if (count >=3D max_ports) -=09=09=09=09printf("WARNING: requested port %u not present" -=09=09=09=09" - ignoring\n", (unsigned)count); -=09=09=09else -=09=09=09 ports->id[ports->num_ports++] =3D count; -=09=09} -=09=09pm =3D (pm >> 1); -=09=09count++; +=09RTE_ETH_FOREACH_DEV(id) { +=09=09unsigned long msk =3D 1u << id; + +=09=09if ((pm & msk) =3D=3D 0) +=09=09=09continue; + +=09=09pm &=3D ~msk; +=09=09ports->id[ports->num_ports++] =3D id; +=09} + +=09if (pm !=3D 0) { +=09=09printf("WARNING: leftover ports in mask %#llx - ignoring\n", +=09=09 pm); =09} =20 @@ -100,5 +104,5 @@ parse_num_clients(const char *clients) */ int -parse_app_args(uint16_t max_ports, int argc, char *argv[]) +parse_app_args(int argc, char *argv[]) { =09int option_index, opt; @@ -113,5 +117,5 @@ parse_app_args(uint16_t max_ports, int argc, char *argv= []) =09=09switch (opt){ =09=09=09case 'p': -=09=09=09=09if (parse_portmask(max_ports, optarg) !=3D 0){ +=09=09=09=09if (parse_portmask(optarg) !=3D 0) { =09=09=09=09=09usage(); =09=09=09=09=09return -1; diff --git a/examples/multi_process/client_server_mp/mp_server/args.h b/exa= mples/multi_process/client_server_mp/mp_server/args.h index 79c190a33..52c8cc86e 100644 --- a/examples/multi_process/client_server_mp/mp_server/args.h +++ b/examples/multi_process/client_server_mp/mp_server/args.h @@ -6,5 +6,5 @@ #define _ARGS_H_ =20 -int parse_app_args(uint16_t max_ports, int argc, char *argv[]); +int parse_app_args(int argc, char *argv[]); =20 #endif /* ifndef _ARGS_H_ */ diff --git a/examples/multi_process/client_server_mp/mp_server/init.c b/exa= mples/multi_process/client_server_mp/mp_server/init.c index 3af5dc699..1b0569937 100644 --- a/examples/multi_process/client_server_mp/mp_server/init.c +++ b/examples/multi_process/client_server_mp/mp_server/init.c @@ -239,5 +239,5 @@ init(int argc, char *argv[]) =09int retval; =09const struct rte_memzone *mz; -=09uint16_t i, total_ports; +=09uint16_t i; =20 =09/* init EAL, parsing EAL args */ @@ -248,7 +248,4 @@ init(int argc, char *argv[]) =09argv +=3D retval; =20 -=09/* get total number of ports */ -=09total_ports =3D rte_eth_dev_count_total(); - =09/* set up array for port data */ =09mz =3D rte_memzone_reserve(MZ_PORT_INFO, sizeof(*ports), @@ -260,5 +257,5 @@ init(int argc, char *argv[]) =20 =09/* parse additional, application arguments */ -=09retval =3D parse_app_args(total_ports, argc, argv); +=09retval =3D parse_app_args(argc, argv); =09if (retval !=3D 0) =09=09return -1; --=20 2.21.0 --- Diff of the applied patch vs upstream commit (please double-check if non-= empty: --- --- -=092019-12-11 21:24:16.514527152 +0000 +++ 0048-examples-multi_process-check-server-port-validity.patch=092019-12-= 11 21:24:12.707650391 +0000 @@ -1 +1 @@ -From 1f41d98c207aee8982ced709864c96c463d4503a Mon Sep 17 00:00:00 2001 +From 573bdb4f37ca0a1659e5b2ba8e611832a4c0c9f6 Mon Sep 17 00:00:00 2001 @@ -5,0 +6,2 @@ +[ upstream commit 1f41d98c207aee8982ced709864c96c463d4503a ] + @@ -13 +14,0 @@ -Cc: stable@dpdk.org @@ -108 +109 @@ -index 3d4a9cdfa..ad9f46f0a 100644 +index 3af5dc699..1b0569937 100644 @@ -111 +112 @@ -@@ -249,5 +249,5 @@ init(int argc, char *argv[]) +@@ -239,5 +239,5 @@ init(int argc, char *argv[]) @@ -118 +119 @@ -@@ -258,7 +258,4 @@ init(int argc, char *argv[]) +@@ -248,7 +248,4 @@ init(int argc, char *argv[]) @@ -126 +127 @@ -@@ -270,5 +267,5 @@ init(int argc, char *argv[]) +@@ -260,5 +257,5 @@ init(int argc, char *argv[])