]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
batman-adv: Prevent duplicated softif_vlan entry
authorSven Eckelmann <sven@narfation.org>
Sat, 20 Nov 2021 12:39:31 +0000 (13:39 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 26 Nov 2021 10:58:45 +0000 (11:58 +0100)
commit13211be723559da8b0787772bae3c26c06418ffe
tree0f24d1c1306e1f432b72e1dc4fc5971bed87d9b1
parent52a00ee3ecc07919f047bddaef1fa289057e91a5
batman-adv: Prevent duplicated softif_vlan entry

commit 94cb82f594ed86be303398d6dfc7640a6f1d45d4 upstream.

The function batadv_softif_vlan_get is responsible for adding new
softif_vlan to the softif_vlan_list. It first checks whether the entry
already is in the list or not. If it is, then the creation of a new entry
is aborted.

But the lock for the list is only held when the list is really modified.
This could lead to duplicated entries because another context could create
an entry with the same key between the check and the list manipulation.

The check and the manipulation of the list must therefore be in the same
locked code section.

Fixes: 5d2c05b21337 ("batman-adv: add per VLAN interface attribute framework")
Signed-off-by: Sven Eckelmann <sven@narfation.org>
Signed-off-by: Simon Wunderlich <sw@simonwunderlich.de>
[ bp: 4.4 backport: switch back to atomic_t based reference counting. ]
Signed-off-by: Sven Eckelmann <sven@narfation.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
net/batman-adv/soft-interface.c