macsec: avoid use-after-free in macsec_handle_frame()
authorEric Dumazet <edumazet@google.com>
Wed, 7 Oct 2020 08:42:46 +0000 (01:42 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 14 Oct 2020 07:48:15 +0000 (09:48 +0200)
commit c7cc9200e9b4a2ac172e990ef1975cd42975dad6 upstream.

De-referencing skb after call to gro_cells_receive() is not allowed.
We need to fetch skb->len earlier.

Fixes: 5491e7c6b1a9 ("macsec: enable GRO and RPS on macsec devices")
Signed-off-by: Eric Dumazet <edumazet@google.com>
Cc: Paolo Abeni <pabeni@redhat.com>
Acked-by: Paolo Abeni <pabeni@redhat.com>
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/net/macsec.c

index 5defa29069ca31c0a05810f4bfe801be6a795b57..774b9db0c811f8063ce247329b563d921ea9af78 100644 (file)
@@ -1087,6 +1087,7 @@ static rx_handler_result_t macsec_handle_frame(struct sk_buff **pskb)
        struct macsec_rx_sa *rx_sa;
        struct macsec_rxh_data *rxd;
        struct macsec_dev *macsec;
+       unsigned int len;
        sci_t sci;
        u32 pn;
        bool cbit;
@@ -1242,9 +1243,10 @@ deliver:
        macsec_rxsc_put(rx_sc);
 
        skb_orphan(skb);
+       len = skb->len;
        ret = gro_cells_receive(&macsec->gro_cells, skb);
        if (ret == NET_RX_SUCCESS)
-               count_rx(dev, skb->len);
+               count_rx(dev, len);
        else
                macsec->secy.netdev->stats.rx_dropped++;