From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wr1-f67.google.com (mail-wr1-f67.google.com [209.85.221.67]) by dpdk.org (Postfix) with ESMTP id 1CEEB98 for ; Tue, 24 Jul 2018 08:57:49 +0200 (CEST) Received: by mail-wr1-f67.google.com with SMTP id c13-v6so2969238wrt.1 for ; Mon, 23 Jul 2018 23:57:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=6wind-com.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:content-transfer-encoding:in-reply-to:openpgp :user-agent; bh=WYbzuI+T074Sxnv1qZfXwvjsTuMn0EK2U6fJfCj83Ds=; b=JvjAuZ9M5frimCqxQIhsWvzWe96ld4w3I0ramdzoOqLN0HQQNFHmLvT/bLDAJTU16f jWrKQ8ze9JB1Gqjj/ey7yw+hx2Nm1ljmQ7+SXOQ573J+T6Umr3Bkk+LFbzt8FMQFWJCY T2IgDKaKM+Qvk2IUCbcTBD/2vCn49zfc1H0I0BS3XBTSLIiqcmybN6kPf0FoDu18e2tE vRXWtO7map0QEjgf/m3uxQeJXdRjrSTvFbdn1V2Uz1Vxk41yckA2GPrFh3Pbc62VUnKn aJPdk3DXirck8gtIcFTy2jTXD9mGCk+cwDSWAzpExN7HHORWoozFkP0h/cX56a/dTDsn ypJQ== 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:references :mime-version:content-disposition:content-transfer-encoding :in-reply-to:openpgp:user-agent; bh=WYbzuI+T074Sxnv1qZfXwvjsTuMn0EK2U6fJfCj83Ds=; b=kOq7XVGs1eq+NKQXLtCZsJnhTu+XR98aJfscWT3EagAbZp2JpyJCZkogvU4dgjKHgO Ib+8qsYIrqck8GaC8WR6qImdQ7Vt3aLzWeS5UnQCptGTV5ZRyv9yU/WPa3UbWhXGuUN3 PztZuwOMKb7PQ7N7X+WZNYRTMMdaewm/NG0KLqkBx4qb0Vhg0FnsSDeHSbLyRNZdoujT LHy9ksGebrgxmGZ03/QL/KydAnusClP2Gs+DQ4JeCQthCsdlaHB/P71JR98p4YlxlJvq 8f+OFp5HAYVwbSo7t/uVRbybXapPMZrqcOyE5YM8K3j4FCOeNgKCpYsh7CW2IEztFIw0 GQVQ== X-Gm-Message-State: AOUpUlFvEAmHkcVHBPHZIv1oEq720DuDgPjIKFY4XfjEVkUHvibgnQbg qxPveDq8vTAzZ7v7AsHUU70J X-Google-Smtp-Source: AAOMgpehXk7QmCw88768I+BAoAvt5jXttbRtiPfxpE1WT1Itob3JqPRblxv0+QT3oN4ZwmDLBaLGvw== X-Received: by 2002:a5d:62c7:: with SMTP id o7-v6mr11211661wrv.83.1532415468931; Mon, 23 Jul 2018 23:57:48 -0700 (PDT) Received: from laranjeiro-vm.dev.6wind.com (host.78.145.23.62.rev.coltfrance.com. [62.23.145.78]) by smtp.gmail.com with ESMTPSA id b126-v6sm1028759wmf.41.2018.07.23.23.57.48 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 23 Jul 2018 23:57:48 -0700 (PDT) Date: Tue, 24 Jul 2018 08:57:42 +0200 From: =?iso-8859-1?Q?N=E9lio?= Laranjeiro To: Yongseok Koh Cc: shahafs@mellanox.com, dev@dpdk.org Message-ID: <20180724065742.xynuw5ddr5pnesju@laranjeiro-vm.dev.6wind.com> References: <20180723182744.1179-1-yskoh@mellanox.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20180723182744.1179-1-yskoh@mellanox.com> OpenPGP: id=A0075DA8F66A5949 preference=signencrypt User-Agent: NeoMutt/20170113 (1.7.2) Subject: Re: [dpdk-dev] [PATCH] net/mlx5: fix possible endless loop when clearing flow flags 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: , X-List-Received-Date: Tue, 24 Jul 2018 06:57:49 -0000 On Mon, Jul 23, 2018 at 11:27:44AM -0700, Yongseok Koh wrote: > If one of (*priv->rxqs)[] is null, the for loop can iterate infinitely as > idx can't be increased. > > Fixes: cd24d526395e ("net/mlx5: add mark/flag flow action") > Cc: Nelio Laranjeiro > > Signed-off-by: Yongseok Koh > --- > drivers/net/mlx5/mlx5_flow.c | 8 +++----- > 1 file changed, 3 insertions(+), 5 deletions(-) > > diff --git a/drivers/net/mlx5/mlx5_flow.c b/drivers/net/mlx5/mlx5_flow.c > index 32854198b..c156f01eb 100644 > --- a/drivers/net/mlx5/mlx5_flow.c > +++ b/drivers/net/mlx5/mlx5_flow.c > @@ -2762,22 +2762,20 @@ mlx5_flow_rxq_flags_clear(struct rte_eth_dev *dev) > { > struct priv *priv = dev->data->dev_private; > unsigned int i; > - unsigned int idx; > > - for (idx = 0, i = 0; idx != priv->rxqs_n; ++i) { > + for (i = 0; i != priv->rxqs_n; ++i) { > struct mlx5_rxq_ctrl *rxq_ctrl; > unsigned int j; > > - if (!(*priv->rxqs)[idx]) > + if (!(*priv->rxqs)[i]) > continue; > - rxq_ctrl = container_of((*priv->rxqs)[idx], > + rxq_ctrl = container_of((*priv->rxqs)[i], > struct mlx5_rxq_ctrl, rxq); > rxq_ctrl->flow_mark_n = 0; > rxq_ctrl->rxq.mark = 0; > for (j = 0; j != MLX5_FLOW_TUNNEL; ++j) > rxq_ctrl->flow_tunnels_n[j] = 0; > rxq_ctrl->rxq.tunnel = 0; > - ++idx; > } > } > > -- > 2.11.0 This patch is wrong, (*priv->rxqs)[i] may un-initialised by the application, the number of queues says how are in used, it does not mean they are contiguous in the rxqs arrays and this due to the DPDK API which configure the number of queues with rte_eth_dev_configure() whereas queues are instantiated with rte_eth_rx_queue_setup() which takes an position in the array as parameter. Indeed this code is wrong, idx should always increase whereas i should only increase if the (*priv->rxqs)[idx] is non null. -- Nélio Laranjeiro 6WIND