mirror of
https://github.com/brain-hackers/linux-brain.git
synced 2024-06-09 23:36:23 +09:00
net-sysfs: take the rtnl lock when accessing xps_rxqs_map and num_tc
[ Upstream commit 4ae2bb81649dc03dfc95875f02126b14b773f7ab ]
Accesses to dev->xps_rxqs_map (when using dev->num_tc) should be
protected by the rtnl lock, like we do for netif_set_xps_queue. I didn't
see an actual bug being triggered, but let's be safe here and take the
rtnl lock while accessing the map in sysfs.
Fixes: 8af2c06ff4
("net-sysfs: Add interface for Rx queue(s) map per Tx queue")
Signed-off-by: Antoine Tenart <atenart@kernel.org>
Reviewed-by: Alexander Duyck <alexanderduyck@fb.com>
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
parent
1f6b04a2b2
commit
8602c20a91
|
@ -1347,22 +1347,29 @@ static struct netdev_queue_attribute xps_cpus_attribute __ro_after_init
|
||||||
|
|
||||||
static ssize_t xps_rxqs_show(struct netdev_queue *queue, char *buf)
|
static ssize_t xps_rxqs_show(struct netdev_queue *queue, char *buf)
|
||||||
{
|
{
|
||||||
|
int j, len, ret, num_tc = 1, tc = 0;
|
||||||
struct net_device *dev = queue->dev;
|
struct net_device *dev = queue->dev;
|
||||||
struct xps_dev_maps *dev_maps;
|
struct xps_dev_maps *dev_maps;
|
||||||
unsigned long *mask, index;
|
unsigned long *mask, index;
|
||||||
int j, len, num_tc = 1, tc = 0;
|
|
||||||
|
|
||||||
index = get_netdev_queue_index(queue);
|
index = get_netdev_queue_index(queue);
|
||||||
|
|
||||||
|
if (!rtnl_trylock())
|
||||||
|
return restart_syscall();
|
||||||
|
|
||||||
if (dev->num_tc) {
|
if (dev->num_tc) {
|
||||||
num_tc = dev->num_tc;
|
num_tc = dev->num_tc;
|
||||||
tc = netdev_txq_to_tc(dev, index);
|
tc = netdev_txq_to_tc(dev, index);
|
||||||
if (tc < 0)
|
if (tc < 0) {
|
||||||
return -EINVAL;
|
ret = -EINVAL;
|
||||||
|
goto err_rtnl_unlock;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
mask = bitmap_zalloc(dev->num_rx_queues, GFP_KERNEL);
|
mask = bitmap_zalloc(dev->num_rx_queues, GFP_KERNEL);
|
||||||
if (!mask)
|
if (!mask) {
|
||||||
return -ENOMEM;
|
ret = -ENOMEM;
|
||||||
|
goto err_rtnl_unlock;
|
||||||
|
}
|
||||||
|
|
||||||
rcu_read_lock();
|
rcu_read_lock();
|
||||||
dev_maps = rcu_dereference(dev->xps_rxqs_map);
|
dev_maps = rcu_dereference(dev->xps_rxqs_map);
|
||||||
|
@ -1388,10 +1395,16 @@ static ssize_t xps_rxqs_show(struct netdev_queue *queue, char *buf)
|
||||||
out_no_maps:
|
out_no_maps:
|
||||||
rcu_read_unlock();
|
rcu_read_unlock();
|
||||||
|
|
||||||
|
rtnl_unlock();
|
||||||
|
|
||||||
len = bitmap_print_to_pagebuf(false, buf, mask, dev->num_rx_queues);
|
len = bitmap_print_to_pagebuf(false, buf, mask, dev->num_rx_queues);
|
||||||
bitmap_free(mask);
|
bitmap_free(mask);
|
||||||
|
|
||||||
return len < PAGE_SIZE ? len : -EINVAL;
|
return len < PAGE_SIZE ? len : -EINVAL;
|
||||||
|
|
||||||
|
err_rtnl_unlock:
|
||||||
|
rtnl_unlock();
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static ssize_t xps_rxqs_store(struct netdev_queue *queue, const char *buf,
|
static ssize_t xps_rxqs_store(struct netdev_queue *queue, const char *buf,
|
||||||
|
|
Loading…
Reference in New Issue
Block a user