Skip to content

Commit 873aca2

Browse files
pmachatadavem330
authored andcommitted
net: bridge: Fix locking in br_fdb_find_port()
Callers of br_fdb_find() need to hold the hash lock, which br_fdb_find_port() doesn't do. However, since br_fdb_find_port() is not doing any actual FDB manipulation, the hash lock is not really needed at all. So convert to br_fdb_find_rcu(), surrounded by rcu_read_lock() / _unlock() pair. The device pointer copied from inside the FDB entry is then kept alive by the RTNL lock, which br_fdb_find_port() asserts. Fixes: 4d4fd36 ("net: bridge: Publish bridge accessor functions") Signed-off-by: Petr Machata <[email protected]> Acked-by: Nikolay Aleksandrov <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 6c206b2 commit 873aca2

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

net/bridge/br_fdb.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,9 +135,11 @@ struct net_device *br_fdb_find_port(const struct net_device *br_dev,
135135
return NULL;
136136

137137
br = netdev_priv(br_dev);
138-
f = br_fdb_find(br, addr, vid);
138+
rcu_read_lock();
139+
f = br_fdb_find_rcu(br, addr, vid);
139140
if (f && f->dst)
140141
dev = f->dst->dev;
142+
rcu_read_unlock();
141143

142144
return dev;
143145
}

0 commit comments

Comments
 (0)