diff options
author | Petr Machata <petrm@mellanox.com> | 2018-06-08 09:11:47 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2018-06-08 19:58:31 -0400 |
commit | 873aca2ee86e533665a73292c4e308ded1e9bafe (patch) | |
tree | ea70348861f364b709118946a5216a91cd421a00 | |
parent | 6c206b20092a3623184cff9470dba75d21507874 (diff) |
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: 4d4fd36126d6 ("net: bridge: Publish bridge accessor functions")
Signed-off-by: Petr Machata <petrm@mellanox.com>
Acked-by: Nikolay Aleksandrov <nikolay@cumulusnetworks.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r-- | net/bridge/br_fdb.c | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/net/bridge/br_fdb.c b/net/bridge/br_fdb.c index b19e3104afd6..502f66349530 100644 --- a/net/bridge/br_fdb.c +++ b/net/bridge/br_fdb.c | |||
@@ -135,9 +135,11 @@ struct net_device *br_fdb_find_port(const struct net_device *br_dev, | |||
135 | return NULL; | 135 | return NULL; |
136 | 136 | ||
137 | br = netdev_priv(br_dev); | 137 | 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); | ||
139 | if (f && f->dst) | 140 | if (f && f->dst) |
140 | dev = f->dst->dev; | 141 | dev = f->dst->dev; |
142 | rcu_read_unlock(); | ||
141 | 143 | ||
142 | return dev; | 144 | return dev; |
143 | } | 145 | } |