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 9D6A0A00C2 for ; Thu, 3 Nov 2022 10:33:19 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 992AE40694; Thu, 3 Nov 2022 10:33:19 +0100 (CET) Received: from mail-wr1-f50.google.com (mail-wr1-f50.google.com [209.85.221.50]) by mails.dpdk.org (Postfix) with ESMTP id 5218740693 for ; Thu, 3 Nov 2022 10:33:17 +0100 (CET) Received: by mail-wr1-f50.google.com with SMTP id g12so1700784wrs.10 for ; Thu, 03 Nov 2022 02:33:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=V4WJgbdWAfLgoX4+rJ5787BeiNP8F1npvIgQSnPNcDA=; b=VS0PzaUGzlyALHlWy4LQkiSFuFuCi1Twt5pvNZmZlSpIErp06iRuo4lpbj/qZVyHYs Rka3vADD0ohe0w8cVaqIcy2NUKC5/BscMKuIzmnUiNgpu9LN/C7mkZqPJ0Cq+M2sjRfX sNIqh7GLbz/Yxov8iCtMLzAjGR30cuhP+rDBXBeL1weoFynjkRosZ7gpF63RhFqn5BxA JOGj8k9F+MqZ3W2X2YHOmFe7Y32waNvMHoqMbEKt2MlVFh4pgOqwUZCj65VcGLnfv3hw 1N0I1W1DAlPhi328eJVZT6HEbfoluxXDptQD3k/TZiXmMOScPeQeN8YaIk4X6qol0Jqm jv2w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=V4WJgbdWAfLgoX4+rJ5787BeiNP8F1npvIgQSnPNcDA=; b=VGeCQ+EyPx98EpYlgfYpqRNpwtlKVDsq4zJsf612f9RtTyOIy834oyDtWnRAwYMpf8 KLOVOjalxJfhv0Od+tecX/OznE4mwrcdkWFLxnfh+jnAuJBg6PDNlKj+kI5K271BdLBX 7YpjaoXqSMJZUHPX4wJgu0/LaFv/Ffe/go6a1SLi4N0NHQg+HsHvkjGnMrI/E++jzxoh UHJc9AZZYMZLeotybPvrXZSVC9sbd0RqzNXGQ49IRr7W+4tDGvdJE7eH+TPXggOsZdvK VlOa0yzmD3XthHV91aqe5110EEch5P9/HXgP1xapR01PYnZHX0V0WxkVCnO97FJYXHMS dMTQ== X-Gm-Message-State: ACrzQf3De1P+32+PuL0wMCHYr1ArJID6C3Hyi0mdtBy479ulp4fQ9s9I FyE++MSdSlHOYhs8WHKFSTIpEE8+QagJW8h4 X-Google-Smtp-Source: AMsMyM7nYt0Qk59zte/v3fHT2mJr227I8aSZsEc7QMA74GhxpQEdcF8iitb0Q6CQBpAgOdatXcmADw== X-Received: by 2002:a05:6000:689:b0:236:6c3e:ec88 with SMTP id bo9-20020a056000068900b002366c3eec88mr17751593wrb.346.1667467997006; Thu, 03 Nov 2022 02:33:17 -0700 (PDT) Received: from localhost ([2a01:4b00:d307:1000:f1d3:eb5e:11f4:a7d9]) by smtp.gmail.com with ESMTPSA id f17-20020a05600c4e9100b003cf7292c553sm821749wmq.13.2022.11.03.02.33.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 03 Nov 2022 02:33:16 -0700 (PDT) From: luca.boccassi@gmail.com To: Gagandeep Singh Cc: Hemant Agrawal , dpdk stable Subject: patch 'net/dpaa: fix buffer freeing in slow path' has been queued to stable release 20.11.7 Date: Thu, 3 Nov 2022 09:27:52 +0000 Message-Id: <20221103092758.1099402-94-luca.boccassi@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221103092758.1099402-1-luca.boccassi@gmail.com> References: <20221103092758.1099402-1-luca.boccassi@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 Hi, FYI, your patch has been queued to stable release 20.11.7 Note it hasn't been pushed to http://dpdk.org/browse/dpdk-stable yet. It will be pushed if I get no objections before 11/05/22. 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 rebasing (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 This queued commit can be viewed at: https://github.com/kevintraynor/dpdk-stable/commit/733e3713ae0bb72ec0cb87bbb5fd51b2c1ff92b6 Thanks. Luca Boccassi --- >From 733e3713ae0bb72ec0cb87bbb5fd51b2c1ff92b6 Mon Sep 17 00:00:00 2001 From: Gagandeep Singh Date: Fri, 7 Oct 2022 08:57:43 +0530 Subject: [PATCH] net/dpaa: fix buffer freeing in slow path [ upstream commit 0bf99a02cc0be9de2e182e204ee0be2f21c9e705 ] If there is any error in packet or taildrop feature is enabled, HW can reject those packets and put them in error queue. Driver poll this error queue to free the buffers. DPAA driver has an issue while freeing these rejected buffers. In case of scatter gather packets, it is preparing the mbuf SG list by scanning the HW descriptors and once the mbuf SG list prepared, it free only first segment of the mbuf SG list by calling the API rte_pktmbuf_free_seg(), This will leak the memory of other segments and mempool can be empty. Also there is one more issue, external buffer's memory may not belong to mempool so driver itself free the external buffer after successfully send the packet to HW to transmit instead of let the HW to free it. So transmit function free all the external buffers. But driver has no check for external buffers while freeing the rejected buffers and this can do double free the memory which can corrupt the user pool and crashes and undefined behaviour of system can be seen. This patch fixes the above mentioned issue by checking each and every segment and freeing all the segments except external. Fixes: 9124e65dd3eb ("net/dpaa: enable Tx queue taildrop") Signed-off-by: Gagandeep Singh Acked-by: Hemant Agrawal --- drivers/net/dpaa/dpaa_rxtx.c | 23 ++++++++--------------- 1 file changed, 8 insertions(+), 15 deletions(-) diff --git a/drivers/net/dpaa/dpaa_rxtx.c b/drivers/net/dpaa/dpaa_rxtx.c index bf57eddca3..a69f97f145 100644 --- a/drivers/net/dpaa/dpaa_rxtx.c +++ b/drivers/net/dpaa/dpaa_rxtx.c @@ -445,7 +445,7 @@ dpaa_free_mbuf(const struct qm_fd *fd) bp_info = DPAA_BPID_TO_POOL_INFO(fd->bpid); format = (fd->opaque & DPAA_FD_FORMAT_MASK) >> DPAA_FD_FORMAT_SHIFT; if (unlikely(format == qm_fd_sg)) { - struct rte_mbuf *first_seg, *prev_seg, *cur_seg, *temp; + struct rte_mbuf *first_seg, *cur_seg; struct qm_sg_entry *sgt, *sg_temp; void *vaddr, *sg_vaddr; int i = 0; @@ -459,32 +459,25 @@ dpaa_free_mbuf(const struct qm_fd *fd) sgt = vaddr + fd_offset; sg_temp = &sgt[i++]; hw_sg_to_cpu(sg_temp); - temp = (struct rte_mbuf *) - ((char *)vaddr - bp_info->meta_data_size); sg_vaddr = DPAA_MEMPOOL_PTOV(bp_info, qm_sg_entry_get64(sg_temp)); - first_seg = (struct rte_mbuf *)((char *)sg_vaddr - bp_info->meta_data_size); first_seg->nb_segs = 1; - prev_seg = first_seg; while (i < DPAA_SGT_MAX_ENTRIES) { sg_temp = &sgt[i++]; hw_sg_to_cpu(sg_temp); - sg_vaddr = DPAA_MEMPOOL_PTOV(bp_info, + if (sg_temp->bpid != 0xFF) { + bp_info = DPAA_BPID_TO_POOL_INFO(sg_temp->bpid); + sg_vaddr = DPAA_MEMPOOL_PTOV(bp_info, qm_sg_entry_get64(sg_temp)); - cur_seg = (struct rte_mbuf *)((char *)sg_vaddr - + cur_seg = (struct rte_mbuf *)((char *)sg_vaddr - bp_info->meta_data_size); - first_seg->nb_segs += 1; - prev_seg->next = cur_seg; - if (sg_temp->final) { - cur_seg->next = NULL; + rte_pktmbuf_free_seg(cur_seg); + } + if (sg_temp->final) break; - } - prev_seg = cur_seg; } - - rte_pktmbuf_free_seg(temp); rte_pktmbuf_free_seg(first_seg); return 0; } -- 2.34.1 --- Diff of the applied patch vs upstream commit (please double-check if non-empty: --- --- - 2022-11-03 09:27:31.246967685 +0000 +++ 0094-net-dpaa-fix-buffer-freeing-in-slow-path.patch 2022-11-03 09:27:25.561426079 +0000 @@ -1 +1 @@ -From 0bf99a02cc0be9de2e182e204ee0be2f21c9e705 Mon Sep 17 00:00:00 2001 +From 733e3713ae0bb72ec0cb87bbb5fd51b2c1ff92b6 Mon Sep 17 00:00:00 2001 @@ -5,0 +6,2 @@ +[ upstream commit 0bf99a02cc0be9de2e182e204ee0be2f21c9e705 ] + @@ -29 +30,0 @@ -Cc: stable@dpdk.org @@ -38 +39 @@ -index 4d285b4f38..ce4f3d6c85 100644 +index bf57eddca3..a69f97f145 100644 @@ -41 +42 @@ -@@ -455,7 +455,7 @@ dpaa_free_mbuf(const struct qm_fd *fd) +@@ -445,7 +445,7 @@ dpaa_free_mbuf(const struct qm_fd *fd) @@ -50 +51 @@ -@@ -469,32 +469,25 @@ dpaa_free_mbuf(const struct qm_fd *fd) +@@ -459,32 +459,25 @@ dpaa_free_mbuf(const struct qm_fd *fd)