FAILED: patch "[PATCH] mac80211: mesh: embedd mesh_paths and mpp_paths into" failed to apply to 5.4-stable tree
Subsystems (2)
[email protected]
maintainerThe patch below does not apply to the 5.4-stable tree.
If someone wants it applied there, or to any other stable or longterm tree, then please email the backport, including the original git commit id to <[email protected]>.
thanks,
greg k-h
------------------ original commit in Linus's tree ------------------
From 8b5cb7e41d9d77ffca036b0239177de123394a55 Mon Sep 17 00:00:00 2001
From: Pavel Skripkin <[email protected]>
Date: Thu, 30 Dec 2021 22:55:47 +0300
Subject: [PATCH] mac80211: mesh: embedd mesh_paths and mpp_paths into
ieee80211_if_mesh
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
net/mac80211/ieee80211_i.h +22 -2
@@ -647,6 +647,26 @@ struct mesh_csa_settings {struct cfg80211_csa_settings settings; }; +/** +* struct mesh_table +* +* @known_gates: list of known mesh gates and their mpaths by the station. The +* gate's mpath may or may not be resolved and active. +* @gates_lock: protects updates to known_gates +* @rhead: the rhashtable containing struct mesh_paths, keyed by dest addr +* @walk_head: linked list containing all mesh_path objects +* @walk_lock: lock protecting walk_head +* @entries: number of entries in the table +*/ +struct mesh_table { +struct hlist_head known_gates; +spinlock_t gates_lock; +struct rhashtable rhead; +struct hlist_head walk_head; +spinlock_t walk_lock; +atomic_t entries;/* Up to MAX_MESH_NEIGHBOURS */ +}; +struct ieee80211_if_mesh {struct timer_list housekeeping_timer;struct timer_list mesh_path_timer;
@@ -721,8 +741,8 @@ struct ieee80211_if_mesh {/* offset from skb->data while building IE */ int meshconf_offset; -struct mesh_table *mesh_paths; -struct mesh_table *mpp_paths;/* Store paths for MPP&MAP */ +struct mesh_table mesh_paths; +struct mesh_table mpp_paths;/* Store paths for MPP&MAP */ int mesh_paths_generation;int mpp_paths_generation; };
net/mac80211/mesh.h +1 -21
@@ -127,26 +127,6 @@ struct mesh_path {u32 path_change_count; }; -/** -* struct mesh_table -* -* @known_gates: list of known mesh gates and their mpaths by the station. The -* gate's mpath may or may not be resolved and active. -* @gates_lock: protects updates to known_gates -* @rhead: the rhashtable containing struct mesh_paths, keyed by dest addr -* @walk_head: linked list containing all mesh_path objects -* @walk_lock: lock protecting walk_head -* @entries: number of entries in the table -*/ -struct mesh_table { -struct hlist_head known_gates; -spinlock_t gates_lock; -struct rhashtable rhead; -struct hlist_head walk_head; -spinlock_t walk_lock; -atomic_t entries;/* Up to MAX_MESH_NEIGHBOURS */ -}; -/* Recent multicast cache */ /* RMC_BUCKETS must be a power of 2, maximum 256 */ #define RMC_BUCKETS 256
@@ -308,7 +288,7 @@ int mesh_path_error_tx(struct ieee80211_sub_if_data *sdata,void mesh_path_assign_nexthop (struct mesh_path *mpath,struct sta_info *sta);void mesh_path_flush_pending (struct mesh_path *mpath);void mesh_path_tx_pending (struct mesh_path *mpath); -int mesh_pathtbl_init (struct ieee80211_sub_if_data *sdata); +void mesh_pathtbl_init (struct ieee80211_sub_if_data *sdata);void mesh_pathtbl_unregister (struct ieee80211_sub_if_data *sdata);int mesh_path_del (struct ieee80211_sub_if_data *sdata,const u8 *addr);void mesh_path_timer (struct timer_list *t);
net/mac80211/mesh_pathtbl.c +31 -58
195 lines not on this page · raw message