lantiq: copy Linux 5.10 files in preparation for Linux 5.15 support
[openwrt/staging/stintel.git] / target / linux / lantiq / patches-5.15 / 0716-v5.17-net-lantiq_xrx200-fix-use-after-free-bug.patch
1 From dd830aed23c6e07cd8e2a163742bf3d63c9add08 Mon Sep 17 00:00:00 2001
2 From: Aleksander Jan Bajkowski <olek2@wp.pl>
3 Date: Sat, 5 Mar 2022 12:20:39 +0100
4 Subject: net: lantiq_xrx200: fix use after free bug
5
6 The skb->len field is read after the packet is sent to the network
7 stack. In the meantime, skb can be freed. This patch fixes this bug.
8
9 Fixes: c3e6b2c35b34 ("net: lantiq_xrx200: add ingress SG DMA support")
10 Reported-by: Eric Dumazet <eric.dumazet@gmail.com>
11 Signed-off-by: Aleksander Jan Bajkowski <olek2@wp.pl>
12 Acked-by: Hauke Mehrtens <hauke@hauke-m.de>
13 Signed-off-by: David S. Miller <davem@davemloft.net>
14 ---
15 drivers/net/ethernet/lantiq_xrx200.c | 2 +-
16 1 file changed, 1 insertion(+), 1 deletion(-)
17
18 --- a/drivers/net/ethernet/lantiq_xrx200.c
19 +++ b/drivers/net/ethernet/lantiq_xrx200.c
20 @@ -260,9 +260,9 @@ static int xrx200_hw_receive(struct xrx2
21
22 if (ctl & LTQ_DMA_EOP) {
23 ch->skb_head->protocol = eth_type_trans(ch->skb_head, net_dev);
24 - netif_receive_skb(ch->skb_head);
25 net_dev->stats.rx_packets++;
26 net_dev->stats.rx_bytes += ch->skb_head->len;
27 + netif_receive_skb(ch->skb_head);
28 ch->skb_head = NULL;
29 ch->skb_tail = NULL;
30 ret = XRX200_DMA_PACKET_COMPLETE;