batman-adv: Only read OGM2 tvlv_len after buffer len check
authorSven Eckelmann <sven@narfation.org>
Thu, 22 Aug 2019 06:55:36 +0000 (08:55 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 21 Sep 2019 05:14:14 +0000 (07:14 +0200)
commita1653da6670412a3fb3a11b413442f7fcbf78b61
tree21f03f6b7f175ece7198a4dcbabfbcc3f9d99b56
parent71c369621a164840012200b22da9e84a254bb223
batman-adv: Only read OGM2 tvlv_len after buffer len check

[ Upstream commit 0ff0f15a32c093381ad1abc06abe85afb561ab28 ]

Multiple batadv_ogm2_packet can be stored in an skbuff. The functions
batadv_v_ogm_send_to_if() uses batadv_v_ogm_aggr_packet() to check if there
is another additional batadv_ogm2_packet in the skb or not before they
continue processing the packet.

The length for such an OGM2 is BATADV_OGM2_HLEN +
batadv_ogm2_packet->tvlv_len. The check must first check that at least
BATADV_OGM2_HLEN bytes are available before it accesses tvlv_len (which is
part of the header. Otherwise it might try read outside of the currently
available skbuff to get the content of tvlv_len.

Fixes: 9323158ef9f4 ("batman-adv: OGMv2 - implement originators logic")
Signed-off-by: Sven Eckelmann <sven@narfation.org>
Signed-off-by: Simon Wunderlich <sw@simonwunderlich.de>
Signed-off-by: Sasha Levin <sashal@kernel.org>
net/batman-adv/bat_v_ogm.c