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=1796389472; b=EjB6QKESxidW20TBZoDpAiZ4UjBKLt7Jqg0n0a49W03pTFPZvqO8tASq0jWM5nVIEaXH w4visJY51RRO1/ZgTBO2TuHWVqERs6gugssKoQmJwDqIdut+yHpRgpzz9nBXIMIuX6cAh VPjV+mI1M8YJN50skLpDVWOAjwXO5TSUwyPacF/Jc1RbvSvOhQHB8/EeubX5zTaGfLqh3 PidptOmWFmILELoiFE1JBzS/mL4WXHW1LjoN0Z18Sse8QqviRc3p4gN35QLIedg2ssxsr e658f3PK8iueNY1txY5S+I6PZqe1oj/VJN0Fsmu9GS5BhJkadjpmIVho0L4PtTSvaaA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796389472; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:MIME-Version:Content-Transfer-Encoding; bh=2sm4SfyWWybo963WW2epBw1NidmpNnHNk4cAxWDmkno=; b=J/RllvCVtza9zupaR5rWHj45Wanyo71TKw+xZ27QCfv/Wlj69qzL9GUfT1k3bT2AdMqI IEMy+C7h/Ieg0L+9bydKntx8EsjJz+fUOo/SRrO5+6WiOIE+jeR8Jvr8v5b8lGQnQUzWx EnR5wkT/bSdIAamtsDnvTOBs/1sgSsAbSZKcdRJxJh8tyaYt/tvkIIPDOOAbePxfvSfB6 5SnuYADDyZqGQjgwk1UY+Gl3Z5i7iYOsfM29E2M2P8gX7aA9OIFOUeXxLiJF7+1bImIYg YXJfXs7AOJJzR3iuRzZuMHb1KCg3Geo+8UFbE37wKLeCilGKOqPyiGs8FQGSDTUQzXw== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=PsWdqo9Y; 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 A21F6606A322 for ; Fri, 4 Dec 2026 13:04:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=PsWdqo9Y Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7399A1F00936; Fri, 4 Dec 2026 13:04:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796389472; bh=2sm4SfyWWybo963WW2epBw1NidmpNnHNk4cAxWDmkno=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=PsWdqo9YjxjDFFkBmiBpZfiQpHVyi3PZZgfFMhBI/PC5II9OV7+mCzDRBA0kXKux4 9t9N2tPcEDdX0JdA9fGQmRYDa4j6+ORy/Gccsx44brr8bUw4n2UKh0sY2pJwbq6/xH bPfyjzaREt4nwWeE+KOTMKJguQuJ1VLGB10+vTna19PzRRDjBLaeAsDPusWC5HPZaO rLxoSMQZ6Y8NwlVQ1HVQPrfKl0cD/RWSN/bJmoUE+nOY6pMP8PQvYuyirNHyBlP586 BFwer9xG72P7Yt0HZZvPlJ/1tXbtLYZ0xMXCikn5UjvTmELNVr5EO6K1QG9HqSI2ZU tmZJDBatGR4Xg== From: Sasha Levin To: stable@vger.kernel.org Cc: Arun Iyengar , Maxime Chevallier , Jakub Kicinski , Sasha Levin Subject: [PATCH 6.1.y] net: stmmac: drop the rest of the frame when napi_build_skb() fails Date: Fri, 4 Dec 2026 08:04:30 -0500 Message-ID: <20261204130416.3097385-1-sashal@kernel.org> X-Mailer: git-send-email 2.53.0 In-Reply-To: <2026120213-ocean-armchair-22c4@gregkh> References: <2026120213-ocean-armchair-22c4@gregkh> X-Mailing-List: stable@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit From: Arun Iyengar [ Upstream commit ece404eac250fc4be7aa4cec82e8c248cca83c28 ] If napi_build_skb() fails on the first buffer of a frame that spans several descriptors, stmmac_rx() drops that buffer but goes on with the next descriptor of the same frame as if a new frame started there. The rest of the frame is then passed up the stack as a frame of its own. A frame spans several descriptors when it does not fit in the RX buffers of one descriptor. Mark the frame as errored instead, so that its remaining descriptors are discarded like those of a frame with a receive error. The frame is counted once in rx_dropped and once against the NAPI budget. Found while working on the sun8i EMAC jumbo frame series, where frames over 2032 bytes span several descriptors. Tested on an Orange Pi Zero2 (dwmac-sun8i, MTU 4070), w/ jumbo series and error injection. Fixes: ec222003bd94 ("net: stmmac: Prepare to add Split Header support") Cc: stable@vger.kernel.org Signed-off-by: Arun Iyengar Reviewed-by: Maxime Chevallier Link: https://patch.msgid.link/20261113-stmmac-rx-skb-fail-v1-1-fcaae89f2d2c@gmail.com Signed-off-by: Jakub Kicinski [ sashal: Replaced the upstream goto next with count++; continue since this tree has no next: label, and adjusted context for the older napi_alloc_skb() allocation path. ] Signed-off-by: Sasha Levin --- drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c index 6d704f86a8729..48fb226aee3ab 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c @@ -5479,7 +5479,7 @@ static int stmmac_rx(struct stmmac_priv *priv, int limit, u32 queue) skb = napi_alloc_skb(&ch->rx_napi, buf1_len); if (!skb) { rx_dropped++; - count++; + error = 1; goto drain_data; } @@ -5517,8 +5517,10 @@ static int stmmac_rx(struct stmmac_priv *priv, int limit, u32 queue) drain_data: if (likely(status & rx_not_ls)) goto read_again; - if (!skb) + if (!skb) { + count++; continue; + } /* Got entire packet into SKB. Finish it. */ -- 2.53.0