linux-stable/net/mac80211
Linus Lüssing 12e407a8ef mac80211: fix potential double free on mesh join
commit 4a2d4496e1 upstream.

While commit 6a01afcf84 ("mac80211: mesh: Free ie data when leaving
mesh") fixed a memory leak on mesh leave / teardown it introduced a
potential memory corruption caused by a double free when rejoining the
mesh:

  ieee80211_leave_mesh()
  -> kfree(sdata->u.mesh.ie);
  ...
  ieee80211_join_mesh()
  -> copy_mesh_setup()
     -> old_ie = ifmsh->ie;
     -> kfree(old_ie);

This double free / kernel panics can be reproduced by using wpa_supplicant
with an encrypted mesh (if set up without encryption via "iw" then
ifmsh->ie is always NULL, which avoids this issue). And then calling:

  $ iw dev mesh0 mesh leave
  $ iw dev mesh0 mesh join my-mesh

Note that typically these commands are not used / working when using
wpa_supplicant. And it seems that wpa_supplicant or wpa_cli are going
through a NETDEV_DOWN/NETDEV_UP cycle between a mesh leave and mesh join
where the NETDEV_UP resets the mesh.ie to NULL via a memcpy of
default_mesh_setup in cfg80211_netdev_notifier_call, which then avoids
the memory corruption, too.

The issue was first observed in an application which was not using
wpa_supplicant but "Senf" instead, which implements its own calls to
nl80211.

Fixing the issue by removing the kfree()'ing of the mesh IE in the mesh
join function and leaving it solely up to the mesh leave to free the
mesh IE.

Cc: stable@vger.kernel.org
Fixes: 6a01afcf84 ("mac80211: mesh: Free ie data when leaving mesh")
Reported-by: Matthias Kretschmer <mathias.kretschmer@fit.fraunhofer.de>
Signed-off-by: Linus Lüssing <ll@simonwunderlich.de>
Tested-by: Mathias Kretschmer <mathias.kretschmer@fit.fraunhofer.de>
Link: https://lore.kernel.org/r/20220310183513.28589-1-linus.luessing@c0d3.blue
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2022-03-28 09:58:45 +02:00
..
Kconfig ath9k: fix build error with LEDS_CLASS=m 2021-01-28 09:29:34 +02:00
Makefile mac80211: remove legacy minstrel rate control 2021-01-22 09:11:37 +01:00
aead_api.c mac80211: Check crypto_aead_encrypt for errors 2021-03-16 21:20:41 +01:00
aead_api.h
aes_ccm.h
aes_cmac.c mac80211: aes_cmac: check crypto_shash_setkey() return value 2021-04-19 12:01:40 +02:00
aes_cmac.h
aes_gcm.h
aes_gmac.c mac80211: Check crypto_aead_encrypt for errors 2021-03-16 21:20:41 +01:00
aes_gmac.h
agg-rx.c mac80211: fix lookup when adding AddBA extension element 2021-12-22 09:32:42 +01:00
agg-tx.c mac80211: refuse aggregations sessions before authorized 2022-03-19 13:47:48 +01:00
airtime.c mac80211: add AQL support for VHT160 tx rates 2020-09-18 11:36:03 +02:00
cfg.c mac80211: fix potential double free on mesh join 2022-03-28 09:58:45 +02:00
chan.c mac80211: handle rate control (RC) racing with chanctx definition 2021-06-23 11:29:14 +02:00
debug.h
debugfs.c mac80211: Switch to a virtual time-based airtime scheduler 2021-06-23 18:12:00 +02:00
debugfs.h
debugfs_key.c mac80211: remove trailing semicolon in macro definitions 2020-12-11 12:51:55 +01:00
debugfs_key.h
debugfs_netdev.c mac80211: Switch to a virtual time-based airtime scheduler 2021-06-23 18:12:00 +02:00
debugfs_netdev.h
debugfs_sta.c mac80211: Switch to a virtual time-based airtime scheduler 2021-06-23 18:12:00 +02:00
debugfs_sta.h
driver-ops.c mac80211: fix station rate table updates on assoc 2021-02-01 15:07:09 +01:00
driver-ops.h mac80211: mark TX-during-stop for TX in in_reconfig 2021-12-22 09:32:34 +01:00
ethtool.c
fils_aead.c
fils_aead.h
he.c mac80211: fix NULL ptr dereference during mesh peer connection for non HE devices 2021-06-23 18:06:44 +02:00
ht.c mac80211: allow SMPS requests only in client mode 2021-06-23 11:29:13 +02:00
ibss.c mac80211: Remove unnecessary variable and label 2021-08-13 09:58:25 +02:00
ieee80211_i.h mac80211: treat some SAE auth steps as final 2022-03-08 19:12:46 +01:00
iface.c mac80211: fix monitor_sdata RCU/locking assertions 2021-11-25 09:48:34 +01:00
key.c mac80211: prevent mixed key and fragment cache attacks 2021-05-11 20:12:51 +02:00
key.h mac80211: prevent mixed key and fragment cache attacks 2021-05-11 20:12:51 +02:00
led.c mac80211: don't open-code LED manipulations 2021-06-23 11:29:12 +02:00
led.h mac80211: fix throughput LED trigger 2021-12-08 09:04:38 +01:00
main.c Minor updates: 2021-08-20 10:09:22 -07:00
mesh.c mac80211: mesh: fix HE operation element length check 2021-10-01 11:02:24 +02:00
mesh.h mac80211: mesh: embedd mesh_paths and mpp_paths into ieee80211_if_mesh 2022-01-11 15:35:13 +01:00
mesh_hwmp.c mac80211: fix some spelling mistakes 2021-06-23 12:36:32 +02:00
mesh_pathtbl.c mac80211: mesh: embedd mesh_paths and mpp_paths into ieee80211_if_mesh 2022-01-11 15:35:13 +01:00
mesh_plink.c mac80211: fix some spelling mistakes 2021-06-23 12:36:32 +02:00
mesh_ps.c mac80211: mesh: fix potentially unaligned access 2021-09-23 13:25:09 +02:00
mesh_sync.c
michael.c
michael.h
mlme.c mac80211: treat some SAE auth steps as final 2022-03-08 19:12:46 +01:00
ocb.c
offchannel.c mac80211: Inform AP when returning operating channel 2020-09-28 13:18:53 +02:00
pm.c cfg80211: avoid holding the RTNL when calling the driver 2021-01-26 11:55:50 +01:00
rate.c Revert "mac80211: do not use low data rates for data frames with no ack flag" 2021-09-23 12:59:29 +02:00
rate.h
rc80211_minstrel_ht.c mac80211: fix some spelling mistakes 2021-06-23 12:36:32 +02:00
rc80211_minstrel_ht.h mac80211: minstrel_ht: remove sample rate switching code for constrained devices 2021-02-12 08:58:22 +01:00
rc80211_minstrel_ht_debugfs.c mac80211: minstrel_ht: show sampling rates in debugfs 2021-02-12 08:58:11 +01:00
rx.c mac80211: fix forwarded mesh frames AC & queue selection 2022-03-08 19:12:46 +01:00
s1g.c mac80211: twt: don't use potentially unaligned pointer 2021-11-18 19:16:25 +01:00
scan.c mac80211: fix skb length check in ieee80211_scan_rx() 2021-05-31 21:39:10 +02:00
spectmgmt.c mac80211: 160MHz with extended NSS BW in CSA 2021-01-21 13:39:11 +01:00
sta_info.c mac80211: Reject zero MAC address in sta_info_insert_check() 2021-08-13 09:50:43 +02:00
sta_info.h mac80211: fix regression in SSN handling of addba tx 2021-12-22 09:32:34 +01:00
status.c mac80211: introduce individual TWT support in AP mode 2021-08-24 10:30:43 +02:00
tdls.c mac80211: use sdata->skb_queue for TDLS 2021-06-23 11:00:17 +02:00
tkip.c
tkip.h
trace.c
trace.h mac80211: introduce individual TWT support in AP mode 2021-08-24 10:30:43 +02:00
trace_msg.h
tx.c mac80211: fix rate control for retransmitted frames 2021-12-22 09:32:34 +01:00
util.c mac80211: validate extended element ID is present 2021-12-22 09:32:35 +01:00
vht.c mac80211: remove NSS number of 160MHz if not support 160MHz for HE 2021-01-21 13:45:13 +01:00
wep.c
wep.h
wme.c mac80211: drop check for DONT_REORDER in __ieee80211_select_queue 2021-11-25 09:48:47 +01:00
wme.h
wpa.c mac80211: fix use-after-free in CCMP/GCMP RX 2021-09-27 11:59:49 +02:00
wpa.h