From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796388028; b=aAtVzyIRGdEvRiiW9T0zV+oAbQuIwJzidJUUSSM/Sd4d2m7m9JT+JE4IjmnlfhFKYbNA wqzwWlV5dwBArnuHFYWhyeI3/TbGV8/3POM42pUV2Y0jI1U/70WCfnjzhDx0RIFdm7ok6 fldIRaIJ18QF6jXRytS6YLsVjES7yud/OeThj8am4KQzHRhJJnIFW2Z+PtIhP88yOWAV6 9sczXlNObdNS5w3WEBgX0LQyst21Ypa3oJcqGLC1vE8ZlFB5oF2W4FnYGCJclshIZi7s9 iTsdD3DxXuFLH5VL542Pf804l3kOe10jvleOI/HNaC0P1xbgsE9wRsr1khOFLroCfUA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796388028; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:User-Agent:X-stable:X-Patchwork-Hint: MIME-Version:Content-Transfer-Encoding; bh=0oaO52fz8+1FIrtmLoRxg57FIH07LlZrkCIV1eRJlng=; b=ypm9x5AMgIa+Ih9tx6IgMp0kyeUnYsWF1UkVk5ALo2vJ7bhyJvpSm4BWP877xmFhkG28 bpJNL4iRBbhhA1HhUkpTYcmMZx17rweaYKlaJZFd30KeVG7iOFixWxapeRzdsrDAUQbV5 p5bIuipMQAbjY6laizSAV7b4sJgfdk5uZjayZHEXqrjVppFVs4jzCdldTzT86ucV3TOnb 8Uvsd4MpeUC1QAr9vg5ndVnX2ogwwA35wffsw+gnZVxHzh7HMwCyIK7SGiuen+J8e4bL4 QzSnVK39ZVeJCWJzkEszbSj/LBFaPgwqO/+4U43+R9Yj41LYB5M0amnospORDbnn1OA== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=thALlRT1; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id AB8AC606A330; Fri, 4 Dec 2026 12:40:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=thALlRT1 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 203171F000CE; Fri, 4 Dec 2026 12:40:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796388028; bh=0oaO52fz8+1FIrtmLoRxg57FIH07LlZrkCIV1eRJlng=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=thALlRT1VtTgMpA8hFX5w89rk1HstAGvBpikAYFqyxUGfroCdSrQn4OHi+cqA7kY1 QDAIaxWd4oiQCWWjJ4MUl6Nl7B4aLOlDZXSMoXrCSXp8kg7xbsEgGSpispEy0K20Hh IusizmlpVRbulaRiaacJ0aWgt+OBZhHst6hvlO/o= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Michael Chan , Jakub Kicinski , Sasha Levin Subject: [PATCH 6.1 0458/1059] eth: bnxt: dont leak buffers when XDP agg buffer allocation fails Date: Fri, 4 Dec 2026 18:59:49 +0900 Message-ID: <20261204100656.140949052@linuxfoundation.org> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261204100643.980430235@linuxfoundation.org> References: <20261204100643.980430235@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore X-Mailing-List: patches@lists.linux.dev List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.1-stable review patch. If anyone has any objections, please let me know. ------------------ From: Jakub Kicinski [ Upstream commit 1b2f02fb4ba92d01603c8261c94be8d348de65b0 ] If a replacement agg buffer can't be allocated for a packet received with XDP attached, bnxt_rx_pkt() drops the packet without returning its head buffer to the ring. The head buffer leaks, and since rx_prod still advances, the device gets a BD with a stale DMA address which points at a buffer the driver no longer owns. When that BD completes the driver finds no buffer in the slot. The agg buffers consumed before the failing one have already been replaced on the agg ring, they are referenced only by the frags of the xdp_buff, which nobody frees. bnxt_xdp_buff_frags_free() would skip them since the frags flag is set only on success, so set it upfront. Pointed out in LLM review of the first patch of the series. Tested on a BCM57504 at MTU 9000 with a frags-capable XDP_PASS program, receiving 8000B ICMPv6 echo requests (a head and two agg buffers each) while page_pool_alloc_netmems() called from bnxt_rx_agg_netmems_xdp() failed half of the time (bpftrace override()). 44.7k packets were dropped, the page pools' inflight count stayed flat and there were no KASAN or DEBUG_PAGEALLOC splats. Fixes: 4c6c123c9af9 ("bnxt: adding bnxt_rx_agg_pages_xdp for aggregated xdp") Reviewed-by: Michael Chan Link: https://patch.msgid.link/20261027234940.1267225-4-kuba@kernel.org Signed-off-by: Jakub Kicinski [ sashal: Renamed bnxt_rx_agg_netmems_xdp() to bnxt_rx_agg_pages_xdp() and adapted the __bnxt_rx_agg_netmems() call to the older __bnxt_rx_agg_pages() signature with an explicit shinfo argument. ] Signed-off-by: Sasha Levin --- drivers/net/ethernet/broadcom/bnxt/bnxt.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.c b/drivers/net/ethernet/broadcom/bnxt/bnxt.c index 3519dd4c3d911..0ea54713c1d7f 100644 --- a/drivers/net/ethernet/broadcom/bnxt/bnxt.c +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.c @@ -1223,16 +1223,19 @@ static u32 bnxt_rx_agg_pages_xdp(struct bnxt *bp, struct skb_shared_info *shinfo = xdp_get_shared_info_from_buff(xdp); u32 total_frag_len = 0; - if (!xdp_buff_has_frags(xdp)) + if (!xdp_buff_has_frags(xdp)) { + xdp_buff_set_frags_flag(xdp); shinfo->nr_frags = 0; + } total_frag_len = __bnxt_rx_agg_pages(bp, cpr, shinfo, idx, agg_bufs, tpa, xdp); - if (total_frag_len) { - xdp_buff_set_frags_flag(xdp); - shinfo->nr_frags = agg_bufs; - shinfo->xdp_frags_size = total_frag_len; + if (!total_frag_len) { + bnxt_xdp_buff_frags_free(cpr->bnapi->rx_ring, xdp); + return 0; } + shinfo->nr_frags = agg_bufs; + shinfo->xdp_frags_size = total_frag_len; return total_frag_len; } @@ -2003,8 +2006,10 @@ static int bnxt_rx_pkt(struct bnxt *bp, struct bnxt_cp_ring_info *cpr, u32 frag_len = bnxt_rx_agg_pages_xdp(bp, cpr, &xdp, cp_cons, agg_bufs, false); - if (!frag_len) + if (!frag_len) { + bnxt_reuse_rx_data(rxr, cons, data); goto oom_next_rx; + } } xdp_active = true; -- 2.53.0