]> www.infradead.org Git - users/dwmw2/linux.git/commit
cw1200: Fix concurrency use-after-free bugs in cw1200_hw_scan()
authorJia-Ju Bai <baijiaju1990@gmail.com>
Fri, 14 Dec 2018 03:55:21 +0000 (11:55 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 12 Feb 2019 19:02:24 +0000 (20:02 +0100)
commite8fdcc65642ec6865f0a6d865e5ec5fab1f5ca19
tree45a743e9719c24aa9448f392467978b91c6e9871
parent8e199bb5de5e0574f3cdcc6f28aaecb810c94e6c
cw1200: Fix concurrency use-after-free bugs in cw1200_hw_scan()

[ Upstream commit 4f68ef64cd7feb1220232bd8f501d8aad340a099 ]

The function cw1200_bss_info_changed() and cw1200_hw_scan() can be
concurrently executed.
The two functions both access a possible shared variable "frame.skb".

This shared variable is freed by dev_kfree_skb() in cw1200_upload_beacon(),
which is called by cw1200_bss_info_changed(). The free operation is
protected by a mutex lock "priv->conf_mutex" in cw1200_bss_info_changed().

In cw1200_hw_scan(), this shared variable is accessed without the
protection of the mutex lock "priv->conf_mutex".
Thus, concurrency use-after-free bugs may occur.

To fix these bugs, the original calls to mutex_lock(&priv->conf_mutex) and
mutex_unlock(&priv->conf_mutex) are moved to the places, which can
protect the accesses to the shared variable.

Signed-off-by: Jia-Ju Bai <baijiaju1990@gmail.com>
Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/net/wireless/st/cw1200/scan.c