2022-11-23 10:27:37

by Yue Haibing

[permalink] [raw]
Subject: [PATCH] staging: rtl8192e: Fix potential use-after-free in rtllib_rx_Monitor()

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: 94a799425eee ("From: wlanfae <[email protected]> [PATCH 1/8] rtl8192e: Import new version of driver from realtek")
Signed-off-by: YueHaibing <[email protected]>
---
drivers/staging/rtl8192e/rtllib_rx.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/rtl8192e/rtllib_rx.c b/drivers/staging/rtl8192e/rtllib_rx.c
index 6a0f5bbb99ef..f8965afab767 100644
--- a/drivers/staging/rtl8192e/rtllib_rx.c
+++ b/drivers/staging/rtl8192e/rtllib_rx.c
@@ -1489,9 +1489,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;
}
--
2.17.1


2022-11-23 22:00:59

by Philipp Hortmann

[permalink] [raw]
Subject: Re: [PATCH] staging: rtl8192e: Fix potential use-after-free in rtllib_rx_Monitor()

On 11/23/22 09:12, YueHaibing wrote:
> 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: 94a799425eee ("From: wlanfae <[email protected]> [PATCH 1/8] rtl8192e: Import new version of driver from realtek")
> Signed-off-by: YueHaibing <[email protected]>
> ---
> drivers/staging/rtl8192e/rtllib_rx.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/staging/rtl8192e/rtllib_rx.c b/drivers/staging/rtl8192e/rtllib_rx.c
> index 6a0f5bbb99ef..f8965afab767 100644
> --- a/drivers/staging/rtl8192e/rtllib_rx.c
> +++ b/drivers/staging/rtl8192e/rtllib_rx.c
> @@ -1489,9 +1489,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;
> }

I was able to set the driver to Monitor mode but I did not get any
information from it. I think this happens due to the missing support for
nl80211. Please give me a hint how to do this.

Thanks for your support.

Bye Philipp