* [PATCH v3] wifi: mac80211: Fix UAF in ieee80211_scan_rx()
@ 2022-08-19 20:03 ` Siddh Raman Pant via Linux-kernel-mentees
0 siblings, 0 replies; 2+ messages in thread
From: Siddh Raman Pant @ 2022-08-19 20:03 UTC (permalink / raw)
To: Johannes Berg, David S. Miller, Eric Dumazet, Jakub Kicinski,
Paolo Abeni
Cc: linux-wireless, netdev, linux-kernel, linux-kernel-mentees,
syzbot+f9acff9bf08a845f225d
ieee80211_scan_rx() tries to access scan_req->flags after a
null check, but a UAF is observed when the scan is completed
and __ieee80211_scan_completed() executes, which then calls
cfg80211_scan_done() leading to the freeing of scan_req.
Since scan_req is rcu_dereference()'d, prevent the racing in
__ieee80211_scan_completed() by ensuring that from mac80211's
POV it is no longer accessed from an RCU read critical section
before we call cfg80211_scan_done().
Bug report: https://syzkaller.appspot.com/bug?extid=f9acff9bf08a845f225d
Reported-by: syzbot+f9acff9bf08a845f225d@syzkaller.appspotmail.com
Suggested-by: Johannes Berg <johannes@sipsolutions.net>
Signed-off-by: Siddh Raman Pant <code@siddh.me>
---
Changes in v3:
Use Johannes Berg's suggestion as-it-is:
https://lore.kernel.org/netdev/18fd9b89d45aedc1504d0cbd299ffb289ae96438.camel@sipsolutions.net/
v2 is now obsolete since it was an incorrect way to go about things.
net/mac80211/scan.c | 11 +++++++----
1 file changed, 7 insertions(+), 4 deletions(-)
diff --git a/net/mac80211/scan.c b/net/mac80211/scan.c
index fa8ddf576bc1..c4f2aeb31da3 100644
--- a/net/mac80211/scan.c
+++ b/net/mac80211/scan.c
@@ -469,16 +469,19 @@ static void __ieee80211_scan_completed(struct ieee80211_hw *hw, bool aborted)
scan_req = rcu_dereference_protected(local->scan_req,
lockdep_is_held(&local->mtx));
- if (scan_req != local->int_scan_req) {
- local->scan_info.aborted = aborted;
- cfg80211_scan_done(scan_req, &local->scan_info);
- }
RCU_INIT_POINTER(local->scan_req, NULL);
RCU_INIT_POINTER(local->scan_sdata, NULL);
local->scanning = 0;
local->scan_chandef.chan = NULL;
+ synchronize_rcu();
+
+ if (scan_req != local->int_scan_req) {
+ local->scan_info.aborted = aborted;
+ cfg80211_scan_done(scan_req, &local->scan_info);
+ }
+
/* Set power back to normal operating levels. */
ieee80211_hw_config(local, 0);
--
2.35.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* [PATCH v3] wifi: mac80211: Fix UAF in ieee80211_scan_rx()
@ 2022-08-19 20:03 ` Siddh Raman Pant via Linux-kernel-mentees
0 siblings, 0 replies; 2+ messages in thread
From: Siddh Raman Pant via Linux-kernel-mentees @ 2022-08-19 20:03 UTC (permalink / raw)
To: Johannes Berg, David S. Miller, Eric Dumazet, Jakub Kicinski,
Paolo Abeni
Cc: netdev, linux-wireless, linux-kernel,
syzbot+f9acff9bf08a845f225d, linux-kernel-mentees
ieee80211_scan_rx() tries to access scan_req->flags after a
null check, but a UAF is observed when the scan is completed
and __ieee80211_scan_completed() executes, which then calls
cfg80211_scan_done() leading to the freeing of scan_req.
Since scan_req is rcu_dereference()'d, prevent the racing in
__ieee80211_scan_completed() by ensuring that from mac80211's
POV it is no longer accessed from an RCU read critical section
before we call cfg80211_scan_done().
Bug report: https://syzkaller.appspot.com/bug?extid=f9acff9bf08a845f225d
Reported-by: syzbot+f9acff9bf08a845f225d@syzkaller.appspotmail.com
Suggested-by: Johannes Berg <johannes@sipsolutions.net>
Signed-off-by: Siddh Raman Pant <code@siddh.me>
---
Changes in v3:
Use Johannes Berg's suggestion as-it-is:
https://lore.kernel.org/netdev/18fd9b89d45aedc1504d0cbd299ffb289ae96438.camel@sipsolutions.net/
v2 is now obsolete since it was an incorrect way to go about things.
net/mac80211/scan.c | 11 +++++++----
1 file changed, 7 insertions(+), 4 deletions(-)
diff --git a/net/mac80211/scan.c b/net/mac80211/scan.c
index fa8ddf576bc1..c4f2aeb31da3 100644
--- a/net/mac80211/scan.c
+++ b/net/mac80211/scan.c
@@ -469,16 +469,19 @@ static void __ieee80211_scan_completed(struct ieee80211_hw *hw, bool aborted)
scan_req = rcu_dereference_protected(local->scan_req,
lockdep_is_held(&local->mtx));
- if (scan_req != local->int_scan_req) {
- local->scan_info.aborted = aborted;
- cfg80211_scan_done(scan_req, &local->scan_info);
- }
RCU_INIT_POINTER(local->scan_req, NULL);
RCU_INIT_POINTER(local->scan_sdata, NULL);
local->scanning = 0;
local->scan_chandef.chan = NULL;
+ synchronize_rcu();
+
+ if (scan_req != local->int_scan_req) {
+ local->scan_info.aborted = aborted;
+ cfg80211_scan_done(scan_req, &local->scan_info);
+ }
+
/* Set power back to normal operating levels. */
ieee80211_hw_config(local, 0);
--
2.35.1
_______________________________________________
Linux-kernel-mentees mailing list
Linux-kernel-mentees@lists.linuxfoundation.org
https://lists.linuxfoundation.org/mailman/listinfo/linux-kernel-mentees
^ permalink raw reply related [flat|nested] 2+ messages in thread
end of thread, other threads:[~2022-08-19 20:06 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-08-19 20:03 [PATCH v3] wifi: mac80211: Fix UAF in ieee80211_scan_rx() Siddh Raman Pant
2022-08-19 20:03 ` Siddh Raman Pant via Linux-kernel-mentees
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.