Skip to contentSkip to conversation

hostap_80211_rx(): fix a use-after-free

RFC PATCH In review Adrian Bunk 2 participants 2 messages Nov 6, 2006

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

RFC PATCH 1/1 hostap_80211_rx(): fix a use-after-free

This patch fixes a use-after-free for "skb" spotted by the Coverity checker.

drivers/net/wireless/hostap/hostap_80211_rx.c renamed from drivers/net/wireless/hostap/hostap_80211_rx.c.old +2 -2
@@ -1004,10 +1004,10 @@ void hostap_80211_rx(struct net_device *
 			if (local->hostapd && local->apdev) {
 				/* Send IEEE 802.1X frames to the user
 				 * space daemon for processing */
-				prism2_rx_80211(local->apdev, skb, rx_stats,
-						PRISM2_RX_MGMT);
 				local->apdevstats.rx_packets++;
 				local->apdevstats.rx_bytes += skb->len;
+				prism2_rx_80211(local->apdev, skb, rx_stats,
+						PRISM2_RX_MGMT);
 				goto rx_exit;
 			}
 		} else if (!frame_authorized) {
#1 lore raw
Quoted 6 lines · Adrian Bunk

This patch fixes a use-after-free for "skb" spotted by the Coverity checker.

drivers/net/wireless/hostap/hostap_80211_rx.c void hostap_80211_rx(struct net_device * · line 1011

Quoted 10 lines
drivers/net/wireless/hostap/hostap_80211_rx.c renamed from drivers/net/wireless/hostap/hostap_80211_rx.c.old +2 -2
@@ -1004,10 +1004,10 @@ void hostap_80211_rx(struct net_device *
 			if (local->hostapd && local->apdev) {
 				/* Send IEEE 802.1X frames to the user
 				 * space daemon for processing */
-				prism2_rx_80211(local->apdev, skb, rx_stats,
-						PRISM2_RX_MGMT);
 				local->apdevstats.rx_packets++;
 				local->apdevstats.rx_bytes += skb->len;
+				prism2_rx_80211(local->apdev, skb, rx_stats,
+						PRISM2_RX_MGMT);
 				goto rx_exit;

Network drivers set rx_packets and rx_bytes after netif_rx. And last_rx, too. The trick seems to be to use pkt_len variable.