batman-adv: Avoid free/alloc race when handling OGM2 buffer
authorSven Eckelmann <sven@narfation.org>
Thu, 3 Oct 2019 15:02:01 +0000 (17:02 +0200)
committerSimon Wunderlich <sw@simonwunderlich.de>
Sun, 13 Oct 2019 18:36:39 +0000 (20:36 +0200)
commita8d23cbbf6c9f515ed678204ad2962be7c336344
treea3a4b2ee8ebe9662a7feb391b9b5796cd44e31c6
parent54ecb8f7028c5eb3d740bb82b0f1d90f2df63c5c
batman-adv: Avoid free/alloc race when handling OGM2 buffer

A B.A.T.M.A.N. V virtual interface has an OGM2 packet buffer which is
initialized using data from the netdevice notifier and other rtnetlink
related hooks. It is sent regularly via various slave interfaces of the
batadv virtual interface and in this process also modified (realloced) to
integrate additional state information via TVLV containers.

It must be avoided that the worker item is executed without a common lock
with the netdevice notifier/rtnetlink helpers. Otherwise it can either
happen that half modified data is sent out or the functions modifying the
OGM2 buffer try to access already freed memory regions.

Fixes: 0da0035942d4 ("batman-adv: OGMv2 - add basic infrastructure")
Signed-off-by: Sven Eckelmann <sven@narfation.org>
Signed-off-by: Simon Wunderlich <sw@simonwunderlich.de>
net/batman-adv/bat_v_ogm.c
net/batman-adv/types.h