From: Sasha Levin <sashal@kernel.org>
To: linux-kernel@vger.kernel.org, stable@vger.kernel.org
Cc: Karthikeyan Periyasamy <periyasa@codeaurora.org>,
Kalle Valo <kvalo@codeaurora.org>,
Sasha Levin <sashal@kernel.org>,
ath10k@lists.infradead.org, linux-wireless@vger.kernel.org,
netdev@vger.kernel.org
Subject: [PATCH AUTOSEL 4.20 241/304] ath10k: fix kernel panic due to use after free
Date: Mon, 28 Jan 2019 10:42:38 -0500 [thread overview]
Message-ID: <20190128154341.47195-241-sashal@kernel.org> (raw)
In-Reply-To: <20190128154341.47195-1-sashal@kernel.org>
From: Karthikeyan Periyasamy <periyasa@codeaurora.org>
[ Upstream commit 553a7cca769d551f1317186760631487c47e23bf ]
This issue arise in a race condition between ath10k_sta_state() and
ath10k_htt_fetch_peer_stats(), explained in below scenario
Steps:
1. In ath10k_sta_state(), arsta->tx_stats get deallocated before peer deletion
when the station moves from IEEE80211_STA_NONE to IEEE80211_STA_NOTEXIST
state.
2. Meanwhile ath10k receive HTT_T2H_MSG_TYPE_PEER_STATS message.
In ath10k_htt_fetch_peer_stats(), arsta->tx_stats get accessed after
the peer validation check.
Since arsta->tx_stats get freed before the peer deletion [1].
ath10k_htt_fetch_peer_stats() ended up in "use after free" situation.
Fixed this issue by moving the arsta->tx_stats free handling after the
peer deletion. so that ath10k_htt_fetch_peer_stats() will not end up in
"use after free" situation.
Kernel Panic:
Unable to handle kernel NULL pointer dereference at virtual address 00000286
pgd = d8754000
[00000286] *pgd=00000000
Internal error: Oops: 5 [#1] PREEMPT SMP ARM
...
CPU: 0 PID: 6245 Comm: hostapd Not tainted
task: dc44cac0 ti: d4a38000 task.ti: d4a38000
PC is at kmem_cache_alloc+0x7c/0x114
LR is at ath10k_sta_state+0x190/0xd58 [ath10k_core]
pc : [<c02bdc50>] lr : [<bf916b78>] psr: 20000013
sp : d4a39b88 ip : 00000000 fp : 00000001
r10: 00000000 r9 : 1d3bc000 r8 : 00000dc0
r7 : 000080d0 r6 : d4a38000 r5 : dd401b00 r4 : 00000286
r3 : 00000000 r2 : d4a39ba0 r1 : 000080d0 r0 : dd401b00
Flags: nzCv IRQs on FIQs on Mode SVC_32 ISA ARM Segment user
Control: 10c5787d Table: 5a75406a DAC: 00000015
Process hostapd (pid: 6245, stack limit = 0xd4a38238)
Stack: (0xd4a39b88 to 0xd4a3a000)
...
[<c02bdc50>] (kmem_cache_alloc) from [<bf916b78>] (ath10k_sta_state+0x190/0xd58 [ath10k_core])
[<bf916b78>] (ath10k_sta_state [ath10k_core]) from [<bf870d4c>] (sta_info_insert_rcu+0x418/0x61c [mac80211])
[<bf870d4c>] (sta_info_insert_rcu [mac80211]) from [<bf88634c>] (ieee80211_add_station+0xf0/0x134 [mac80211])
[<bf88634c>] (ieee80211_add_station [mac80211]) from [<bf83f3c4>] (nl80211_new_station+0x330/0x36c [cfg80211])
[<bf83f3c4>] (nl80211_new_station [cfg80211]) from [<bf6c4040>] (extack_doit+0x2c/0x74 [compat])
[<bf6c4040>] (extack_doit [compat]) from [<c05c285c>] (genl_rcv_msg+0x274/0x30c)
[<c05c285c>] (genl_rcv_msg) from [<c05c1d98>] (netlink_rcv_skb+0x58/0xac)
[<c05c1d98>] (netlink_rcv_skb) from [<c05c25d4>] (genl_rcv+0x20/0x34)
[<c05c25d4>] (genl_rcv) from [<c05c1750>] (netlink_unicast+0x11c/0x204)
[<c05c1750>] (netlink_unicast) from [<c05c1be0>] (netlink_sendmsg+0x30c/0x370)
[<c05c1be0>] (netlink_sendmsg) from [<c0587e90>] (sock_sendmsg+0x70/0x84)
[<c0587e90>] (sock_sendmsg) from [<c058970c>] (___sys_sendmsg.part.3+0x188/0x228)
[<c058970c>] (___sys_sendmsg.part.3) from [<c058a594>] (__sys_sendmsg+0x4c/0x70)
[<c058a594>] (__sys_sendmsg) from [<c0208c80>] (ret_fast_syscall+0x0/0x44)
Code: ebfffec1 e1a04000 ea00001b e5953014 (e7940003)
ath10k_pci 0000:01:00.0: SWBA overrun on vdev 0, skipped old beacon
Hardware tested: QCA9984
Firmware tested: 10.4-3.6.0.1-00004
Fixes: a904417fc ("ath10k: add extended per sta tx statistics support")
Signed-off-by: Karthikeyan Periyasamy <periyasa@codeaurora.org>
Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
drivers/net/wireless/ath/ath10k/mac.c | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/drivers/net/wireless/ath/ath10k/mac.c b/drivers/net/wireless/ath/ath10k/mac.c
index b4764fee4751..6436dc229be5 100644
--- a/drivers/net/wireless/ath/ath10k/mac.c
+++ b/drivers/net/wireless/ath/ath10k/mac.c
@@ -6387,11 +6387,6 @@ static int ath10k_sta_state(struct ieee80211_hw *hw,
"mac vdev %d peer delete %pM sta %pK (sta gone)\n",
arvif->vdev_id, sta->addr, sta);
- if (ath10k_debug_is_extd_tx_stats_enabled(ar)) {
- kfree(arsta->tx_stats);
- arsta->tx_stats = NULL;
- }
-
if (sta->tdls) {
ret = ath10k_mac_tdls_peer_update(ar, arvif->vdev_id,
sta,
@@ -6431,6 +6426,11 @@ static int ath10k_sta_state(struct ieee80211_hw *hw,
}
spin_unlock_bh(&ar->data_lock);
+ if (ath10k_debug_is_extd_tx_stats_enabled(ar)) {
+ kfree(arsta->tx_stats);
+ arsta->tx_stats = NULL;
+ }
+
for (i = 0; i < ARRAY_SIZE(sta->txq); i++)
ath10k_mac_txq_unref(ar, sta->txq[i]);
--
2.19.1
next prev parent reply other threads:[~2019-01-28 15:55 UTC|newest]
Thread overview: 51+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20190128154341.47195-1-sashal@kernel.org>
2019-01-28 15:38 ` [PATCH AUTOSEL 4.20 015/304] wil6210: fix reset flow for Talyn-mb Sasha Levin
2019-01-28 15:38 ` [PATCH AUTOSEL 4.20 016/304] wil6210: fix memory leak in wil_find_tx_bcast_2 Sasha Levin
2019-01-28 15:38 ` [PATCH AUTOSEL 4.20 017/304] ath10k: assign 'n_cipher_suites' for WCN3990 Sasha Levin
2019-01-28 15:38 ` [PATCH AUTOSEL 4.20 018/304] ath9k: dynack: use authentication messages for 'late' ack Sasha Levin
2019-01-28 15:39 ` [PATCH AUTOSEL 4.20 030/304] bpftool: Improve handling of ENOENT on map dumps Sasha Levin
2019-01-28 15:39 ` [PATCH AUTOSEL 4.20 036/304] ptp: check gettime64 return code in PTP_SYS_OFFSET ioctl Sasha Levin
2019-01-28 15:39 ` [PATCH AUTOSEL 4.20 038/304] dpaa2-ptp: defer probe when portal allocation failed Sasha Levin
2019-01-28 15:39 ` [PATCH AUTOSEL 4.20 039/304] sctp: Fix SKB list traversal in sctp_intl_store_ordered() Sasha Levin
2019-01-28 15:39 ` [PATCH AUTOSEL 4.20 040/304] sctp: Fix SKB list traversal in sctp_intl_store_reasm() Sasha Levin
2019-01-28 15:39 ` [PATCH AUTOSEL 4.20 041/304] iwlwifi: fw: do not set sgi bits for HE connection Sasha Levin
2019-01-28 15:39 ` [PATCH AUTOSEL 4.20 048/304] i40e: suppress bogus error message Sasha Levin
2019-01-28 15:39 ` [PATCH AUTOSEL 4.20 049/304] i40e: prevent overlapping tx_timeout recover Sasha Levin
2019-01-28 15:39 ` [PATCH AUTOSEL 4.20 052/304] usbnet: smsc95xx: fix rx packet alignment Sasha Levin
2019-01-28 15:39 ` [PATCH AUTOSEL 4.20 057/304] bpf: libbpf: retry map creation without the name Sasha Levin
2019-01-28 15:39 ` [PATCH AUTOSEL 4.20 058/304] net/mlx5: EQ, Use the right place to store/read IRQ affinity hint Sasha Levin
2019-01-28 15:39 ` [PATCH AUTOSEL 4.20 076/304] ptp: Fix pass zero to ERR_PTR() in ptp_clock_register Sasha Levin
2019-01-28 15:40 ` [PATCH AUTOSEL 4.20 092/304] net: aquantia: return 'err' if set MPI_DEINIT state fails Sasha Levin
2019-01-28 15:40 ` [PATCH AUTOSEL 4.20 104/304] mt76x0: dfs: fix IBI_R11 configuration on non-radar channels Sasha Levin
2019-01-28 15:40 ` [PATCH AUTOSEL 4.20 105/304] mt76x0: use band parameter for LC calibration Sasha Levin
2019-01-28 15:40 ` [PATCH AUTOSEL 4.20 109/304] nfp: add locking around representor changes Sasha Levin
2019-01-28 15:40 ` [PATCH AUTOSEL 4.20 127/304] mac80211: fix deauth TX when we disconnect Sasha Levin
2019-01-28 15:40 ` [PATCH AUTOSEL 4.20 130/304] tipc: fix node keep alive interval calculation Sasha Levin
2019-01-28 15:41 ` [PATCH AUTOSEL 4.20 169/304] mlxsw: spectrum_acl: Limit priority value Sasha Levin
2019-01-28 15:41 ` [PATCH AUTOSEL 4.20 172/304] selftests/bpf: use __bpf_constant_htons in test_prog.c Sasha Levin
2019-01-28 15:41 ` [PATCH AUTOSEL 4.20 179/304] ipv6: Fix handling of LLA with VRF and sockets bound to VRF Sasha Levin
2019-01-28 15:41 ` [PATCH AUTOSEL 4.20 180/304] tools: bpftool: fix -Wmissing declaration warnings Sasha Levin
2019-01-28 15:42 ` [PATCH AUTOSEL 4.20 203/304] bnxt_en: Disable MSIX before re-reserving NQs/CMPL rings Sasha Levin
2019-01-28 15:42 ` [PATCH AUTOSEL 4.20 207/304] mac80211: Properly handle SKB with radiotap only Sasha Levin
2019-01-28 15:42 ` [PATCH AUTOSEL 4.20 216/304] net: hns3: fix error handling int the hns3_get_vector_ring_chain Sasha Levin
2019-01-28 15:42 ` [PATCH AUTOSEL 4.20 217/304] net: hns3: fix incomplete uninitialization of IRQ in the hns3_nic_uninit_vector_data() Sasha Levin
2019-01-28 15:42 ` [PATCH AUTOSEL 4.20 223/304] mac80211: fix radiotap vendor presence bitmap handling Sasha Levin
2019-01-28 15:42 ` [PATCH AUTOSEL 4.20 224/304] xfrm6_tunnel: Fix spi check in __xfrm6_tunnel_alloc_spi Sasha Levin
2019-01-28 15:42 ` [PATCH AUTOSEL 4.20 225/304] mlxsw: spectrum: Properly cleanup LAG uppers when removing port from LAG Sasha Levin
2019-01-28 15:42 ` [PATCH AUTOSEL 4.20 229/304] cw1200: Fix concurrency use-after-free bugs in cw1200_hw_scan() Sasha Levin
2019-01-28 15:42 ` [PATCH AUTOSEL 4.20 230/304] net: hns3: add max vector number check for pf Sasha Levin
2019-01-28 15:42 ` [PATCH AUTOSEL 4.20 231/304] net: hns3: fix the descriptor index when get rss type Sasha Levin
2019-01-28 15:42 ` [PATCH AUTOSEL 4.20 232/304] net: hns3: don't restore rules when flow director is disabled Sasha Levin
2019-01-28 15:42 ` [PATCH AUTOSEL 4.20 234/304] iwlwifi: mvm: fix setting HE ppe FW config Sasha Levin
2019-01-28 15:42 ` [PATCH AUTOSEL 4.20 236/304] mlx5: update timecounter at least twice per counter overflow Sasha Levin
2019-01-28 15:42 ` Sasha Levin [this message]
2019-01-28 15:42 ` [PATCH AUTOSEL 4.20 242/304] ath10k: fix tx_stats memory leak Sasha Levin
2019-01-28 15:42 ` [PATCH AUTOSEL 4.20 247/304] i40e: define proper net_device::neigh_priv_len Sasha Levin
2019-01-28 15:42 ` [PATCH AUTOSEL 4.20 248/304] ice: Do not enable NAPI on q_vectors that have no rings Sasha Levin
2019-01-28 15:42 ` [PATCH AUTOSEL 4.20 249/304] igb: Fix an issue that PME is not enabled during runtime suspend Sasha Levin
2019-01-28 15:42 ` [PATCH AUTOSEL 4.20 252/304] bpf: sk_msg, zap ingress queue on psock down Sasha Levin
2019-01-28 15:42 ` [PATCH AUTOSEL 4.20 254/304] bpf: sk_msg, fix socket data_ready events Sasha Levin
2019-01-28 15:43 ` [PATCH AUTOSEL 4.20 272/304] niu: fix missing checks of niu_pci_eeprom_read Sasha Levin
2019-01-28 15:43 ` [PATCH AUTOSEL 4.20 283/304] isdn: hisax: hfc_pci: Fix a possible concurrency use-after-free bug in HFCPCI_l1hw() Sasha Levin
2019-01-28 15:43 ` [PATCH AUTOSEL 4.20 285/304] fsl/fman: Use GFP_ATOMIC in {memac,tgec}_add_hash_mac_address() Sasha Levin
2019-01-28 15:43 ` [PATCH AUTOSEL 4.20 293/304] bpf: fix check_map_access smin_value test when pointer contains offset Sasha Levin
2019-01-28 15:43 ` [PATCH AUTOSEL 4.20 304/304] xprtrdma: Don't wake pending tasks until disconnect is done 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=20190128154341.47195-241-sashal@kernel.org \
--to=sashal@kernel.org \
--cc=ath10k@lists.infradead.org \
--cc=kvalo@codeaurora.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-wireless@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=periyasa@codeaurora.org \
--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;
as well as URLs for NNTP newsgroup(s).