mac80211: mesh: embedd mesh_paths and mpp_paths into ieee80211_if_mesh
authorPavel Skripkin <paskripkin@gmail.com>
Thu, 30 Dec 2021 19:55:47 +0000 (22:55 +0300)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 11 Jan 2022 14:35:13 +0000 (15:35 +0100)
commit03fb6db4ad614bf0aa3e0ce38328401faf4f145c
tree72eb9f3ea2a5ca3cc294f7de0a280e37f492e0bf
parent18b224910edcf1bf120428be1f1030a6f245cf0a
mac80211: mesh: embedd mesh_paths and mpp_paths into ieee80211_if_mesh

commit 8b5cb7e41d9d77ffca036b0239177de123394a55 upstream.

Syzbot hit NULL deref in rhashtable_free_and_destroy(). The problem was
in mesh_paths and mpp_paths being NULL.

mesh_pathtbl_init() could fail in case of memory allocation failure, but
nobody cared, since ieee80211_mesh_init_sdata() returns void. It led to
leaving 2 pointers as NULL. Syzbot has found null deref on exit path,
but it could happen anywhere else, because code assumes these pointers are
valid.

Since all ieee80211_*_setup_sdata functions are void and do not fail,
let's embedd mesh_paths and mpp_paths into parent struct to avoid
adding error handling on higher levels and follow the pattern of others
setup_sdata functions

Fixes: 60854fd94573 ("mac80211: mesh: convert path table to rhashtable")
Reported-and-tested-by: syzbot+860268315ba86ea6b96b@syzkaller.appspotmail.com
Signed-off-by: Pavel Skripkin <paskripkin@gmail.com>
Link: https://lore.kernel.org/r/20211230195547.23977-1-paskripkin@gmail.com
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
net/mac80211/ieee80211_i.h
net/mac80211/mesh.h
net/mac80211/mesh_pathtbl.c