linux-stable/net/mac80211
Linus Lüssing c1d9c3628e 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 08:22:27 +02:00
..
aes_ccm.c
aes_ccm.h
aes_cmac.c
aes_cmac.h
aes_gcm.c
aes_gcm.h
aes_gmac.c
aes_gmac.h
agg-rx.c mac80211: Fix sending ADDBA response for an ongoing session 2018-05-30 07:51:58 +02:00
agg-tx.c mac80211: send ADDBA requests using the tid/queue of the aggregation session 2021-12-22 09:17:58 +01:00
cfg.c mac80211: fix potential double free on mesh join 2022-03-28 08:22:27 +02:00
chan.c
debug.h
debugfs.c
debugfs.h
debugfs_key.c
debugfs_key.h
debugfs_netdev.c mac80211: fix txq null pointer dereference 2019-10-29 09:16:57 +01:00
debugfs_netdev.h
debugfs_sta.c mac80211: drop data frames without key on encrypted links 2021-08-26 08:37:05 -04:00
debugfs_sta.h
driver-ops.c mac80211: fix station rate table updates on assoc 2021-02-10 09:12:09 +01:00
driver-ops.h mac80211: do not call driver wake_tx_queue op during reconfig 2019-04-27 09:35:38 +02:00
ethtool.c
fils_aead.c
fils_aead.h
ht.c
ibss.c mac80211: fix double free in ibss_leave 2021-03-30 14:40:12 +02:00
ieee80211_i.h mac80211: remove warning in ieee80211_get_sband() 2021-06-30 08:48:57 -04:00
iface.c mac80211: add fragment cache to sta_info 2021-06-03 08:36:14 +02:00
Kconfig
key.c mac80211: drop data frames without key on encrypted links 2021-08-26 08:37:05 -04:00
key.h mac80211: prevent mixed key and fragment cache attacks 2021-06-03 08:36:13 +02:00
led.c
led.h
main.c mac80211: bail out if cipher schemes are invalid 2021-05-22 10:57:32 +02:00
Makefile
mesh.c mac80211: free peer keys before vif down in mesh 2019-07-21 09:04:19 +02:00
mesh.h mac80211: fix TX status reporting for ieee80211s 2018-11-04 14:52:37 +01:00
mesh_hwmp.c mac80211: fix potential overflow when multiplying to u32 integers 2021-03-03 18:22:40 +01:00
mesh_pathtbl.c mac80211: mesh: fix mesh_pathtbl_init() error path 2020-12-29 13:46:45 +01:00
mesh_plink.c
mesh_ps.c
mesh_sync.c
michael.c
michael.h
mlme.c mac80211: initialize variable have_higher_than_11mbit 2022-01-11 13:57:35 +01:00
ocb.c
offchannel.c
pm.c
rate.c mac80211: fix station rate table updates on assoc 2021-02-10 09:12:09 +01:00
rate.h
rc80211_minstrel.c mac80211: minstrel: fix tx status processing corner case 2020-11-24 13:05:56 +01:00
rc80211_minstrel.h mac80211: minstrel: remove deferred sampling code 2020-11-24 13:05:56 +01:00
rc80211_minstrel_debugfs.c
rc80211_minstrel_ht.c mac80211: minstrel_ht: fix per-group max throughput rate initialization 2020-01-27 14:46:43 +01:00
rc80211_minstrel_ht.h
rc80211_minstrel_ht_debugfs.c
rx.c mac80211: fix forwarded mesh frames AC & queue selection 2022-03-08 19:01:57 +01:00
scan.c
spectmgmt.c mac80211: Do not disconnect on invalid operating class 2018-05-30 07:51:58 +02:00
sta_info.c mac80211: add fragment cache to sta_info 2021-06-03 08:36:14 +02:00
sta_info.h mac80211: drop data frames without key on encrypted links 2021-08-26 08:37:05 -04:00
status.c mac80211: add ieee80211_is_any_nullfunc() 2020-05-10 10:29:03 +02:00
tdls.c mac80211: handle deauthentication/disassociation from TDLS peer 2019-06-25 11:36:55 +08:00
tkip.c mac80211: Fix TKIP replay protection immediately after key setup 2020-02-05 14:18:21 +00:00
tkip.h
trace.c
trace.h
trace_msg.h mac80211: Increase MAX_MSG_LEN 2019-05-16 19:42:21 +02:00
tx.c mac80211: limit injected vht mcs/nss in ieee80211_parse_tx_radiotap 2021-10-06 15:05:08 +02:00
util.c mac80211: consider more elements in parsing CRC 2020-03-11 18:02:44 +01:00
vht.c mac80211: do not allow bigger VHT MPDUs than the hardware supports 2020-10-14 09:51:07 +02:00
wep.c
wep.h
wme.c
wme.h
wpa.c mac80211: fix use-after-free in CCMP/GCMP RX 2021-10-06 15:05:08 +02:00
wpa.h