Message ID | 20201204162428.2583119-1-eric.dumazet@gmail.com |
---|---|
State | New |
Headers | show |
Series | [net] mac80211: mesh: fix mesh_pathtbl_init() error path | expand |
On Fri, 2020-12-04 at 17:26 +0100, Johannes Berg wrote: > On Fri, 2020-12-04 at 08:24 -0800, Eric Dumazet wrote: > > From: Eric Dumazet <edumazet@google.com> > > > > If tbl_mpp can not be allocated, we call mesh_table_free(tbl_path) > > while tbl_path rhashtable has not yet been initialized, which causes > > panics. > > Thanks Eric! > > I was going to ask how you ran into this ... > > > Reported-by: syzbot <syzkaller@googlegroups.com> > > Until I saw this - but doesn't syzbot normally want a > "syzbot+somehashid@..." as the reported-by? > > > > --- a/net/mac80211/mesh_pathtbl.c > > +++ b/net/mac80211/mesh_pathtbl.c > > @@ -60,6 +60,7 @@ static struct mesh_table *mesh_table_alloc(void) > > atomic_set(&newtbl->entries, 0); > > spin_lock_init(&newtbl->gates_lock); > > spin_lock_init(&newtbl->walk_lock); > > + rhashtable_init(&newtbl->rhead, &mesh_rht_params); > > > > return newtbl; > > } > > @@ -773,9 +774,6 @@ int mesh_pathtbl_init(struct ieee80211_sub_if_data *sdata) > > goto free_path; > > } > > > > - rhashtable_init(&tbl_path->rhead, &mesh_rht_params); > > - rhashtable_init(&tbl_mpp->rhead, &mesh_rht_params); > > > > Hmm. There were two calls, now there's only one? Is that a bug, or am I > missing something? Umm, never mind. johannes
On Fri, 04 Dec 2020 17:29:39 +0100 Johannes Berg wrote: > On Fri, 2020-12-04 at 08:24 -0800, Eric Dumazet wrote: > > From: Eric Dumazet <edumazet@google.com> > > > > If tbl_mpp can not be allocated, we call mesh_table_free(tbl_path) > > while tbl_path rhashtable has not yet been initialized, which causes > > panics. > > > > Simply factorize the rhashtable_init() call into mesh_table_alloc() > > Fixes: 60854fd94573 ("mac80211: mesh: convert path table to rhashtable") > > Signed-off-by: Eric Dumazet <edumazet@google.com> > > Reported-by: syzbot <syzkaller@googlegroups.com> > > Reviewed-by: Johannes Berg <johannes@sipsolutions.net> > > Jakub, if you want to take it to the net tree I wouldn't mind at all, > since I _just_ sent a pull request a little while ago. Sure thing. Applied, thanks!
diff --git a/net/mac80211/mesh_pathtbl.c b/net/mac80211/mesh_pathtbl.c index 48f31ac9233c8b33558cf41a9b44412c7b1ad591..620ecf922408b1f870d4da8ab7eef02e4d33ab15 100644 --- a/net/mac80211/mesh_pathtbl.c +++ b/net/mac80211/mesh_pathtbl.c @@ -60,6 +60,7 @@ static struct mesh_table *mesh_table_alloc(void) atomic_set(&newtbl->entries, 0); spin_lock_init(&newtbl->gates_lock); spin_lock_init(&newtbl->walk_lock); + rhashtable_init(&newtbl->rhead, &mesh_rht_params); return newtbl; } @@ -773,9 +774,6 @@ int mesh_pathtbl_init(struct ieee80211_sub_if_data *sdata) goto free_path; } - rhashtable_init(&tbl_path->rhead, &mesh_rht_params); - rhashtable_init(&tbl_mpp->rhead, &mesh_rht_params); - sdata->u.mesh.mesh_paths = tbl_path; sdata->u.mesh.mpp_paths = tbl_mpp;