From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id D356DA055D for ; Tue, 2 Mar 2021 17:37:27 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 089B740142; Tue, 2 Mar 2021 17:37:25 +0100 (CET) Received: from m12-13.163.com (m12-13.163.com [220.181.12.13]) by mails.dpdk.org (Postfix) with ESMTP id 46A3E40142; Tue, 2 Mar 2021 17:37:22 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=163.com; s=s110527; h=From:Subject:Date:Message-Id; bh=nff/vWM4ZykhFa8HHC IZ/c6EeiseSGETJwyk4RfnaWA=; b=oLMXRzO6POY1Hh3lqV4t9T8DnVr6W3O7qX En6dyaVL1Nohi334IU1Fe+JRr5W8WRtcPpkGoVin8oM4ZbJJO9MGt6SvHQ4UPXXN uJ158VyTOLJ2zYVE+iIRfBBOMtYxXCZQ6T5gfTh/zvVsKfmuZdkd1aVuRZWyjsSN tKMYlWk4k= Received: from localhost.localdomain.localdomain (unknown [112.10.64.142]) by smtp9 (Coremail) with SMTP id DcCowAA3bZG9aT5gQYr5hQ--.154S2; Wed, 03 Mar 2021 00:37:17 +0800 (CST) From: Jiawei Zhu <17826875952@163.com> To: dev@dpdk.org Cc: zhujiawei12@huawei.com, matan@nvidia.com, shahafs@nvidia.com, viacheslavo@nvidia.com, Jiawei Zhu <17826875952@163.com>, stable@dpdk.org Date: Mon, 1 Mar 2021 12:19:50 -0500 Message-Id: <1614619190-3846-1-git-send-email-17826875952@163.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1614617885-2650-1-git-send-email-17826875952@163.com> References: <1614617885-2650-1-git-send-email-17826875952@163.com> X-CM-TRANSID: DcCowAA3bZG9aT5gQYr5hQ--.154S2 X-Coremail-Antispam: 1Uf129KBjvJXoW7WryxArWUGw4rXF1xAw43Wrg_yoW8Ww1xpr 4a9ryUArn5J348Z3WIva1Fq3Wruw4rJFWjkr98CwsxZ3s3W345WrW2gay7uFyUurWkCa42 qrnFvwn8GFs8ZFUanT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDUYxBIdaVFxhVjvjDU0xZFpf9x07UZqXJUUUUU= X-Originating-IP: [112.10.64.142] X-CM-SenderInfo: bprxmjywyxkmivs6il2tof0z/1tbiRR1J9ll91WvqCAAAsf Subject: [dpdk-stable] [PATCH v3] net/mlx5: fix wrong segmented packet in Rx X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.29 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" The issue occurred if mbuf starvation happened in the middle of segmented packet reception. In such a situation, after release the segments of packet being received, code did not advance the consumer index to the next stride. This caused the receiving of the wrong segmented packet data. The possible error scenario: - we assume segs_n is 4 and we are receiving 4 segments of multi-segment packet. - we fail to allocate mbuf while receiving the 3rd segment, and this frees the mbufs of the packet chain we have built. There are the 1st and 2nd segments in the chain. - the 1st and the 2nd segments of this stride of Rx queue are filled up (in elts array) with the new allocated mbufs and their data are random (the 3rd and 4th segments still contain the valid data of the packet though). - on the next iteration of stride processing we get the wrong two segments of the multi-segment packet. Hence, we should skip these mbufs in the stride and we should advance the consumer index on loop exit. Fixes: 15a756b63734 ("net/mlx5: fix possible NULL dereference in Rx path") Cc: stable@dpdk.org Signed-off-by: Jiawei Zhu <17826875952@163.com> --- v3: * Reword the commit message a little bit. v2: * Added extra explanation in commit message. --- drivers/net/mlx5/mlx5_rxtx.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/net/mlx5/mlx5_rxtx.c b/drivers/net/mlx5/mlx5_rxtx.c index 2e4b87c..e3ce9fd 100644 --- a/drivers/net/mlx5/mlx5_rxtx.c +++ b/drivers/net/mlx5/mlx5_rxtx.c @@ -1480,6 +1480,9 @@ enum mlx5_txcmp_code { rte_mbuf_raw_free(pkt); pkt = rep; } + rq_ci >>= sges_n; + ++rq_ci; + rq_ci <<= sges_n; break; } if (!pkt) { -- 1.8.3.1