From: "Levin, Alexander (Sasha Levin)" <alexander.levin@verizon.com>
To: "linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"stable@vger.kernel.org" <stable@vger.kernel.org>
Cc: Michal Kazior <michal.kazior@tieto.com>,
Kalle Valo <kvalo@qca.qualcomm.com>,
"Levin, Alexander (Sasha Levin)" <alexander.levin@verizon.com>
Subject: [PATCH for 4.9 48/59] ath10k: prevent sta pointer rcu violation
Date: Thu, 14 Sep 2017 15:51:18 +0000 [thread overview]
Message-ID: <20170914155051.8289-48-alexander.levin@verizon.com> (raw)
In-Reply-To: <20170914155051.8289-1-alexander.levin@verizon.com>
From: Michal Kazior <michal.kazior@tieto.com>
[ Upstream commit 0a744d927406389e00687560d9ce3c5ab0e58db9 ]
Station pointers are RCU protected so driver must
be extra careful if it tries to store them
internally for later use outside of the RCU
section it obtained it in.
It was possible for station teardown to race with
some htt events. The possible outcome could be a
use-after-free and a crash.
Only peer-flow-control capable firmware was
affected (so hardware-wise qca99x0 and qca4019).
This could be done in sta_state() itself via
explicit synchronize_net() call but there's
already a convenient sta_pre_rcu_remove() op that
can be hooked up to avoid extra rcu stall.
The peer->sta pointer itself can't be set to
NULL/ERR_PTR because it is later used in
sta_state() for extra sanity checks.
Signed-off-by: Michal Kazior <michal.kazior@tieto.com>
Signed-off-by: Kalle Valo <kvalo@qca.qualcomm.com>
Signed-off-by: Sasha Levin <alexander.levin@verizon.com>
---
drivers/net/wireless/ath/ath10k/core.h | 1 +
drivers/net/wireless/ath/ath10k/mac.c | 18 ++++++++++++++++++
2 files changed, 19 insertions(+)
diff --git a/drivers/net/wireless/ath/ath10k/core.h b/drivers/net/wireless/ath/ath10k/core.h
index be5b527472f9..90c0c4a7175d 100644
--- a/drivers/net/wireless/ath/ath10k/core.h
+++ b/drivers/net/wireless/ath/ath10k/core.h
@@ -314,6 +314,7 @@ struct ath10k_peer {
struct ieee80211_vif *vif;
struct ieee80211_sta *sta;
+ bool removed;
int vdev_id;
u8 addr[ETH_ALEN];
DECLARE_BITMAP(peer_ids, ATH10K_MAX_NUM_PEER_IDS);
diff --git a/drivers/net/wireless/ath/ath10k/mac.c b/drivers/net/wireless/ath/ath10k/mac.c
index f2e85eb22afe..30e98afa2e68 100644
--- a/drivers/net/wireless/ath/ath10k/mac.c
+++ b/drivers/net/wireless/ath/ath10k/mac.c
@@ -3738,6 +3738,9 @@ struct ieee80211_txq *ath10k_mac_txq_lookup(struct ath10k *ar,
if (!peer)
return NULL;
+ if (peer->removed)
+ return NULL;
+
if (peer->sta)
return peer->sta->txq[tid];
else if (peer->vif)
@@ -7422,6 +7425,20 @@ ath10k_mac_op_switch_vif_chanctx(struct ieee80211_hw *hw,
return 0;
}
+static void ath10k_mac_op_sta_pre_rcu_remove(struct ieee80211_hw *hw,
+ struct ieee80211_vif *vif,
+ struct ieee80211_sta *sta)
+{
+ struct ath10k *ar;
+ struct ath10k_peer *peer;
+
+ ar = hw->priv;
+
+ list_for_each_entry(peer, &ar->peers, list)
+ if (peer->sta == sta)
+ peer->removed = true;
+}
+
static const struct ieee80211_ops ath10k_ops = {
.tx = ath10k_mac_op_tx,
.wake_tx_queue = ath10k_mac_op_wake_tx_queue,
@@ -7462,6 +7479,7 @@ static const struct ieee80211_ops ath10k_ops = {
.assign_vif_chanctx = ath10k_mac_op_assign_vif_chanctx,
.unassign_vif_chanctx = ath10k_mac_op_unassign_vif_chanctx,
.switch_vif_chanctx = ath10k_mac_op_switch_vif_chanctx,
+ .sta_pre_rcu_remove = ath10k_mac_op_sta_pre_rcu_remove,
CFG80211_TESTMODE_CMD(ath10k_tm_cmd)
--
2.11.0
next prev parent reply other threads:[~2017-09-14 15:59 UTC|newest]
Thread overview: 69+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-09-14 15:51 [PATCH for 4.9 01/59] drm_fourcc: Fix DRM_FORMAT_MOD_LINEAR #define Levin, Alexander (Sasha Levin)
2017-09-14 15:51 ` [PATCH for 4.9 02/59] drm: bridge: add DT bindings for TI ths8135 Levin, Alexander (Sasha Levin)
2017-09-14 15:51 ` [PATCH for 4.9 03/59] GFS2: Fix reference to ERR_PTR in gfs2_glock_iter_next Levin, Alexander (Sasha Levin)
2017-09-14 15:51 ` [PATCH for 4.9 04/59] drm/i915: Fix the overlay frontbuffer tracking Levin, Alexander (Sasha Levin)
2017-09-14 15:51 ` [PATCH for 4.9 07/59] clk: sunxi-ng: set the parent rate when adjustin CPUX clock on A33 Levin, Alexander (Sasha Levin)
2017-09-15 2:02 ` icenowy
2017-09-15 2:08 ` Levin, Alexander (Sasha Levin)
2017-09-14 15:51 ` [PATCH for 4.9 05/59] ARM: dts: exynos: Add CPU OPPs for Exynos4412 Prime Levin, Alexander (Sasha Levin)
2017-09-14 15:51 ` [PATCH for 4.9 06/59] clk: sunxi-ng: fix PLL_CPUX adjusting on H3 Levin, Alexander (Sasha Levin)
2017-09-14 15:51 ` [PATCH for 4.9 11/59] MIPS: fix mem=X@Y commandline processing Levin, Alexander (Sasha Levin)
2017-09-14 18:59 ` Mathieu Malaterre
2017-09-14 19:11 ` Levin, Alexander (Sasha Levin)
2017-09-14 19:17 ` Mathieu Malaterre
2017-09-15 5:44 ` Marcin Nowakowski
2017-09-15 17:03 ` Paul Burton
2017-09-14 15:51 ` [PATCH for 4.9 08/59] RDS: RDMA: Fix the composite message user notification Levin, Alexander (Sasha Levin)
2017-09-14 15:51 ` [PATCH for 4.9 10/59] MIPS: Ensure bss section ends on a long-aligned address Levin, Alexander (Sasha Levin)
2017-09-14 15:51 ` [PATCH for 4.9 09/59] ARM: dts: r8a7790: Use R-Car Gen 2 fallback binding for msiof nodes Levin, Alexander (Sasha Levin)
2017-09-14 15:51 ` [PATCH for 4.9 15/59] power: supply: axp288_fuel_gauge: Fix fuel_gauge_reg_readb return on error Levin, Alexander (Sasha Levin)
2017-09-14 15:51 ` [PATCH for 4.9 13/59] MIPS: ralink: Fix a typo in the pinmux setup Levin, Alexander (Sasha Levin)
2017-09-14 15:51 ` [PATCH for 4.9 12/59] MIPS: kexec: Do not reserve invalid crashkernel memory on boot Levin, Alexander (Sasha Levin)
2017-09-14 15:51 ` [PATCH for 4.9 14/59] MIPS: ralink: Fix incorrect assignment on ralink_soc Levin, Alexander (Sasha Levin)
2017-09-14 15:51 ` [PATCH for 4.9 16/59] scsi: be2iscsi: Add checks to validate CID alloc/free Levin, Alexander (Sasha Levin)
2017-09-14 15:51 ` [PATCH for 4.9 17/59] ARM: dts: am335x-chilisom: Wakeup from RTC-only state by power on event Levin, Alexander (Sasha Levin)
2017-09-14 15:51 ` [PATCH for 4.9 19/59] extcon: axp288: Use vbus-valid instead of -present to determine cable presence Levin, Alexander (Sasha Levin)
2017-09-14 15:51 ` [PATCH for 4.9 18/59] igb: re-assign hw address pointer on reset after PCI error Levin, Alexander (Sasha Levin)
2017-09-14 15:51 ` [PATCH for 4.9 21/59] sh_eth: use correct name for ECMR_MPDE bit Levin, Alexander (Sasha Levin)
2017-09-14 15:51 ` [PATCH for 4.9 20/59] reset: ti_syscon: fix a ti_syscon_reset_status issue Levin, Alexander (Sasha Levin)
2017-09-14 15:51 ` [PATCH for 4.9 22/59] clk/axs10x: Clear init field in driver probe Levin, Alexander (Sasha Levin)
2017-09-14 15:51 ` [PATCH for 4.9 23/59] clk: wm831x: fix usleep_range with bad range Levin, Alexander (Sasha Levin)
2017-09-14 15:51 ` [PATCH for 4.9 24/59] usb: make the MTK XHCI driver compile for older MIPS SoCs Levin, Alexander (Sasha Levin)
2017-09-14 15:51 ` [PATCH for 4.9 25/59] hwmon: (gl520sm) Fix overflows and crash seen when writing into limit attributes Levin, Alexander (Sasha Levin)
2017-09-14 15:51 ` [PATCH for 4.9 29/59] IB/rxe: Add a runtime check in alloc_index() Levin, Alexander (Sasha Levin)
2017-09-14 15:51 ` [PATCH for 4.9 26/59] iio: adc: imx25-gcq: Fix module autoload Levin, Alexander (Sasha Levin)
2017-09-14 15:51 ` [PATCH for 4.9 28/59] iio: adc: hx711: Add DT binding for avia,hx711 Levin, Alexander (Sasha Levin)
2017-09-14 15:51 ` [PATCH for 4.9 27/59] iio: adc: axp288: Drop bogus AXP288_ADC_TS_PIN_CTRL register modifications Levin, Alexander (Sasha Levin)
2017-09-14 15:51 ` [PATCH for 4.9 32/59] drm/i915/psr: disable psr2 for resolution greater than 32X20 Levin, Alexander (Sasha Levin)
2017-09-14 15:51 ` [PATCH for 4.9 33/59] serial: 8250: moxa: Store num_ports in brd Levin, Alexander (Sasha Levin)
2017-09-14 15:51 ` [PATCH for 4.9 30/59] IB/rxe: Fix a MR reference leak in check_rkey() Levin, Alexander (Sasha Levin)
2017-09-14 15:51 ` [PATCH for 4.9 31/59] ARM: 8635/1: nommu: allow enabling REMAP_VECTORS_TO_RAM Levin, Alexander (Sasha Levin)
2017-09-14 15:51 ` [PATCH for 4.9 34/59] tty: goldfish: Fix a parameter of a call to free_irq Levin, Alexander (Sasha Levin)
2017-09-14 15:51 ` [PATCH for 4.9 35/59] serial: 8250_port: Remove dangerous pr_debug() Levin, Alexander (Sasha Levin)
2017-09-14 15:51 ` [PATCH for 4.9 36/59] IB/ipoib: Fix deadlock over vlan_mutex Levin, Alexander (Sasha Levin)
2017-09-14 15:51 ` [PATCH for 4.9 37/59] IB/ipoib: rtnl_unlock can not come after free_netdev Levin, Alexander (Sasha Levin)
2017-09-14 15:51 ` [PATCH for 4.9 41/59] USB: serial: mos7720: fix control-message error handling Levin, Alexander (Sasha Levin)
2017-09-14 15:51 ` [PATCH for 4.9 40/59] drm/amdkfd: fix improper return value on error Levin, Alexander (Sasha Levin)
2017-09-14 15:51 ` [PATCH for 4.9 38/59] IB/ipoib: Replace list_del of the neigh->list with list_del_init Levin, Alexander (Sasha Levin)
2017-09-14 15:51 ` [PATCH for 4.9 39/59] arm: dts: mt2701: Add subsystem clock controller device nodes Levin, Alexander (Sasha Levin)
2017-09-15 11:15 ` Matthias Brugger
2017-09-17 23:20 ` Levin, Alexander (Sasha Levin)
2017-09-18 10:28 ` Matthias Brugger
2017-09-14 15:51 ` [PATCH for 4.9 45/59] partitions/efi: Fix integer overflow in GPT size calculation Levin, Alexander (Sasha Levin)
2017-09-14 15:51 ` [PATCH for 4.9 43/59] sfc: get PIO buffer size from the NIC Levin, Alexander (Sasha Levin)
2017-09-14 15:51 ` [PATCH for 4.9 44/59] pinctrl: mvebu: Use seq_puts() in mvebu_pinconf_group_dbg_show() Levin, Alexander (Sasha Levin)
2017-09-14 15:51 ` [PATCH for 4.9 42/59] USB: serial: mos7840: fix control-message error handling Levin, Alexander (Sasha Levin)
2017-09-14 15:51 ` [PATCH for 4.9 46/59] ASoC: dapm: handle probe deferrals Levin, Alexander (Sasha Levin)
2017-09-14 15:51 ` [PATCH for 4.9 47/59] audit: log 32-bit socketcalls Levin, Alexander (Sasha Levin)
2017-09-14 15:51 ` [PATCH for 4.9 49/59] spi: pxa2xx: Add support for Intel Gemini Lake Levin, Alexander (Sasha Levin)
2017-09-14 15:51 ` Levin, Alexander (Sasha Levin) [this message]
2017-09-14 15:51 ` [PATCH for 4.9 52/59] rtl8xxxu: Add additional USB IDs for rtl8192eu devices Levin, Alexander (Sasha Levin)
2017-09-14 15:51 ` [PATCH for 4.9 50/59] iommu/arm-smmu: Set privileged attribute to 'default' instead of 'unprivileged' Levin, Alexander (Sasha Levin)
2017-09-14 15:51 ` [PATCH for 4.9 53/59] ASoC: dapm: fix some pointer error handling Levin, Alexander (Sasha Levin)
2017-09-14 15:51 ` [PATCH for 4.9 51/59] usb: chipidea: vbus event may exist before starting gadget Levin, Alexander (Sasha Levin)
2017-09-14 15:51 ` [PATCH for 4.9 54/59] drm: mali-dp: Fix destination size handling when rotating Levin, Alexander (Sasha Levin)
2017-09-14 15:51 ` [PATCH for 4.9 57/59] MIPS: Lantiq: Fix another request_mem_region() return code check Levin, Alexander (Sasha Levin)
2017-09-14 15:51 ` [PATCH for 4.9 56/59] HID: wacom: release the resources before leaving despite devm Levin, Alexander (Sasha Levin)
2017-09-14 15:51 ` [PATCH for 4.9 55/59] drm: mali-dp: Fix transposed horizontal/vertical flip Levin, Alexander (Sasha Levin)
2017-09-14 15:51 ` [PATCH for 4.9 58/59] mips: ath79: clock:- Unmap region obtained by of_iomap Levin, Alexander (Sasha Levin)
2017-09-14 15:51 ` [PATCH for 4.9 59/59] lkdtm: Fix Oops when unloading the module Levin, Alexander (Sasha Levin)
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=20170914155051.8289-48-alexander.levin@verizon.com \
--to=alexander.levin@verizon.com \
--cc=kvalo@qca.qualcomm.com \
--cc=linux-kernel@vger.kernel.org \
--cc=michal.kazior@tieto.com \
--cc=stable@vger.kernel.org \
/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
all inboxes | Powered by JetHome®