]> git.baikalelectronics.ru Git - kernel.git/commitdiff
net: lantiq_xrx200: fix use after free bug
authorAleksander Jan Bajkowski <olek2@wp.pl>
Sat, 5 Mar 2022 11:20:39 +0000 (12:20 +0100)
committerDavid S. Miller <davem@davemloft.net>
Mon, 7 Mar 2022 11:29:35 +0000 (11:29 +0000)
The skb->len field is read after the packet is sent to the network
stack. In the meantime, skb can be freed. This patch fixes this bug.

Fixes: d09d5a37c22b ("net: lantiq_xrx200: add ingress SG DMA support")
Reported-by: Eric Dumazet <eric.dumazet@gmail.com>
Signed-off-by: Aleksander Jan Bajkowski <olek2@wp.pl>
Acked-by: Hauke Mehrtens <hauke@hauke-m.de>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/lantiq_xrx200.c

index 41d11137cde0c4ce397d29c920756a9e37034b25..5712c3e94be813eecb668d97be06385983e78a72 100644 (file)
@@ -260,9 +260,9 @@ static int xrx200_hw_receive(struct xrx200_chan *ch)
 
        if (ctl & LTQ_DMA_EOP) {
                ch->skb_head->protocol = eth_type_trans(ch->skb_head, net_dev);
-               netif_receive_skb(ch->skb_head);
                net_dev->stats.rx_packets++;
                net_dev->stats.rx_bytes += ch->skb_head->len;
+               netif_receive_skb(ch->skb_head);
                ch->skb_head = NULL;
                ch->skb_tail = NULL;
                ret = XRX200_DMA_PACKET_COMPLETE;