Skip to contentSkip to conversation

batman-adv: Avoid nullptr derefence in batadv_v_neigh_is_sob

PATCH Superseded Sven Eckelmann 1 participant 2 messages May 6, 2016 Batman advanced

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Sven Eckelmann

author maintainer
#0 lore raw

PATCH 1/1 batman-adv: Avoid nullptr derefence in batadv_v_neigh_is_sob

batadv_neigh_ifinfo_get can return NULL when it cannot find (even when only temporarily) anymore the neigh_ifinfo in the list neigh->ifinfo_list. This has to be checked to avoid kernel Oopses when the ifinfo is dereferenced.

This a situation which isn't expected but is already handled by functions like batadv_v_neigh_cmp. The same kind of warning is therefore used before the function returns without dereferencing the pointers.

Fixes b05bbab5e1fc ("batman-adv: B.A.T.M.A.N. V - implement neighbor comparison API calls")
---
 net/batman-adv/bat_v.c | 3 +++
 1 file changed, 3 insertions(+)
net/batman-adv/bat_v.c +3 -0
index 927d405..f271ae8 100644
@@ -286,6 +286,9 @@ static bool batadv_v_neigh_is_sob(struct batadv_neigh_node *neigh1,
 	ifinfo1 = batadv_neigh_ifinfo_get(neigh1, if_outgoing1);
 	ifinfo2 = batadv_neigh_ifinfo_get(neigh2, if_outgoing2);
 
+	if (WARN_ON(!ifinfo1 || !ifinfo2))
+		return false;
+
 	threshold = ifinfo1->bat_v.throughput / 4;
 	threshold = ifinfo1->bat_v.throughput - threshold;
 
Signature · 1 line
2.8.1
author maintainer
#1 lore raw
Quoted 11 lines · On Friday 06 May 2016 11:22:47 Sven Eckelmann wrote:

batadv_neigh_ifinfo_get can return NULL when it cannot find (even when only temporarily) anymore the neigh_ifinfo in the list neigh->ifinfo_list. This has to be checked to avoid kernel Oopses when the ifinfo is dereferenced.

This a situation which isn't expected but is already handled by functions like batadv_v_neigh_cmp. The same kind of warning is therefore used before the function returns without dereferencing the pointers.

Fixes b05bbab5e1fc ("batman-adv: B.A.T.M.A.N. V - implement neighbor

comparison API calls") Signed-off-by: Sven Eckelmann <[email protected]>
---

Looks like the reference counting is also completely broken in these functions :(

Kind regards,
Sven