* [B.A.T.M.A.N.] [PATCH-maint 1/2] batman-adv: Only put gw_node list reference when removed
@ 2016-01-31 12:27 Sven Eckelmann
2016-01-31 12:28 ` [B.A.T.M.A.N.] [PATCH-maint 2/2] batman-adv: Only put orig_node_vlan " Sven Eckelmann
2016-02-10 10:43 ` [B.A.T.M.A.N.] [PATCH-maint 1/2] batman-adv: Only put gw_node " Marek Lindner
0 siblings, 2 replies; 4+ messages in thread
From: Sven Eckelmann @ 2016-01-31 12:27 UTC (permalink / raw)
To: b.a.t.m.a.n
The batadv_gw_node reference counter in batadv_gw_node_update can only be
reduced when the list entry was actually removed. Otherwise the reference
counter may reach zero when batadv_gw_node_update is called from two
different contexts for the same gw_node but only one context is actually
removing the entry from the list.
The release function for this gw_node is not called inside the list_lock
spinlock protected region because the function batadv_gw_node_update still
holds a gw_node reference for the object pointer on the stack. Thus the
actual release function (when required) will be called only at the end of
the function.
Fixes: 0511575c4d03 ("batman-adv: remove obsolete deleted attribute for gateway node")
Signed-off-by: Sven Eckelmann <sven@narfation.org>
---
net/batman-adv/gateway_client.c | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/net/batman-adv/gateway_client.c b/net/batman-adv/gateway_client.c
index 8350775..c9b8b48 100644
--- a/net/batman-adv/gateway_client.c
+++ b/net/batman-adv/gateway_client.c
@@ -527,11 +527,12 @@ void batadv_gw_node_update(struct batadv_priv *bat_priv,
* gets dereferenced.
*/
spin_lock_bh(&bat_priv->gw.list_lock);
- hlist_del_init_rcu(&gw_node->list);
+ if (!hlist_unhashed(&gw_node->list)) {
+ hlist_del_init_rcu(&gw_node->list);
+ batadv_gw_node_free_ref(gw_node);
+ }
spin_unlock_bh(&bat_priv->gw.list_lock);
- batadv_gw_node_free_ref(gw_node);
-
curr_gw = batadv_gw_get_selected_gw_node(bat_priv);
if (gw_node == curr_gw)
batadv_gw_reselect(bat_priv);
--
2.7.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [B.A.T.M.A.N.] [PATCH-maint 2/2] batman-adv: Only put orig_node_vlan list reference when removed
2016-01-31 12:27 [B.A.T.M.A.N.] [PATCH-maint 1/2] batman-adv: Only put gw_node list reference when removed Sven Eckelmann
@ 2016-01-31 12:28 ` Sven Eckelmann
2016-02-10 10:45 ` Marek Lindner
2016-02-10 10:43 ` [B.A.T.M.A.N.] [PATCH-maint 1/2] batman-adv: Only put gw_node " Marek Lindner
1 sibling, 1 reply; 4+ messages in thread
From: Sven Eckelmann @ 2016-01-31 12:28 UTC (permalink / raw)
To: b.a.t.m.a.n
The batadv_orig_node_vlan reference counter in batadv_tt_global_size_mod
can only be reduced when the list entry was actually removed. Otherwise the
reference counter may reach zero when batadv_tt_global_size_mod is called
from two different contexts for the same orig_node_vlan but only one
context is actually removing the entry from the list.
The release function for this orig_node_vlan is not called inside the
vlan_list_lock spinlock protected region because the function
batadv_tt_global_size_mod still holds a orig_node_vlan reference for the
object pointer on the stack. Thus the actual release function (when
required) will be called only at the end of the function.
Fixes: 21a57f6e7a3b ("batman-adv: make the TT CRC logic VLAN specific")
Signed-off-by: Sven Eckelmann <sven@narfation.org>
---
net/batman-adv/translation-table.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/net/batman-adv/translation-table.c b/net/batman-adv/translation-table.c
index 9fcf6bf..7301a92 100644
--- a/net/batman-adv/translation-table.c
+++ b/net/batman-adv/translation-table.c
@@ -311,9 +311,11 @@ static void batadv_tt_global_size_mod(struct batadv_orig_node *orig_node,
if (atomic_add_return(v, &vlan->tt.num_entries) == 0) {
spin_lock_bh(&orig_node->vlan_list_lock);
- hlist_del_init_rcu(&vlan->list);
+ if (!hlist_unhashed(&vlan->list)) {
+ hlist_del_init_rcu(&vlan->list);
+ batadv_orig_node_vlan_free_ref(vlan);
+ }
spin_unlock_bh(&orig_node->vlan_list_lock);
- batadv_orig_node_vlan_free_ref(vlan);
}
batadv_orig_node_vlan_free_ref(vlan);
--
2.7.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [B.A.T.M.A.N.] [PATCH-maint 1/2] batman-adv: Only put gw_node list reference when removed
2016-01-31 12:27 [B.A.T.M.A.N.] [PATCH-maint 1/2] batman-adv: Only put gw_node list reference when removed Sven Eckelmann
2016-01-31 12:28 ` [B.A.T.M.A.N.] [PATCH-maint 2/2] batman-adv: Only put orig_node_vlan " Sven Eckelmann
@ 2016-02-10 10:43 ` Marek Lindner
1 sibling, 0 replies; 4+ messages in thread
From: Marek Lindner @ 2016-02-10 10:43 UTC (permalink / raw)
To: The list for a Better Approach To Mobile Ad-hoc Networking
[-- Attachment #1: Type: text/plain, Size: 1008 bytes --]
On Sunday, January 31, 2016 13:27:59 Sven Eckelmann wrote:
> The batadv_gw_node reference counter in batadv_gw_node_update can only be
> reduced when the list entry was actually removed. Otherwise the reference
> counter may reach zero when batadv_gw_node_update is called from two
> different contexts for the same gw_node but only one context is actually
> removing the entry from the list.
>
> The release function for this gw_node is not called inside the list_lock
> spinlock protected region because the function batadv_gw_node_update still
> holds a gw_node reference for the object pointer on the stack. Thus the
> actual release function (when required) will be called only at the end of
> the function.
>
> Fixes: 0511575c4d03 ("batman-adv: remove obsolete deleted attribute for
> gateway node") Signed-off-by: Sven Eckelmann <sven@narfation.org>
> ---
> net/batman-adv/gateway_client.c | 7 ++++---
> 1 file changed, 4 insertions(+), 3 deletions(-)
Applied in revision c215e4e.
Thanks,
Marek
[-- Attachment #2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 473 bytes --]
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [B.A.T.M.A.N.] [PATCH-maint 2/2] batman-adv: Only put orig_node_vlan list reference when removed
2016-01-31 12:28 ` [B.A.T.M.A.N.] [PATCH-maint 2/2] batman-adv: Only put orig_node_vlan " Sven Eckelmann
@ 2016-02-10 10:45 ` Marek Lindner
0 siblings, 0 replies; 4+ messages in thread
From: Marek Lindner @ 2016-02-10 10:45 UTC (permalink / raw)
To: b.a.t.m.a.n
[-- Attachment #1: Type: text/plain, Size: 1040 bytes --]
On Sunday, January 31, 2016 13:28:00 Sven Eckelmann wrote:
> The batadv_orig_node_vlan reference counter in batadv_tt_global_size_mod
> can only be reduced when the list entry was actually removed. Otherwise the
> reference counter may reach zero when batadv_tt_global_size_mod is called
> from two different contexts for the same orig_node_vlan but only one
> context is actually removing the entry from the list.
>
> The release function for this orig_node_vlan is not called inside the
> vlan_list_lock spinlock protected region because the function
> batadv_tt_global_size_mod still holds a orig_node_vlan reference for the
> object pointer on the stack. Thus the actual release function (when
> required) will be called only at the end of the function.
>
> Fixes: 21a57f6e7a3b ("batman-adv: make the TT CRC logic VLAN specific")
> Signed-off-by: Sven Eckelmann <sven@narfation.org>
> ---
> net/batman-adv/translation-table.c | 6 ++++--
> 1 file changed, 4 insertions(+), 2 deletions(-)
Applied in revision ead9389.
Thanks,
Marek
[-- Attachment #2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 473 bytes --]
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2016-02-10 10:45 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-01-31 12:27 [B.A.T.M.A.N.] [PATCH-maint 1/2] batman-adv: Only put gw_node list reference when removed Sven Eckelmann
2016-01-31 12:28 ` [B.A.T.M.A.N.] [PATCH-maint 2/2] batman-adv: Only put orig_node_vlan " Sven Eckelmann
2016-02-10 10:45 ` Marek Lindner
2016-02-10 10:43 ` [B.A.T.M.A.N.] [PATCH-maint 1/2] batman-adv: Only put gw_node " Marek Lindner
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).