Skip to contentSkip to conversation

bridge: Don't put partly initialized fdb into hash

PATCH In review Pavel Emelyanov 2 participants 2 messages Feb 4, 2011

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

PATCH 1/1 bridge: Don't put partly initialized fdb into hash

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.

---

net/bridge/br_fdb.c +2 -2
index 2872393..88485cc 100644
@@ -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;
 }
maintainer
#1 lore raw

From: Pavel Emelyanov <[email protected]>
Date: Fri, 04 Feb 2011 18:58:08 +0300

Quoted 7 lines

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.

Whoa, good catch. Applied, thanks!