diff options
author | stephen hemminger <shemminger@vyatta.com> | 2010-11-15 01:38:13 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2010-11-15 14:13:17 -0500 |
commit | b5ed54e94d324f17c97852296d61a143f01b227a (patch) | |
tree | 2104d3cde24efc1145bc71beb4b61d79ed841132 /net/bridge/br_netlink.c | |
parent | 61391cde9eefac5cfcf6d214aa80c77e58b1626b (diff) |
bridge: fix RCU races with bridge port
The macro br_port_exists() is not enough protection when only
RCU is being used. There is a tiny race where other CPU has cleared port
handler hook, but is bridge port flag might still be set.
Signed-off-by: Stephen Hemminger <shemminger@vyatta.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/bridge/br_netlink.c')
-rw-r--r-- | net/bridge/br_netlink.c | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/net/bridge/br_netlink.c b/net/bridge/br_netlink.c index 4a6a378c84e3..e3de0a428f5d 100644 --- a/net/bridge/br_netlink.c +++ b/net/bridge/br_netlink.c | |||
@@ -119,11 +119,13 @@ static int br_dump_ifinfo(struct sk_buff *skb, struct netlink_callback *cb) | |||
119 | 119 | ||
120 | idx = 0; | 120 | idx = 0; |
121 | for_each_netdev(net, dev) { | 121 | for_each_netdev(net, dev) { |
122 | struct net_bridge_port *port = br_port_get(dev); | ||
123 | |||
122 | /* not a bridge port */ | 124 | /* not a bridge port */ |
123 | if (!br_port_exists(dev) || idx < cb->args[0]) | 125 | if (!port || idx < cb->args[0]) |
124 | goto skip; | 126 | goto skip; |
125 | 127 | ||
126 | if (br_fill_ifinfo(skb, br_port_get(dev), | 128 | if (br_fill_ifinfo(skb, port, |
127 | NETLINK_CB(cb->skb).pid, | 129 | NETLINK_CB(cb->skb).pid, |
128 | cb->nlh->nlmsg_seq, RTM_NEWLINK, | 130 | cb->nlh->nlmsg_seq, RTM_NEWLINK, |
129 | NLM_F_MULTI) < 0) | 131 | NLM_F_MULTI) < 0) |
@@ -169,9 +171,9 @@ static int br_rtm_setlink(struct sk_buff *skb, struct nlmsghdr *nlh, void *arg) | |||
169 | if (!dev) | 171 | if (!dev) |
170 | return -ENODEV; | 172 | return -ENODEV; |
171 | 173 | ||
172 | if (!br_port_exists(dev)) | ||
173 | return -EINVAL; | ||
174 | p = br_port_get(dev); | 174 | p = br_port_get(dev); |
175 | if (!p) | ||
176 | return -EINVAL; | ||
175 | 177 | ||
176 | /* if kernel STP is running, don't allow changes */ | 178 | /* if kernel STP is running, don't allow changes */ |
177 | if (p->br->stp_enabled == BR_KERNEL_STP) | 179 | if (p->br->stp_enabled == BR_KERNEL_STP) |