From: Sasha Levin Date: Fri, 23 Sep 2022 16:54:14 +0000 (-0400) Subject: Fixes for 4.9 X-Git-Tag: v4.9.330~94 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=5f07d90ea431c70fd2d59f868b27ca13b9e2ac66;p=thirdparty%2Fkernel%2Fstable-queue.git Fixes for 4.9 Signed-off-by: Sasha Levin --- diff --git a/queue-4.9/series b/queue-4.9/series index 07b4a3ea52b..49b7875186e 100644 --- a/queue-4.9/series +++ b/queue-4.9/series @@ -10,3 +10,4 @@ mips-lantiq-xway-fix-refcount-leak-bug-in-sysctrl.patch mips-pic32-pic32mzda-fix-refcount-leak-bugs.patch mips-lantiq-add-missing-of_node_put-in-irq.c.patch arm-mach-spear-add-missing-of_node_put-in-time.c.patch +wifi-mac80211-fix-uaf-in-ieee80211_scan_rx.patch diff --git a/queue-4.9/wifi-mac80211-fix-uaf-in-ieee80211_scan_rx.patch b/queue-4.9/wifi-mac80211-fix-uaf-in-ieee80211_scan_rx.patch new file mode 100644 index 00000000000..e4fecccc1e1 --- /dev/null +++ b/queue-4.9/wifi-mac80211-fix-uaf-in-ieee80211_scan_rx.patch @@ -0,0 +1,63 @@ +From 964052e29e113e6f529e9ff1824b739ed86518f6 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Sat, 20 Aug 2022 01:33:40 +0530 +Subject: wifi: mac80211: Fix UAF in ieee80211_scan_rx() + +From: Siddh Raman Pant + +[ Upstream commit 60deb9f10eec5c6a20252ed36238b55d8b614a2c ] + +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(). + +Cc: stable@vger.kernel.org +Link: https://syzkaller.appspot.com/bug?extid=f9acff9bf08a845f225d +Reported-by: syzbot+f9acff9bf08a845f225d@syzkaller.appspotmail.com +Suggested-by: Johannes Berg +Signed-off-by: Siddh Raman Pant +Link: https://lore.kernel.org/r/20220819200340.34826-1-code@siddh.me +Signed-off-by: Johannes Berg +Signed-off-by: Sasha Levin +--- + 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 701adcb9262e..a73c362a0182 100644 +--- a/net/mac80211/scan.c ++++ b/net/mac80211/scan.c +@@ -385,10 +385,6 @@ 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); + + scan_sdata = rcu_dereference_protected(local->scan_sdata, +@@ -398,6 +394,13 @@ static void __ieee80211_scan_completed(struct ieee80211_hw *hw, bool aborted) + 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 +