Skip to content

Commit 5aac910

Browse files
Shyam Sundar S Kkuba-moo
authored andcommitted
net: amd-xgbe: Fix skb data length underflow
There will be BUG_ON() triggered in include/linux/skbuff.h leading to intermittent kernel panic, when the skb length underflow is detected. Fix this by dropping the packet if such length underflows are seen because of inconsistencies in the hardware descriptors. Fixes: 622c36f ("amd-xgbe: Fix jumbo MTU processing on newer hardware") Suggested-by: Tom Lendacky <thomas.lendacky@amd.com> Signed-off-by: Shyam Sundar S K <Shyam-sundar.S-k@amd.com> Acked-by: Tom Lendacky <thomas.lendacky@amd.com> Link: https://lore.kernel.org/r/20220127092003.2812745-1-Shyam-sundar.S-k@amd.com Signed-off-by: Jakub Kicinski <kuba@kernel.org>
1 parent 23a4642 commit 5aac910

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

drivers/net/ethernet/amd/xgbe/xgbe-drv.c

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2550,6 +2550,14 @@ static int xgbe_rx_poll(struct xgbe_channel *channel, int budget)
25502550
buf2_len = xgbe_rx_buf2_len(rdata, packet, len);
25512551
len += buf2_len;
25522552

2553+
if (buf2_len > rdata->rx.buf.dma_len) {
2554+
/* Hardware inconsistency within the descriptors
2555+
* that has resulted in a length underflow.
2556+
*/
2557+
error = 1;
2558+
goto skip_data;
2559+
}
2560+
25532561
if (!skb) {
25542562
skb = xgbe_create_skb(pdata, napi, rdata,
25552563
buf1_len);
@@ -2579,8 +2587,10 @@ static int xgbe_rx_poll(struct xgbe_channel *channel, int budget)
25792587
if (!last || context_next)
25802588
goto read_again;
25812589

2582-
if (!skb)
2590+
if (!skb || error) {
2591+
dev_kfree_skb(skb);
25832592
goto next_packet;
2593+
}
25842594

25852595
/* Be sure we don't exceed the configured MTU */
25862596
max_len = netdev->mtu + ETH_HLEN;

0 commit comments

Comments
 (0)