public inbox for b.a.t.m.a.n@lists.open-mesh.org
 help / color / mirror / Atom feed
From: Antonio Quartulli <a@unstable.cc>
To: davem@davemloft.net
Cc: netdev@vger.kernel.org, b.a.t.m.a.n@lists.open-mesh.org,
	Antonio Quartulli <a@unstable.cc>
Subject: [B.A.T.M.A.N.] [PATCH 3/4] batman-adv: Fix double neigh_node_put in batadv_v_ogm_route_update
Date: Sun, 15 May 2016 23:11:32 +0800	[thread overview]
Message-ID: <1463325093-3927-4-git-send-email-a@unstable.cc> (raw)
In-Reply-To: <1463325093-3927-1-git-send-email-a@unstable.cc>

From: Sven Eckelmann <sven@narfation.org>

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")
Signed-off-by: Sven Eckelmann <sven@narfation.org>
Signed-off-by: Antonio Quartulli <a@unstable.cc>
---
 net/batman-adv/bat_v_ogm.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/net/batman-adv/bat_v_ogm.c b/net/batman-adv/bat_v_ogm.c
index d9bcbe6e7d65..91df28a100f9 100644
--- a/net/batman-adv/bat_v_ogm.c
+++ b/net/batman-adv/bat_v_ogm.c
@@ -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,
-- 
2.8.2


  parent reply	other threads:[~2016-05-15 15:11 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-05-15 15:11 [B.A.T.M.A.N.] pull request [net]: batman-adv 20160515 Antonio Quartulli
2016-05-15 15:11 ` [B.A.T.M.A.N.] [PATCH 1/4] batman-adv: fix skb deref after free Antonio Quartulli
2016-05-15 15:11 ` [B.A.T.M.A.N.] [PATCH 2/4] batman-adv: Avoid nullptr derefence in batadv_v_neigh_is_sob Antonio Quartulli
2016-05-15 15:11 ` Antonio Quartulli [this message]
2016-05-15 15:11 ` [B.A.T.M.A.N.] [PATCH 4/4] batman-adv: Fix refcnt leak in batadv_v_neigh_* Antonio Quartulli
2016-05-16 18:01 ` [B.A.T.M.A.N.] pull request [net]: batman-adv 20160515 David Miller

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1463325093-3927-4-git-send-email-a@unstable.cc \
    --to=a@unstable.cc \
    --cc=b.a.t.m.a.n@lists.open-mesh.org \
    --cc=davem@davemloft.net \
    --cc=netdev@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox