]> git.baikalelectronics.ru Git - kernel.git/commitdiff
staging: rtl8192e: Fix potential use-after-free in rtllib_rx_Monitor()
authorYueHaibing <yuehaibing@huawei.com>
Wed, 23 Nov 2022 08:12:53 +0000 (16:12 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 18 Jan 2023 10:41:25 +0000 (11:41 +0100)
[ Upstream commit d30f4436f364b4ad915ca2c09be07cd0f93ceb44 ]

The skb is delivered to netif_rx() in rtllib_monitor_rx(), which may free it,
after calling this, dereferencing skb may trigger use-after-free.
Found by Smatch.

Fixes: cc5d857430c2 ("From: wlanfae <wlanfae@realtek.com> [PATCH 1/8] rtl8192e: Import new version of driver from realtek")
Signed-off-by: YueHaibing <yuehaibing@huawei.com>
Link: https://lore.kernel.org/r/20221123081253.22296-1-yuehaibing@huawei.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/staging/rtl8192e/rtllib_rx.c

index 83c30e2d82f5f2bd438a5aff3f887576eba725d0..a78f914082fe5041dc2742a3bcfb6043381d2cc6 100644 (file)
@@ -1490,9 +1490,9 @@ static int rtllib_rx_Monitor(struct rtllib_device *ieee, struct sk_buff *skb,
                hdrlen += 4;
        }
 
-       rtllib_monitor_rx(ieee, skb, rx_stats, hdrlen);
        ieee->stats.rx_packets++;
        ieee->stats.rx_bytes += skb->len;
+       rtllib_monitor_rx(ieee, skb, rx_stats, hdrlen);
 
        return 1;
 }