Skip to contentSkip to conversation

cfg80211: fix NULL ptr deref

PATCH In review Johannes Berg 2 participants 4 messages Oct 31, 2009 802.11 (including cfg80211/NL80211)

lore
Share & tools
lore

Johannes Berg

author maintainer
#0 lore raw

PATCH 1/1 cfg80211: fix NULL ptr deref

commit 211a4d12abf86fe0df4cd68fc6327cbb58f56f81
Author: Johannes Berg <[email protected]>
Date: Tue Oct 20 15:08:53 2009 +0900

cfg80211: sme: deauthenticate on assoc failure

introduced a potential NULL pointer dereference that some people have been hitting for some reason -- the params.bssid pointer is not guaranteed to be non-NULL for what seems to be a race between various ways of reaching the same thing.

While I'm trying to analyse the problem more let's first fix the crash. I think the real fix may be to avoid doing _anything_ if it ended up being NULL, but right now I'm not sure yet.

I think
http://bugzilla.kernel.org/show_bug.cgi?id=14342
might also be this issue.

---
 net/wireless/sme.c |    7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)
net/wireless/sme.c +5 -2
@@ -165,7 +165,7 @@ void cfg80211_conn_work(struct work_stru
 	struct cfg80211_registered_device *rdev =
 		container_of(work, struct cfg80211_registered_device, conn_work);
 	struct wireless_dev *wdev;
-	u8 bssid[ETH_ALEN];
+	u8 bssid_buf[ETH_ALEN], *bssid = NULL;
 
 	rtnl_lock();
 	cfg80211_lock_rdev(rdev);
@@ -181,7 +181,10 @@ void cfg80211_conn_work(struct work_stru
 			wdev_unlock(wdev);
 			continue;
 		}
-		memcpy(bssid, wdev->conn->params.bssid, ETH_ALEN);
+		if (wdev->conn->params.bssid) {
+			memcpy(bssid_buf, wdev->conn->params.bssid, ETH_ALEN);
+			bssid = bssid_buf;
+		}
 		if (cfg80211_conn_do_work(wdev))
 			__cfg80211_connect_result(
 					wdev->netdev, bssid,
#1 lore raw
Quoted 17 lines · Johannes Berg

 commit 211a4d12abf86fe0df4cd68fc6327cbb58f56f81
 Author: Johannes Berg <[email protected]>
 Date:   Tue Oct 20 15:08:53 2009 +0900

     cfg80211: sme: deauthenticate on assoc failure

introduced a potential NULL pointer dereference that some people have been hitting for some reason -- the params.bssid pointer is not guaranteed to be non-NULL for what seems to be a race between various ways of reaching the same thing.

While I'm trying to analyse the problem more let's first fix the crash. I think the real fix may be to avoid doing _anything_ if it ended up being NULL, but right now I'm not sure yet.

Quoted 7 lines

I think
http://bugzilla.kernel.org/show_bug.cgi?id=14342
might also be this issue.

Do we know if this will also affect 2.6.32?

Luis

author maintainer
#2 lore raw
Quoted 23 lines · Luis R. Rodriguez
Quoted 21 lines · Johannes Berg

commit 211a4d12abf86fe0df4cd68fc6327cbb58f56f81
Author: Johannes Berg <[email protected]>
Date: Tue Oct 20 15:08:53 2009 +0900

cfg80211: sme: deauthenticate on assoc failure

introduced a potential NULL pointer dereference that some people have been hitting for some reason -- the params.bssid pointer is not guaranteed to be non-NULL for what seems to be a race between various ways of reaching the same thing.

While I'm trying to analyse the problem more let's first fix the crash. I think the real fix may be to avoid doing _anything_ if it ended up being NULL, but right now I'm not sure yet.

I think
http://bugzilla.kernel.org/show_bug.cgi?id=14342
might also be this issue.

Quoted 5 lines
Quoted 3 lines

Do we know if this will also affect 2.6.32?

I'm pretty sure -- have we got any changes to this code that are not in .32?

johannes

#3 lore raw
Quoted 24 lines · Johannes Berg
Quoted 23 lines · Luis R. Rodriguez
Quoted 21 lines · Johannes Berg

 commit 211a4d12abf86fe0df4cd68fc6327cbb58f56f81
 Author: Johannes Berg <[email protected]>
 Date:   Tue Oct 20 15:08:53 2009 +0900

     cfg80211: sme: deauthenticate on assoc failure

introduced a potential NULL pointer dereference that some people have been hitting for some reason -- the params.bssid pointer is not guaranteed to be non-NULL for what seems to be a race between various ways of reaching the same thing.

While I'm trying to analyse the problem more let's first fix the crash. I think the real fix may be to avoid doing _anything_ if it ended up being NULL, but right now I'm not sure yet.

I think
http://bugzilla.kernel.org/show_bug.cgi?id=14342
might also be this issue.

Quoted 8 lines
Quoted 5 lines
Quoted 3 lines

Do we know if this will also affect 2.6.32?

I'm pretty sure -- have we got any changes to this code that are not in .32?

Not sure, I just wanted to make sure we fix .32 as well, that's all.

Luis