Commit 5aac9108 authored by Shyam Sundar S K's avatar Shyam Sundar S K Committed by Jakub Kicinski

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: 622c36f1 ("amd-xgbe: Fix jumbo MTU processing on newer hardware")
Suggested-by: default avatarTom Lendacky <thomas.lendacky@amd.com>
Signed-off-by: default avatarShyam Sundar S K <Shyam-sundar.S-k@amd.com>
Acked-by: default avatarTom Lendacky <thomas.lendacky@amd.com>
Link: https://lore.kernel.org/r/20220127092003.2812745-1-Shyam-sundar.S-k@amd.comSigned-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parent 23a46422
...@@ -2550,6 +2550,14 @@ static int xgbe_rx_poll(struct xgbe_channel *channel, int budget) ...@@ -2550,6 +2550,14 @@ static int xgbe_rx_poll(struct xgbe_channel *channel, int budget)
buf2_len = xgbe_rx_buf2_len(rdata, packet, len); buf2_len = xgbe_rx_buf2_len(rdata, packet, len);
len += buf2_len; len += buf2_len;
if (buf2_len > rdata->rx.buf.dma_len) {
/* Hardware inconsistency within the descriptors
* that has resulted in a length underflow.
*/
error = 1;
goto skip_data;
}
if (!skb) { if (!skb) {
skb = xgbe_create_skb(pdata, napi, rdata, skb = xgbe_create_skb(pdata, napi, rdata,
buf1_len); buf1_len);
...@@ -2579,8 +2587,10 @@ static int xgbe_rx_poll(struct xgbe_channel *channel, int budget) ...@@ -2579,8 +2587,10 @@ static int xgbe_rx_poll(struct xgbe_channel *channel, int budget)
if (!last || context_next) if (!last || context_next)
goto read_again; goto read_again;
if (!skb) if (!skb || error) {
dev_kfree_skb(skb);
goto next_packet; goto next_packet;
}
/* Be sure we don't exceed the configured MTU */ /* Be sure we don't exceed the configured MTU */
max_len = netdev->mtu + ETH_HLEN; max_len = netdev->mtu + ETH_HLEN;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment