]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
batman-adv: Avoid free/alloc race when handling OGM buffer
authorSven Eckelmann <sven@narfation.org>
Thu, 3 Oct 2019 15:02:01 +0000 (17:02 +0200)
committerBen Hutchings <ben@decadent.org.uk>
Thu, 19 Dec 2019 15:58:28 +0000 (15:58 +0000)
commit6f2088aaa4bf8df9c35c92dbc9fe381f49b8f62a
tree70f3a01a1ed24a22f082f8190878ceb719963eb9
parentbc1e75e2f759973eb81dd09757952f1a2f95e607
batman-adv: Avoid free/alloc race when handling OGM buffer

commit 40e220b4218bb3d278e5e8cc04ccdfd1c7ff8307 upstream.

Each slave interface of an B.A.T.M.A.N. IV virtual interface has an OGM
packet buffer which is initialized using data from 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/freed data is sent out or functions modifying the
OGM buffer try to access already freed memory regions.

Reported-by: syzbot+0cc629f19ccb8534935b@syzkaller.appspotmail.com
Fixes: c6c8fea29769 ("net: Add batman-adv meshing protocol")
Signed-off-by: Sven Eckelmann <sven@narfation.org>
Signed-off-by: Simon Wunderlich <sw@simonwunderlich.de>
[bwh: Backported to 3.16:
 - Don't add status check in batadv_iv_ogm_schedule()
 - Adjust context]
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
net/batman-adv/bat_iv_ogm.c
net/batman-adv/hard-interface.c
net/batman-adv/types.h