]> git.baikalelectronics.ru Git - kernel.git/commit
net: fix race on decreasing number of TX queues
authorJakub Kicinski <jakub.kicinski@netronome.com>
Tue, 13 Feb 2018 05:35:31 +0000 (21:35 -0800)
committerDavid S. Miller <davem@davemloft.net>
Wed, 14 Feb 2018 19:12:55 +0000 (14:12 -0500)
commit1ec3cf15e1c42eccd80a6c1b3b8b718e0787fbf4
tree40a1ec058bf4f38d60a53bfe8f5f3e4bfa135c89
parent5c30401ec4af41d2e21e2144014ddf6956b4bbba
net: fix race on decreasing number of TX queues

netif_set_real_num_tx_queues() can be called when netdev is up.
That usually happens when user requests change of number of
channels/rings with ethtool -L.  The procedure for changing
the number of queues involves resetting the qdiscs and setting
dev->num_tx_queues to the new value.  When the new value is
lower than the old one, extra care has to be taken to ensure
ordering of accesses to the number of queues vs qdisc reset.

Currently the queues are reset before new dev->num_tx_queues
is assigned, leaving a window of time where packets can be
enqueued onto the queues going down, leading to a likely
crash in the drivers, since most drivers don't check if TX
skbs are assigned to an active queue.

Fixes: 9befb6712980 ("net: allocate tx queues in register_netdevice")
Signed-off-by: Jakub Kicinski <jakub.kicinski@netronome.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/core/dev.c