Commit 8515ae38 authored by Florian Westphal's avatar Florian Westphal Committed by David S. Miller

rtnetlink: switch rtnl_link_get_slave_info_data_size to rcu

David Ahern reports following splat:
 RTNL: assertion failed at net/core/dev.c (5717)
 netdev_master_upper_dev_get+0x5f/0x70
 if_nlmsg_size+0x158/0x240
 rtnl_calcit.isra.26+0xa3/0xf0

rtnl_link_get_slave_info_data_size currently assumes RTNL protection, but
there appears to be no hard requirement for this, so use rcu instead.

At the time of this writing, there are three 'get_slave_size' callbacks
(now invoked under rcu): bond_get_slave_size, vrf_get_slave_size and
br_port_get_slave_size, all return constant only (i.e. they don't sleep).

Fixes: 6853dd48 ("rtnetlink: protect handler table with rcu")
Reported-by: default avatarDavid Ahern <dsahern@gmail.com>
Signed-off-by: default avatarFlorian Westphal <fw@strlen.de>
Acked-by: default avatarDavid Ahern <dsahern@gmail.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 5c2bb9b6
...@@ -402,16 +402,24 @@ static size_t rtnl_link_get_slave_info_data_size(const struct net_device *dev) ...@@ -402,16 +402,24 @@ static size_t rtnl_link_get_slave_info_data_size(const struct net_device *dev)
{ {
struct net_device *master_dev; struct net_device *master_dev;
const struct rtnl_link_ops *ops; const struct rtnl_link_ops *ops;
size_t size = 0;
master_dev = netdev_master_upper_dev_get((struct net_device *) dev); rcu_read_lock();
master_dev = netdev_master_upper_dev_get_rcu((struct net_device *)dev);
if (!master_dev) if (!master_dev)
return 0; goto out;
ops = master_dev->rtnl_link_ops; ops = master_dev->rtnl_link_ops;
if (!ops || !ops->get_slave_size) if (!ops || !ops->get_slave_size)
return 0; goto out;
/* IFLA_INFO_SLAVE_DATA + nested data */ /* IFLA_INFO_SLAVE_DATA + nested data */
return nla_total_size(sizeof(struct nlattr)) + size = nla_total_size(sizeof(struct nlattr)) +
ops->get_slave_size(master_dev, dev); ops->get_slave_size(master_dev, dev);
out:
rcu_read_unlock();
return size;
} }
static size_t rtnl_link_get_size(const struct net_device *dev) static size_t rtnl_link_get_size(const struct net_device *dev)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment