b.a.t.m.a.n.lists.open-mesh.org archive mirror
 help / color / mirror / Atom feed
From: Sven Eckelmann <sven@narfation.org>
To: b.a.t.m.a.n@lists.open-mesh.org
Subject: [B.A.T.M.A.N.] [PATCH 04/23] batman-adv: Drop immediate free functions for batadv_hardif_neigh_node
Date: Wed, 16 Dec 2015 00:31:37 +0100	[thread overview]
Message-ID: <1450222316-1764-4-git-send-email-sven@narfation.org> (raw)
In-Reply-To: <1450222316-1764-1-git-send-email-sven@narfation.org>

It is not allowed to free the memory of an object which is part of a list
which is protected by rcu-read-side-critical sections without making sure
that no other context is accessing the object anymore. This usually happens
by removing the references to this object and then waiting until the rcu
grace period is over and no one (allowedly) accesses it anymore.

But the _now functions ignore this completely. They delete the entry from
the lists and immediately frees the entry. This has to be avoided and thus
these functions must be removed and all functions have to use instead
batadv_hardif_neigh_put.

Signed-off-by: Sven Eckelmann <sven@narfation.org>
---
 net/batman-adv/originator.c | 42 +++++-------------------------------------
 1 file changed, 5 insertions(+), 37 deletions(-)

diff --git a/net/batman-adv/originator.c b/net/batman-adv/originator.c
index 18305d3..7735118 100644
--- a/net/batman-adv/originator.c
+++ b/net/batman-adv/originator.c
@@ -219,38 +219,6 @@ batadv_hardif_neigh_free(struct batadv_hardif_neigh_node *hardif_neigh)
 }
 
 /**
- * batadv_hardif_neigh_release_now - release hardif neigh node from lists and
- *  free without waiting for rcu grace period
- * @ref: kref pointer of the neigh_node
- */
-static void batadv_hardif_neigh_release_now(struct kref *ref)
-{
-	struct batadv_hardif_neigh_node *hardif_neigh;
-
-	hardif_neigh = container_of(ref, struct batadv_hardif_neigh_node,
-				    refcount);
-
-	spin_lock_bh(&hardif_neigh->if_incoming->neigh_list_lock);
-	hlist_del_init_rcu(&hardif_neigh->list);
-	spin_unlock_bh(&hardif_neigh->if_incoming->neigh_list_lock);
-
-	batadv_hardif_free_ref_now(hardif_neigh->if_incoming);
-
-	batadv_hardif_neigh_free(hardif_neigh);
-}
-
-/**
- * batadv_hardif_neigh_put_now - decrement the hardif neighbors refcounter
- *  and possibly release it (without rcu callback)
- * @hardif_neigh: hardif neigh neighbor to free
- */
-static void
-batadv_hardif_neigh_put_now(struct batadv_hardif_neigh_node *hardif_neigh)
-{
-	kref_put(&hardif_neigh->refcount, batadv_hardif_neigh_release_now);
-}
-
-/**
  * batadv_hardif_neigh_free_rcu - free the hardif neigh_node
  * @rcu: rcu pointer of the neigh_node
  */
@@ -263,11 +231,11 @@ static void batadv_hardif_neigh_free_rcu(struct rcu_head *rcu)
 }
 
 /**
- * batadv_hardif_neigh_release_rcu - release hardif neigh node from lists and
+ * batadv_hardif_neigh_release - release hardif neigh node from lists and
  *  queue for free after rcu grace period
  * * @ref: kref pointer of the neigh_node
  */
-static void batadv_hardif_neigh_release_rcu(struct kref *ref)
+static void batadv_hardif_neigh_release(struct kref *ref)
 {
 	struct batadv_hardif_neigh_node *hardif_neigh;
 
@@ -290,7 +258,7 @@ static void batadv_hardif_neigh_release_rcu(struct kref *ref)
  */
 void batadv_hardif_neigh_put(struct batadv_hardif_neigh_node *hardif_neigh)
 {
-	kref_put(&hardif_neigh->refcount, batadv_hardif_neigh_release_rcu);
+	kref_put(&hardif_neigh->refcount, batadv_hardif_neigh_release);
 }
 
 /**
@@ -317,8 +285,8 @@ static void batadv_neigh_node_free_rcu(struct rcu_head *rcu)
 					       neigh_node->addr);
 	if (hardif_neigh) {
 		/* batadv_hardif_neigh_get() increases refcount too */
-		batadv_hardif_neigh_put_now(hardif_neigh);
-		batadv_hardif_neigh_put_now(hardif_neigh);
+		batadv_hardif_neigh_put(hardif_neigh);
+		batadv_hardif_neigh_put(hardif_neigh);
 	}
 
 	if (bao->bat_neigh_free)
-- 
2.6.4


  parent reply	other threads:[~2015-12-15 23:31 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-12-15 23:31 [B.A.T.M.A.N.] [PATCH 01/23] batman-adv: Fix list removal of batadv_hardif_neigh_node Sven Eckelmann
2015-12-15 23:31 ` [B.A.T.M.A.N.] [PATCH 02/23] batman-adv: Convert batadv_hardif_neigh_node to kref Sven Eckelmann
2015-12-15 23:31 ` [B.A.T.M.A.N.] [PATCH 03/23] batman-adv: Avoid recursive call_rcu for batadv_hardif_neigh_node Sven Eckelmann
2015-12-15 23:31 ` Sven Eckelmann [this message]
2015-12-15 23:31 ` [B.A.T.M.A.N.] [PATCH 05/23] batman-adv: Drop batadv_hardif_neigh_free_rcu Sven Eckelmann
2015-12-15 23:31 ` [B.A.T.M.A.N.] [PATCH 06/23] batman-adv: Convert batadv_gw_node to kref Sven Eckelmann
2015-12-15 23:31 ` [B.A.T.M.A.N.] [PATCH 07/23] batman-adv: Convert batadv_softif_vlan " Sven Eckelmann
2015-12-15 23:31 ` [B.A.T.M.A.N.] [PATCH 08/23] batman-adv: Convert batadv_bla_backbone_gw " Sven Eckelmann
2015-12-15 23:31 ` [B.A.T.M.A.N.] [PATCH 09/23] batman-adv: Convert batadv_bla_claim " Sven Eckelmann
2015-12-15 23:31 ` [B.A.T.M.A.N.] [PATCH 10/23] batman-adv: Convert batadv_nc_node " Sven Eckelmann
2015-12-15 23:31 ` [B.A.T.M.A.N.] [PATCH 11/23] batman-adv: Convert batadv_nc_path " Sven Eckelmann
2015-12-15 23:31 ` [B.A.T.M.A.N.] [PATCH 12/23] batman-adv: Convert batadv_dat_entry " Sven Eckelmann
2015-12-15 23:31 ` [B.A.T.M.A.N.] [PATCH 13/23] batman-adv: Convert batadv_tvlv_container " Sven Eckelmann
2015-12-15 23:31 ` [B.A.T.M.A.N.] [PATCH 14/23] batman-adv: Convert batadv_tvlv_handler " Sven Eckelmann
2015-12-15 23:31 ` [B.A.T.M.A.N.] [PATCH 15/23] batman-adv: Convert batadv_orig_node_free_rcu " Sven Eckelmann
2015-12-15 23:31 ` [B.A.T.M.A.N.] [PATCH 16/23] batman-adv: Convert batadv_neigh_ifinfo " Sven Eckelmann
2015-12-15 23:31 ` [B.A.T.M.A.N.] [PATCH 17/23] batman-adv: Convert batadv_orig_ifinfo " Sven Eckelmann
2015-12-15 23:31 ` [B.A.T.M.A.N.] [PATCH 18/23] batman-adv: Convert batadv_neigh_node " Sven Eckelmann
2015-12-15 23:31 ` [B.A.T.M.A.N.] [PATCH 19/23] batman-adv: Convert batadv_hard_iface " Sven Eckelmann
2015-12-15 23:31 ` [B.A.T.M.A.N.] [PATCH 20/23] batman-adv: Convert batadv_orig_node_vlan " Sven Eckelmann
2015-12-15 23:31 ` [B.A.T.M.A.N.] [PATCH 21/23] batman-adv: Convert batadv_orig_node " Sven Eckelmann
2015-12-15 23:31 ` [B.A.T.M.A.N.] [PATCH 22/23] batman-adv: Convert batadv_tt_common_entry " Sven Eckelmann
2015-12-15 23:31 ` [B.A.T.M.A.N.] [PATCH 23/23] batman-adv: Add lockdep assert for container_list_lock Sven Eckelmann
2015-12-19 22:34 ` [B.A.T.M.A.N.] [PATCH 01/23] batman-adv: Fix list removal of batadv_hardif_neigh_node Sven Eckelmann

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=1450222316-1764-4-git-send-email-sven@narfation.org \
    --to=sven@narfation.org \
    --cc=b.a.t.m.a.n@lists.open-mesh.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;
as well as URLs for NNTP newsgroup(s).