Skip to contentSkip to conversation

batman-adv: Fix double neigh_node_put in batadv_v_ogm_route_update

PATCH Applied Antonio Quartulli 2 participants 2 messages May 21, 2016 – Jun 4, 2016

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 batman-adv: Fix double neigh_node_put in batadv_v_ogm_route_update

From: Sven Eckelmann <[email protected]>

The router is put down twice when it was non-NULL and either orig_ifinfo is NULL afterwards or batman-adv receives a packet with the same sequence number. This will end up in a use-after-free when the batadv_neigh_node is removed because the reference counter ended up too early at 0.

Fixes 9323158ef9f4 ("batman-adv: OGMv2 - implement originators logic")

---

This patch is skipping netdev and is being sent directly to stable in accordance with David S. Miller[1].

The reason is that this patch applies only on linux-4.6 and not on linux-4.7/net because it was "accidentally" fixed by a refactoring commit (more details in [2]).

It addresses a reference imbalance which systematically leads to a use-after-free and then a kernel crash.

Cheers,

[1] https://www.mail-archive.com/[email protected]/msg15258.html
[2] https://www.mail-archive.com/[email protected]/msg15252.html

 net/batman-adv/bat_v_ogm.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
net/batman-adv/bat_v_ogm.c +3 -1
index d9bcbe6e7d65..91df28a100f9 100644
@@ -529,8 +529,10 @@ static void batadv_v_ogm_route_update(struct batadv_priv *bat_priv,
 		goto out;
 	}
 
-	if (router)
+	if (router) {
 		batadv_neigh_node_put(router);
+		router = NULL;
+	}
 
 	/* Update routes, and check if the OGM is from the best next hop */
 	batadv_v_ogm_orig_update(bat_priv, orig_node, neigh_node, ogm2,
Signature · 1 line
2.8.3
maintainer Applied
#1 lore raw

Patch "batman-adv: Fix double neigh_node_put in batadv_v_ogm_route_update" has been added to the 4.6-stable tree

This is a note to let you know that I've just added the patch titled

batman-adv: Fix double neigh_node_put in batadv_v_ogm_route_update

to the 4.6-stable tree which can be found at:
http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
batman-adv-fix-double-neigh_node_put-in-batadv_v_ogm_route_update.patch
and it can be found in the queue-4.6 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree, please let <[email protected]> know about it.

Quoted 1 line

From [email protected] Sat Jun 4 12:37:07 2016

From: Antonio Quartulli <[email protected]>
Date: Sat, 21 May 2016 17:48:17 +0800
Subject: batman-adv: Fix double neigh_node_put in batadv_v_ogm_route_update
To: [email protected]
Cc: [email protected], Sven Eckelmann <[email protected]>, Antonio Quartulli <[email protected]>
Message-ID: <[email protected]>

From: Sven Eckelmann <[email protected]>

The router is put down twice when it was non-NULL and either orig_ifinfo is NULL afterwards or batman-adv receives a packet with the same sequence number. This will end up in a use-after-free when the batadv_neigh_node is removed because the reference counter ended up too early at 0.

This patch is skipping netdev and is being sent directly to stable in accordance with David S. Miller[1].

The reason is that this patch applies only on linux-4.6 and not on linux-4.7/net because it was "accidentally" fixed by a refactoring commit (more details in [2]).

It addresses a reference imbalance which systematically leads to a use-after-free and then a kernel crash.

[1] https://www.mail-archive.com/[email protected]/msg15258.html
[2] https://www.mail-archive.com/[email protected]/msg15252.html

Fixes 9323158ef9f4 ("batman-adv: OGMv2 - implement originators logic")

---

Cheers,

 net/batman-adv/bat_v_ogm.c |    4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
net/batman-adv/bat_v_ogm.c +3 -1
@@ -529,8 +529,10 @@ static void batadv_v_ogm_route_update(st
 		goto out;
 	}
 
-	if (router)
+	if (router) {
 		batadv_neigh_node_put(router);
+		router = NULL;
+	}
 
 	/* Update routes, and check if the OGM is from the best next hop */
 	batadv_v_ogm_orig_update(bat_priv, orig_node, neigh_node, ogm2,

Patches currently in stable-queue which might be from [email protected] are

queue-4.6/batman-adv-fix-double-neigh_node_put-in-batadv_v_ogm_route_update.patch