Skip to content

Commit ef72706

Browse files
Marek Lindnerordex
authored andcommitted
batman-adv: protect tt_local_entry from concurrent delete events
The tt_local_entry deletion performed in batadv_tt_local_remove() was neither protecting against simultaneous deletes nor checking whether the element was still part of the list before calling hlist_del_rcu(). Replacing the hlist_del_rcu() call with batadv_hash_remove() provides adequate protection via hash spinlocks as well as an is-element-still-in-hash check to avoid 'blind' hash removal. Fixes: 068ee6e ("batman-adv: roaming handling mechanism redesign") Reported-by: [email protected] Signed-off-by: Marek Lindner <[email protected]> Signed-off-by: Antonio Quartulli <[email protected]>
1 parent 354136b commit ef72706

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

net/batman-adv/translation-table.c

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1037,6 +1037,7 @@ uint16_t batadv_tt_local_remove(struct batadv_priv *bat_priv,
10371037
struct batadv_tt_local_entry *tt_local_entry;
10381038
uint16_t flags, curr_flags = BATADV_NO_FLAGS;
10391039
struct batadv_softif_vlan *vlan;
1040+
void *tt_entry_exists;
10401041

10411042
tt_local_entry = batadv_tt_local_hash_find(bat_priv, addr, vid);
10421043
if (!tt_local_entry)
@@ -1064,7 +1065,15 @@ uint16_t batadv_tt_local_remove(struct batadv_priv *bat_priv,
10641065
* immediately purge it
10651066
*/
10661067
batadv_tt_local_event(bat_priv, tt_local_entry, BATADV_TT_CLIENT_DEL);
1067-
hlist_del_rcu(&tt_local_entry->common.hash_entry);
1068+
1069+
tt_entry_exists = batadv_hash_remove(bat_priv->tt.local_hash,
1070+
batadv_compare_tt,
1071+
batadv_choose_tt,
1072+
&tt_local_entry->common);
1073+
if (!tt_entry_exists)
1074+
goto out;
1075+
1076+
/* extra call to free the local tt entry */
10681077
batadv_tt_local_entry_free_ref(tt_local_entry);
10691078

10701079
/* decrease the reference held for this vlan */

0 commit comments

Comments
 (0)