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=1796387634; b=oGNWBokHo1Oq6vjDGMiDAOa+aYrqn4BFZ2ipwYJP9LBDt8Ncg1eB093yFT7ODmVmeOgi 1lJ5SOjPLYl+03XZXExpromra0oYj0g2jQ6v8LcREeMi0zhKPAHU+DzXQ+onZu4tXg5vv T5dYHlaNI/QrdXv+r2tQE5nSUpZRkIPe/IwwBND/Z2c7cLcgif/0JQe3k11fHDAPOv++O Jx/giNbs7+vIkJ6zDGF48w8nYWLK6q22r8nFi3ffSkJchCaSE3JAJdPdovtIwMSUZRIZN +zrM2/FyW3LCTL782z6R8306MXDSSePs2T8BUTbltrD79EYik2HfywDnTXS0hhUKD6g== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796387634; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:MIME-Version:Content-Transfer-Encoding; bh=PhSho6xdGzRh+ONPj8z9Fw/BRtKqob3f5BXHy4Ola8A=; b=Ehm9A19oSvQZjdSnzYaImzrbQDxxQYH8VmxI3WBRS/QM0o4cDVqfkyUVHyggHxGD3oaS v4eFi1Z1Esi2qC7vpHYEgN0g6qk/uhuUG1ebUWUl33poXU/0IkZ9wqZsebkhGzaKlQE9h Yb4OYpZgWFnuPtuSZO3WZ5dzkmkWLZtyMk94LyNzh+0qSa6El1bA9DQgh7grOTLaulXmV aqiEPmS/TWiri7JZjiQwn8WWHyTnLdJ+hkcEC+FkqZunE2IyGtdW4m+fAIN8oAcbCtV7c bUOsA/7UVYgPaqmq89C4FgKkYmN4N2leibYi2rMMuWOLOItEaR9TOZVwqBnoG+dqysg== 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=aVn2PgSA; 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 BF61F606A32C for ; Fri, 4 Dec 2026 12:33:54 +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=aVn2PgSA Received: by smtp.kernel.org (Postfix) with ESMTPSA id D130C1F000C2; Fri, 4 Dec 2026 12:33:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796387634; bh=PhSho6xdGzRh+ONPj8z9Fw/BRtKqob3f5BXHy4Ola8A=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=aVn2PgSAHRcbyhJw6QjyZNlkJFe21ELK8TWymIUu4zejIguFqG2GhbhHPjq9QFUYY b0IAtgdV15D3w/szl8nzxitCb3b2T+p2/c71ju6luGyO5eXRzQp9gLimk3Eq3eq2kQ hyPIuQBz/UGCKe2yCbJ21EV716q4CO6HxLaWlNaLQoHA/52jDK5KAZwzxf0Mk9mgMl zm92U6ce1haZyF5NUuL+bxOFGNg+LM4oRs9R/2K7y0VtnUBEcqWl4hwBKgAw4ZbQ0I rqzjkghNF4HYdqlcLGi/318PDGafvtl5vlS8nbbiMguE3VzlCKmV+fAz4oLTdnxxkX VPYeFc3hYHABw== From: Sasha Levin To: stable@vger.kernel.org Cc: Arun Iyengar , Maxime Chevallier , Jakub Kicinski , Sasha Levin Subject: [PATCH 6.12.y] net: stmmac: drop the rest of the frame when napi_build_skb() fails Date: Fri, 4 Dec 2026 07:33:52 -0500 Message-ID: <20261204123342.3033595-1-sashal@kernel.org> X-Mailer: git-send-email 2.53.0 In-Reply-To: <2026120213-cherub-disarm-03b0@gregkh> References: <2026120213-cherub-disarm-03b0@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: Adapted the allocation-failure path to this tree's napi_alloc_skb() code, and replaced upstream's goto next with an inline count++ and continue because there is no next: label. ] 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 378824a166ecb..c3274f755e8e5 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c @@ -5691,7 +5691,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; } @@ -5729,8 +5729,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