public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: linux-kernel@vger.kernel.org
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	stable@vger.kernel.org,
	syzbot+f9acff9bf08a845f225d@syzkaller.appspotmail.com,
	Johannes Berg <johannes@sipsolutions.net>,
	Siddh Raman Pant <code@siddh.me>,
	Johannes Berg <johannes.berg@intel.com>,
	Sasha Levin <sashal@kernel.org>
Subject: [PATCH 4.19 24/58] wifi: mac80211: Fix UAF in ieee80211_scan_rx()
Date: Mon, 26 Sep 2022 12:11:43 +0200	[thread overview]
Message-ID: <20220926100742.330172253@linuxfoundation.org> (raw)
In-Reply-To: <20220926100741.430882406@linuxfoundation.org>

From: Siddh Raman Pant <code@siddh.me>

[ 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 <johannes@sipsolutions.net>
Signed-off-by: Siddh Raman Pant <code@siddh.me>
Link: https://lore.kernel.org/r/20220819200340.34826-1-code@siddh.me
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 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 de42bcfeda9c..e3d8be4feea5 100644
--- a/net/mac80211/scan.c
+++ b/net/mac80211/scan.c
@@ -412,10 +412,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,
@@ -425,6 +421,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




  parent reply	other threads:[~2022-09-26 10:30 UTC|newest]

Thread overview: 63+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-09-26 10:11 [PATCH 4.19 00/58] 4.19.260-rc1 review Greg Kroah-Hartman
2022-09-26 10:11 ` [PATCH 4.19 01/58] of: fdt: fix off-by-one error in unflatten_dt_nodes() Greg Kroah-Hartman
2022-09-26 10:11 ` [PATCH 4.19 02/58] gpio: mpc8xxx: Fix support for IRQ_TYPE_LEVEL_LOW flow_type in mpc85xx Greg Kroah-Hartman
2022-09-26 10:11 ` [PATCH 4.19 03/58] drm/meson: Correct OSD1 global alpha value Greg Kroah-Hartman
2022-09-26 10:11 ` [PATCH 4.19 04/58] parisc: ccio-dma: Add missing iounmap in error path in ccio_probe() Greg Kroah-Hartman
2022-09-26 10:11 ` [PATCH 4.19 05/58] efi/libstub: Disable Shadow Call Stack Greg Kroah-Hartman
2022-09-26 10:11 ` [PATCH 4.19 06/58] efi: libstub: Disable struct randomization Greg Kroah-Hartman
2022-09-26 10:11 ` [PATCH 4.19 07/58] nvmet: fix a use-after-free Greg Kroah-Hartman
2022-09-26 10:11 ` [PATCH 4.19 08/58] mvpp2: no need to check return value of debugfs_create functions Greg Kroah-Hartman
2022-09-26 10:11 ` [PATCH 4.19 09/58] cifs: dont send down the destination address to sendmsg for a SOCK_STREAM Greg Kroah-Hartman
2022-09-26 10:11 ` [PATCH 4.19 10/58] ASoC: nau8824: Fix semaphore unbalance at error paths Greg Kroah-Hartman
2022-09-26 10:11 ` [PATCH 4.19 11/58] regulator: pfuze100: Fix the global-out-of-bounds access in pfuze100_regulator_probe() Greg Kroah-Hartman
2022-09-26 10:11 ` [PATCH 4.19 12/58] rxrpc: Fix local destruction being repeated Greg Kroah-Hartman
2022-09-26 10:11 ` [PATCH 4.19 13/58] ALSA: hda/sigmatel: Keep power up while beep is enabled Greg Kroah-Hartman
2022-09-26 10:11 ` [PATCH 4.19 14/58] net: usb: qmi_wwan: add Quectel RM520N Greg Kroah-Hartman
2022-09-26 10:11 ` [PATCH 4.19 15/58] MIPS: OCTEON: irq: Fix octeon_irq_force_ciu_mapping() Greg Kroah-Hartman
2022-09-26 10:11 ` [PATCH 4.19 16/58] mksysmap: Fix the mismatch of L0 symbols in System.map Greg Kroah-Hartman
2022-09-26 10:11 ` [PATCH 4.19 17/58] video: fbdev: pxa3xx-gcu: Fix integer overflow in pxa3xx_gcu_write Greg Kroah-Hartman
2022-09-26 10:11 ` [PATCH 4.19 18/58] ALSA: hda/sigmatel: Fix unused variable warning for beep power change Greg Kroah-Hartman
2022-09-26 10:11 ` [PATCH 4.19 19/58] usb: dwc3: pci: Add Support for Intel Elkhart Lake Devices Greg Kroah-Hartman
2022-09-26 10:11 ` [PATCH 4.19 20/58] usb: dwc3: pci: add support for TigerLake Devices Greg Kroah-Hartman
2022-09-26 10:11 ` [PATCH 4.19 21/58] usb: dwc3: pci: add support for the Intel Tiger Lake PCH -H variant Greg Kroah-Hartman
2022-09-26 10:11 ` [PATCH 4.19 22/58] usb: dwc3: pci: add support for the Intel Jasper Lake Greg Kroah-Hartman
2022-09-26 10:11 ` [PATCH 4.19 23/58] usb: dwc3: pci: add support for the Intel Alder Lake-S Greg Kroah-Hartman
2022-09-26 10:11 ` Greg Kroah-Hartman [this message]
2022-09-26 10:11 ` [PATCH 4.19 25/58] USB: core: Fix RST error in hub.c Greg Kroah-Hartman
2022-09-26 10:11 ` [PATCH 4.19 26/58] USB: serial: option: add Quectel BG95 0x0203 composition Greg Kroah-Hartman
2022-09-26 10:11 ` [PATCH 4.19 27/58] USB: serial: option: add Quectel RM520N Greg Kroah-Hartman
2022-09-26 10:11 ` [PATCH 4.19 28/58] ALSA: hda/tegra: set depop delay for tegra Greg Kroah-Hartman
2022-09-26 10:11 ` [PATCH 4.19 29/58] ALSA: hda: add Intel 5 Series / 3400 PCI DID Greg Kroah-Hartman
2022-09-26 10:11 ` [PATCH 4.19 30/58] ALSA: hda/realtek: Enable 4-speaker output Dell Precision 5530 laptop Greg Kroah-Hartman
2022-09-26 10:11 ` [PATCH 4.19 31/58] efi: libstub: check Shim mode using MokSBStateRT Greg Kroah-Hartman
2022-09-26 10:11 ` [PATCH 4.19 32/58] riscv: fix a nasty sigreturn bug Greg Kroah-Hartman
2022-09-26 10:11 ` [PATCH 4.19 33/58] mm/slub: fix to return errno if kmalloc() fails Greg Kroah-Hartman
2022-09-26 10:11 ` [PATCH 4.19 34/58] arm64: dts: rockchip: Set RK3399-Gru PCLK_EDP to 24 MHz Greg Kroah-Hartman
2022-09-26 10:11 ` [PATCH 4.19 35/58] arm64: dts: rockchip: Remove enable-active-low from rk3399-puma Greg Kroah-Hartman
2022-09-26 10:11 ` [PATCH 4.19 36/58] netfilter: nf_conntrack_sip: fix ct_sip_walk_headers Greg Kroah-Hartman
2022-09-26 10:11 ` [PATCH 4.19 37/58] netfilter: nf_conntrack_irc: Tighten matching on DCC message Greg Kroah-Hartman
2022-09-26 10:11 ` [PATCH 4.19 38/58] iavf: Fix cached head and tail value for iavf_get_tx_pending Greg Kroah-Hartman
2022-09-26 10:11 ` [PATCH 4.19 39/58] ipvlan: Fix out-of-bound bugs caused by unset skb->mac_header Greg Kroah-Hartman
2022-09-26 10:11 ` [PATCH 4.19 40/58] net: team: Unsync device addresses on ndo_stop Greg Kroah-Hartman
2022-09-26 10:12 ` [PATCH 4.19 41/58] MIPS: lantiq: export clk_get_io() for lantiq_wdt.ko Greg Kroah-Hartman
2022-09-26 10:12 ` [PATCH 4.19 42/58] i40e: Fix VF set max MTU size Greg Kroah-Hartman
2022-09-26 10:12 ` [PATCH 4.19 43/58] i40e: Fix set max_tx_rate when it is lower than 1 Mbps Greg Kroah-Hartman
2022-09-26 10:12 ` [PATCH 4.19 44/58] of: mdio: Add of_node_put() when breaking out of for_each_xx Greg Kroah-Hartman
2022-09-26 10:12 ` [PATCH 4.19 45/58] netfilter: ebtables: fix memory leak when blob is malformed Greg Kroah-Hartman
2022-09-26 10:12 ` [PATCH 4.19 46/58] can: gs_usb: gs_can_open(): fix race dev->can.state condition Greg Kroah-Hartman
2022-09-26 10:12 ` [PATCH 4.19 47/58] perf jit: Include program header in ELF files Greg Kroah-Hartman
2022-09-26 10:12 ` [PATCH 4.19 48/58] perf kcore_copy: Do not check /proc/modules is unchanged Greg Kroah-Hartman
2022-09-26 10:12 ` [PATCH 4.19 49/58] net: sunhme: Fix packet reception for len < RX_COPY_THRESHOLD Greg Kroah-Hartman
2022-09-26 10:12 ` [PATCH 4.19 50/58] serial: Create uart_xmit_advance() Greg Kroah-Hartman
2022-09-26 10:12 ` [PATCH 4.19 51/58] serial: tegra: Use uart_xmit_advance(), fixes icount.tx accounting Greg Kroah-Hartman
2022-09-26 10:12 ` [PATCH 4.19 52/58] s390/dasd: fix Oops in dasd_alias_get_start_dev due to missing pavgroup Greg Kroah-Hartman
2022-09-26 10:12 ` [PATCH 4.19 53/58] Drivers: hv: Never allocate anything besides framebuffer from framebuffer memory region Greg Kroah-Hartman
2022-09-26 10:12 ` [PATCH 4.19 54/58] drm/amd/display: Limit user regamma to a valid value Greg Kroah-Hartman
2022-09-26 10:12 ` [PATCH 4.19 55/58] drm/rockchip: Fix return type of cdn_dp_connector_mode_valid Greg Kroah-Hartman
2022-09-26 10:12 ` [PATCH 4.19 56/58] workqueue: dont skip lockdep work dependency in cancel_work_sync() Greg Kroah-Hartman
2022-09-26 10:12 ` [PATCH 4.19 57/58] ext4: make directory inode spreading reflect flexbg size Greg Kroah-Hartman
2022-09-26 10:12 ` [PATCH 4.19 58/58] usb: dwc3: pci: Allow Elkhart Lake to utilize DSM method for PM functionality Greg Kroah-Hartman
2022-09-26 13:36 ` [PATCH 4.19 00/58] 4.19.260-rc1 review Pavel Machek
2022-09-26 13:40 ` Guenter Roeck
2022-09-26 16:20   ` Greg Kroah-Hartman
2022-09-27  0:59 ` Shuah Khan

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220926100742.330172253@linuxfoundation.org \
    --to=gregkh@linuxfoundation.org \
    --cc=code@siddh.me \
    --cc=johannes.berg@intel.com \
    --cc=johannes@sipsolutions.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=sashal@kernel.org \
    --cc=stable@vger.kernel.org \
    --cc=syzbot+f9acff9bf08a845f225d@syzkaller.appspotmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox