wifi: mac80211_hwsim: fix race condition in pending packet
authorJeongik Cha <jeongik@google.com>
Mon, 4 Jul 2022 08:43:54 +0000 (17:43 +0900)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 17 Aug 2022 12:22:46 +0000 (14:22 +0200)
commit879f766eaa31f1eccab543f6236bc66a2acda2e3
treeb92fc0f5822b45133170de1f5e544c79bb41d63c
parent14acf0290d2d823296bdfc3d555d42779b50193b
wifi: mac80211_hwsim: fix race condition in pending packet

commit 4ee186fa7e40ae06ebbfbad77e249e3746e14114 upstream.

A pending packet uses a cookie as an unique key, but it can be duplicated
because it didn't use atomic operators.

And also, a pending packet can be null in hwsim_tx_info_frame_received_nl
due to race condition with mac80211_hwsim_stop.

For this,
 * Use an atomic type and operator for a cookie
 * Add a lock around the loop for pending packets

Signed-off-by: Jeongik Cha <jeongik@google.com>
Link: https://lore.kernel.org/r/20220704084354.3556326-1-jeongik@google.com
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/net/wireless/mac80211_hwsim.c