OSDN Git Service

batman-adv: Fix deletion of RTR(4|6) mcast list entries
authorSven Eckelmann <sven@narfation.org>
Sun, 7 Jul 2019 21:04:57 +0000 (23:04 +0200)
committerSimon Wunderlich <sw@simonwunderlich.de>
Mon, 22 Jul 2019 19:34:58 +0000 (21:34 +0200)
commitf7af86ccf1882084293b11077deec049fd01da63
tree522b67465b1aa16d4ec47c44d0004430efa7bf60
parentfa3a03da549a889fc9dbc0d3c5908eb7882cac8f
batman-adv: Fix deletion of RTR(4|6) mcast list entries

The multicast code uses the lists bat_priv->mcast.want_all_rtr*_list to
store all all originator nodes which don't have the flag no-RTR4 or no-RTR6
set. When an originator is purged, it has to be removed from these lists.

Since all entries without the BATADV_MCAST_WANT_NO_RTR4/6 are stored in
these lists, they have to be handled like entries which have these flags
set to force the update routines to remove them from the lists when purging
the originator.

Not doing so will leave a pointer to a freed memory region inside the list.
Trying to operate on these lists will then cause an use-after-free error:

  BUG: KASAN: use-after-free in batadv_mcast_want_rtr4_update+0x335/0x3a0 [batman_adv]
  Write of size 8 at addr ffff888007b41a38 by task swapper/0/0

Fixes: 61caf3d109f5 ("batman-adv: mcast: detect, distribute and maintain multicast router presence")
Signed-off-by: Sven Eckelmann <sven@narfation.org>
Acked-by: Linus Lüssing <linus.luessing@c0d3.blue>
Signed-off-by: Simon Wunderlich <sw@simonwunderlich.de>
net/batman-adv/multicast.c