Skip to content

Commit

Permalink
bridge: use br_port_get_rtnl within rtnl lock
Browse files Browse the repository at this point in the history
current br_port_get_rcu is problematic in bridging path
(NULL deref). Change these calls in netlink path first.

Signed-off-by: Hong Zhiguo <zhiguohong@tencent.com>
Acked-by: Eric Dumazet <edumazet@google.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Hong Zhiguo authored and David S. Miller committed Sep 16, 2013
1 parent 3274f68 commit 1fb1754
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions net/bridge/br_netlink.c
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ int br_getlink(struct sk_buff *skb, u32 pid, u32 seq,
struct net_device *dev, u32 filter_mask)
{
int err = 0;
struct net_bridge_port *port = br_port_get_rcu(dev);
struct net_bridge_port *port = br_port_get_rtnl(dev);

/* not a bridge port and */
if (!port && !(filter_mask & RTEXT_FILTER_BRVLAN))
Expand Down Expand Up @@ -451,7 +451,7 @@ static size_t br_get_link_af_size(const struct net_device *dev)
struct net_port_vlans *pv;

if (br_port_exists(dev))
pv = nbp_get_vlan_info(br_port_get_rcu(dev));
pv = nbp_get_vlan_info(br_port_get_rtnl(dev));
else if (dev->priv_flags & IFF_EBRIDGE)
pv = br_get_vlan_info((struct net_bridge *)netdev_priv(dev));
else
Expand Down
2 changes: 1 addition & 1 deletion net/bridge/br_private.h
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ static inline struct net_bridge_port *br_port_get_rcu(const struct net_device *d
return br_port_exists(dev) ? port : NULL;
}

static inline struct net_bridge_port *br_port_get_rtnl(struct net_device *dev)
static inline struct net_bridge_port *br_port_get_rtnl(const struct net_device *dev)
{
return br_port_exists(dev) ?
rtnl_dereference(dev->rx_handler_data) : NULL;
Expand Down

0 comments on commit 1fb1754

Please sign in to comment.