]> git.baikalelectronics.ru Git - kernel.git/commit
batman-adv: Fix potential synchronization issues in mcast tvlv handler
authorLinus Lüssing <linus.luessing@c0d3.blue>
Tue, 16 Jun 2015 15:10:26 +0000 (17:10 +0200)
committerAntonio Quartulli <antonio@meshcoding.com>
Fri, 14 Aug 2015 20:52:08 +0000 (22:52 +0200)
commit2a4a4e45711d791094c0fc06c839c30faea3784d
tree47a3414f2843011b95fdad1c05e413c3957d050a
parent6610c12d917b324305fcb1ad36aec5192163c67d
batman-adv: Fix potential synchronization issues in mcast tvlv handler

So far the mcast tvlv handler did not anticipate the processing of
multiple incoming OGMs from the same originator at the same time. This
can lead to various issues:

* Broken refcounting: For instance two mcast handlers might both assume
  that an originator just got multicast capabilities and will together
  wrongly decrease mcast.num_disabled by two, potentially leading to
  an integer underflow.

* Potential kernel panic on hlist_del_rcu(): Two mcast handlers might
  one after another try to do an
  hlist_del_rcu(&orig->mcast_want_all_*_node). The second one will
  cause memory corruption / crashes.
  (Reported by: Sven Eckelmann <sven@narfation.org>)

Right in the beginning the code path makes assumptions about the current
multicast related state of an originator and bases all updates on that. The
easiest and least error prune way to fix the issues in this case is to
serialize multiple mcast handler invocations with a spinlock.

Fixes: 1b8d573fd585 ("batman-adv: Announce new capability via multicast TVLV")
Signed-off-by: Linus Lüssing <linus.luessing@c0d3.blue>
Signed-off-by: Marek Lindner <mareklindner@neomailbox.ch>
Signed-off-by: Antonio Quartulli <antonio@meshcoding.com>
net/batman-adv/multicast.c
net/batman-adv/originator.c
net/batman-adv/types.h