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=1796388347; b=mKJLCVpsJBCZwzs9ylH7+jlwmYfmbt94sM01Yv7xvuPNpr8qtcR0gFffkHyL66ZE2fBc wOGNFhtu+8vfL8lh/rTR6A/813mhJ5afRqJmXG8CyPIgO3riErUjMz8RoTsfVJpBngEke kECtx5EqxF3XI46FR5fiT/ut5ucqLtcHoicvIung92EGTGe9gKnmuU+ibg4+d0FdCab7z 49B6O0Imanyeaq9Wynv6mtrAe/qIX+3hm+22K9Ww1CdeZS5aCHYJEyi9MjU2ptYd4iRnh dw9u5VVhaLS4y2vs6/oHqLBpBQQ+L/BdXBJlKmu1VU2j3393H2Wh4vkRv3dRUfXTbbA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796388347; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:MIME-Version:Content-Transfer-Encoding; bh=yvELaWcTC4vePwiR8BF5NR8bwQrmWnsWyHc9bcqG7oM=; b=UyNe7hzadRAUEvwdHcAqQB112X+CkI54wnRSgcvEPklRkCHJns4TtKYMJlaFVu59qCq7 2awZ6hiUOOQdvnIrjNdqwfTRcmBOeX1vFLeOQu6gIQnC/Cu3K3TQZ/0N5pgFEjmxdcKg9 wXuF8QWSqSTV1j3mnzSH3CG54/lhpCEV47ekclFvAi7JN9Y8NtVd6MYGeaImtSlhaTG5y LWeXdwjqFhQ5RtQZdYDGNbN3Xl5dKAeit+dIq6imkENSeOd2U93U15WmjDt9ERrgnalwg ZDR7busAGen7xjn0lAUIOVVYk1oenuwq8n4gYmr0zqFmbb6aG2f+kvXvBB0mzMmnu1g== 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="GGsj/Dkl"; 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 A0EA6606A683 for ; Fri, 4 Dec 2026 12:45:47 +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=GGsj/Dkl Received: by smtp.kernel.org (Postfix) with ESMTPSA id 46D271F00933; Fri, 4 Dec 2026 12:45:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796388346; bh=yvELaWcTC4vePwiR8BF5NR8bwQrmWnsWyHc9bcqG7oM=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=GGsj/DklQpuQwy/+KFxfMUF3oWjaF4NGEuo2q7VZA5UaBQFLzcqBhW0NXqHdZ/REz L2moWdVtu/iV+iaDE8qmA8sRQn2P+t6pWFWtoKiJBf0TX3b/4FMQDCR7sqi4l3KfVq CxRnhyM5qo0xxP0DTgf9rDb1d17He3JJWkwmJTaf5Esd8TABK2/f4QuNztu/nkmjoV cJUE9wbWbHAt06ITqpaPb6VRJFf0dVGa2p5tJHe6cgMr4Yqrs6xhfUA9sYRBaJ2vVk q4HHk5c0ggIDKljFMopm0VuDaSrMoeVZovns6MEyWHXtQLS2xUp7MHFQOdBlJIQHrj uQf0UHzhNXiyw== From: Sasha Levin To: stable@vger.kernel.org Cc: Arun Iyengar , Maxime Chevallier , Jakub Kicinski , Sasha Levin Subject: [PATCH 6.6.y] net: stmmac: drop the rest of the frame when napi_build_skb() fails Date: Fri, 4 Dec 2026 07:45:44 -0500 Message-ID: <20261204124533.3071200-1-sashal@kernel.org> X-Mailer: git-send-email 2.53.0 In-Reply-To: <2026120213-mocha-handyman-a43d@gregkh> References: <2026120213-mocha-handyman-a43d@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: Context differs because this tree uses napi_alloc_skb() rather than napi_build_skb(), and with no next: label, goto next became count++; continue; in the !skb branch after drain_data. ] 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 052de50863bff..b7e1a4123d7b0 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c @@ -5509,7 +5509,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; } @@ -5547,8 +5547,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