netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] bridge: Don't put partly initialized fdb into hash
@ 2011-02-04 15:58 Pavel Emelyanov
  2011-02-04 21:02 ` David Miller
  0 siblings, 1 reply; 2+ messages in thread
From: Pavel Emelyanov @ 2011-02-04 15:58 UTC (permalink / raw)
  To: Stephen Hemminger, David Miller; +Cc: bridge, Linux Netdev List

The fdb_create() puts a new fdb into hash with only addr set. This is
not good, since there are callers, that search the hash w/o the lock
and access all the other its fields.

Applies to current netdev tree.

Signed-off-by: Pavel Emelyanov <xemul@openvz.org>

---

diff --git a/net/bridge/br_fdb.c b/net/bridge/br_fdb.c
index 2872393..88485cc 100644
--- a/net/bridge/br_fdb.c
+++ b/net/bridge/br_fdb.c
@@ -328,12 +328,12 @@ static struct net_bridge_fdb_entry *fdb_create(struct hlist_head *head,
 	fdb = kmem_cache_alloc(br_fdb_cache, GFP_ATOMIC);
 	if (fdb) {
 		memcpy(fdb->addr.addr, addr, ETH_ALEN);
-		hlist_add_head_rcu(&fdb->hlist, head);
-
 		fdb->dst = source;
 		fdb->is_local = is_local;
 		fdb->is_static = is_local;
 		fdb->ageing_timer = jiffies;
+
+		hlist_add_head_rcu(&fdb->hlist, head);
 	}
 	return fdb;
 }

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] bridge: Don't put partly initialized fdb into hash
  2011-02-04 15:58 [PATCH] bridge: Don't put partly initialized fdb into hash Pavel Emelyanov
@ 2011-02-04 21:02 ` David Miller
  0 siblings, 0 replies; 2+ messages in thread
From: David Miller @ 2011-02-04 21:02 UTC (permalink / raw)
  To: xemul; +Cc: shemminger, bridge, netdev

From: Pavel Emelyanov <xemul@parallels.com>
Date: Fri, 04 Feb 2011 18:58:08 +0300

> The fdb_create() puts a new fdb into hash with only addr set. This is
> not good, since there are callers, that search the hash w/o the lock
> and access all the other its fields.
> 
> Applies to current netdev tree.
> 
> Signed-off-by: Pavel Emelyanov <xemul@openvz.org>

Whoa, good catch.  Applied, thanks!

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2011-02-04 21:02 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-02-04 15:58 [PATCH] bridge: Don't put partly initialized fdb into hash Pavel Emelyanov
2011-02-04 21:02 ` David Miller

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).