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 DCDEAA00E6 for ; Mon, 5 Aug 2019 18:00:58 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id BAD7B1B959; Mon, 5 Aug 2019 18:00:58 +0200 (CEST) Received: from mail-pg1-f196.google.com (mail-pg1-f196.google.com [209.85.215.196]) by dpdk.org (Postfix) with ESMTP id BEE073798 for ; Mon, 5 Aug 2019 18:00:57 +0200 (CEST) Received: by mail-pg1-f196.google.com with SMTP id n4so4698021pgv.2 for ; Mon, 05 Aug 2019 09:00:57 -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=qCkCSYnNIfLJ3U+RpXtVeTD0+krFn8uG1ZZr90mxI3o=; b=15dhIAw+txOr08zujnKbXtfYUFUI3N5l6L/NUgvICKmCLP9RwIk2p9pwcZ8d2iTTYE Og8vz7MNVlf1qhPyFMufm9IrU/2PnCGoDP2UfJRK8fZK/jy3TJSF3rwJW/+s3cT4gG21 LRy+09Ck8a/ed89p3YPxKoiCfqwJoJKUgupe+OjZh0+kMiFLI5S3jpoGFV+7jaBbw57w V0Q3RshyitGNp8jlyuIvksS+kkDpRQHSx4gMeKaKUEYaorm0CcGrG3TxLCcpycElwkIe VZKN3+51nmaYFC3lm98ghTwvU+LR75/9SMhlvvgwcXBekrK3vcF203S12OET/km1P6Cs MAyQ== 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=qCkCSYnNIfLJ3U+RpXtVeTD0+krFn8uG1ZZr90mxI3o=; b=bCgALXjG4+3nD5wSRPjj1MIwcT8PdfVUOQRDFi3ak7dzM/ACgMooySZOARCd9l5Dq/ wUxiE4uJpHgPBbKdIaRDGQp+0bZcTBgLrXMTfts4TgvmEcCnhsFhCB/GOdUp0IJ0+ts5 DmYwwK6DI0rs6wDtktppK4cAQDId0ENVYm7mMXSeTYb1BlV8kAwpvuaduqyGxMvBs21W HoyJx5Z+Ctwpu2KJEOTT7izl+5IhF/3PudLIyVBn9bEJzqf6QhfYNS2hzUCa69DjYuWg jmndAkSgMApbJamq3+vZ1+fc5ecM6m05D7vOO1YRYhUZkQ8uFJ75/a0UR7ggvoPtS99o jjkw== X-Gm-Message-State: APjAAAVtroOjsewU1q2UFVlfUJyowdGGl+KIc8xhYNBqkX5klwTuKBuI zPM59tQ9dOIgPfDbR28Q6jk= X-Google-Smtp-Source: APXvYqwGmZ84schlpKK43RY/5bCcWVvBrk5sdpug3lX+M1OzS45RwkXEzUp7bHH5eAKU6oT0CHsMCA== X-Received: by 2002:a65:6546:: with SMTP id a6mr84630380pgw.220.1565020856766; Mon, 05 Aug 2019 09:00:56 -0700 (PDT) Received: from hermes.lan (204-195-22-127.wavecable.com. [204.195.22.127]) by smtp.gmail.com with ESMTPSA id a1sm51262161pgh.61.2019.08.05.09.00.56 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Mon, 05 Aug 2019 09:00:56 -0700 (PDT) Date: Mon, 5 Aug 2019 09:00:54 -0700 From: Stephen Hemminger To: Matan Azrad Cc: "dev@dpdk.org" , Stephen Hemminger Message-ID: <20190805090054.1511b033@hermes.lan> In-Reply-To: References: <20190726165054.24078-1-stephen@networkplumber.org> <20190802025826.1174-1-stephen@networkplumber.org> <20190802025826.1174-2-stephen@networkplumber.org> <20190802085301.02ab5b55@hermes.lan> 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 Sun, 4 Aug 2019 08:31:54 +0000 Matan Azrad wrote: > > > > /* 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. > > So, all are bugs, no? I don't think 32 bit build is that well tested. But yes a mask needs to hold 64 ports. > > 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: The problem here was my mistake for not having wide enough portmask.