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 6C8DCA10DA for ; Fri, 2 Aug 2019 17:53:08 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 4D4021C2DD; Fri, 2 Aug 2019 17:53:07 +0200 (CEST) Received: from mail-pg1-f193.google.com (mail-pg1-f193.google.com [209.85.215.193]) by dpdk.org (Postfix) with ESMTP id 3213D1C24A for ; Fri, 2 Aug 2019 17:53:05 +0200 (CEST) Received: by mail-pg1-f193.google.com with SMTP id u17so36276993pgi.6 for ; Fri, 02 Aug 2019 08:53:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=hNFmVxPn4JyQSmKhxFiVL7yz55Te0gveSUYWtcbtyuU=; b=nkBU+4YXh0qzTinf8X5e1tiGkfOFn9f7nbqS0k8SvjDEcovPxy3VV2soM83odTqwa3 vZ4nduyxsSdkPsjLaKe0mIPVdOisnAjnNzPGEB/BnNQKOFbPAhFJOXlpRNwWbdxw9xo/ qP9RipuqwcPp7sNlKK3d4EedvIjvJ4Ycw5rK2YAL2Uh8Wb9duMn/o5deg3hTWxKLAi0L 1j7OmqdCVA7wSusM6ieVDY8B3QMGoSEo4E182FvUo24+l3ryiqIEQSBlC2x5swJ97kiL oby/RGdRlUPHJcyO0llRCYobakexRZCGA54SFdKluXWvNpxbC0wa7I+qYLZEIDCP/gY0 /j+w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=hNFmVxPn4JyQSmKhxFiVL7yz55Te0gveSUYWtcbtyuU=; b=W3ShyiZrher7UKYrp9cr+PYUwaoowLDQgjPhOGLhlr8Ur9dN09ZHF/7odHt77AMz98 aUT9rs6cFHYPT/clsabwjLWaM8fJDAmI59QW9jEldVpfpyNBe/jeNfI/AhTjl0yyU7ER 7TxCILoSxPyRZPST5Qdmubu5Xm5qpChLIU+e7EWfLI8wVJQxv4rsdC272EL735k/Z4Lx RY8AFtqjC6Cv+v4YsSsg0idW55siz5bb4x+0ZOMqx4VFM+ctA3q0yK/9amkzS17uG6q+ 4znMMFbeWY0P1++Zn2MrgsA4YMbAzWcGfI6APwsV46NCWql+ZH+W94QbwB0DB0KfGBBR sQ4Q== X-Gm-Message-State: APjAAAVKwxqxWq0jBxTBtvNBptDD2xJ7uz531B2AKQJz46Agjjfa1QCP qIeLM/BQ9Dxwt/Re3PScA/w= X-Google-Smtp-Source: APXvYqxINE1xkwegjdRXITrUZ2HvLg1OqUwUB3RXfl8oR98jP4q/MFPlKWTXURqbixIzZYqdvYBS9w== X-Received: by 2002:aa7:989a:: with SMTP id r26mr47305068pfl.232.1564761184334; Fri, 02 Aug 2019 08:53:04 -0700 (PDT) Received: from hermes.lan (204-195-22-127.wavecable.com. [204.195.22.127]) by smtp.gmail.com with ESMTPSA id e10sm78922761pfi.173.2019.08.02.08.53.04 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Fri, 02 Aug 2019 08:53:04 -0700 (PDT) Date: Fri, 2 Aug 2019 08:53:01 -0700 From: Stephen Hemminger To: Matan Azrad Cc: "dev@dpdk.org" , Stephen Hemminger Message-ID: <20190802085301.02ab5b55@hermes.lan> In-Reply-To: References: <20190726165054.24078-1-stephen@networkplumber.org> <20190802025826.1174-1-stephen@networkplumber.org> <20190802025826.1174-2-stephen@networkplumber.org> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit 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" On Fri, 2 Aug 2019 05:33:20 +0000 Matan Azrad wrote: > 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 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 > > --- > > .../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 = NULL; > > unsigned long pm; > > - uint16_t count = 0; > > + uint16_t id; > > > > if (portmask == NULL || *portmask == '\0') > > return -1; > > > > /* convert parameter to a number and verify */ > > pm = strtoul(portmask, &end, 16); > > - if (end == NULL || *end != '\0' || pm == 0) > > + if (end == NULL || *end != '\0' || pm > UINT16_MAX || pm == 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. > The DPDK assumes a lot of places that unsigned long will hold a port mask. If some extra bits are set, the error is visible later when the bits are leftover after finding ports. The original code had worse problems, it would not catch invalid pm values at all and truncate silently.