aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/ethernet
diff options
context:
space:
mode:
authorJohn Fastabend <john.fastabend@gmail.com>2013-11-08 03:51:10 -0500
committerDavid S. Miller <davem@davemloft.net>2013-11-08 15:21:08 -0500
commit51f3773bdeecf6ec48647dbfea335be4e507da0b (patch)
tree97e6a59cc7277266fb53749c6ff5313cc874d481 /drivers/net/ethernet
parent219354d4897fe06cb10d68308c14128a1e3fc074 (diff)
ixgbe: deleting dfwd stations out of order can cause null ptr deref
The number of stations in use is kept in the num_rx_pools counter in the ixgbe_adapter structure. This is in turn used by the queue allocation scheme to determine how many queues are needed to support the number of pools in use with the current feature set. This works as long as the pools are added and destroyed in order because (num_rx_pools * queues_per_pool) is equal to the last queue in use by a pool. But as soon as you delete a pool out of order this is no longer the case. So the above multiplication allocates to few queues and a pool may reference a ring that has not been allocated/initialized. To resolve use the bit mask of in use pools to determine the final pool being used and allocate enough queues so that we don't inadvertently remove its queues. # ip link add link eth2 \ numtxqueues 4 numrxqueues 4 txqueuelen 50 type macvlan # ip link set dev macvlan0 up # ip link add link eth2 \ numtxqueues 4 numrxqueues 4 txqueuelen 50 type macvlan # ip link set dev macvlan1 up # for i in {0..100}; do ip link set dev macvlan0 down; ip link set dev macvlan0 up; done; Signed-off-by: John Fastabend <john.r.fastabend@intel.com> Acked-by: Neil Horman <nhorman@tuxdriver.com> Acked-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/ethernet')
-rw-r--r--drivers/net/ethernet/intel/ixgbe/ixgbe_main.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c
index 2e17c307c6df..ec1bf3edb063 100644
--- a/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c
+++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c
@@ -7536,6 +7536,7 @@ static void *ixgbe_fwd_add(struct net_device *pdev, struct net_device *vdev)
7536{ 7536{
7537 struct ixgbe_fwd_adapter *fwd_adapter = NULL; 7537 struct ixgbe_fwd_adapter *fwd_adapter = NULL;
7538 struct ixgbe_adapter *adapter = netdev_priv(pdev); 7538 struct ixgbe_adapter *adapter = netdev_priv(pdev);
7539 unsigned int limit;
7539 int pool, err; 7540 int pool, err;
7540 7541
7541#ifdef CONFIG_RPS 7542#ifdef CONFIG_RPS
@@ -7566,10 +7567,11 @@ static void *ixgbe_fwd_add(struct net_device *pdev, struct net_device *vdev)
7566 pool = find_first_zero_bit(&adapter->fwd_bitmask, 32); 7567 pool = find_first_zero_bit(&adapter->fwd_bitmask, 32);
7567 adapter->num_rx_pools++; 7568 adapter->num_rx_pools++;
7568 set_bit(pool, &adapter->fwd_bitmask); 7569 set_bit(pool, &adapter->fwd_bitmask);
7570 limit = find_last_bit(&adapter->fwd_bitmask, 32);
7569 7571
7570 /* Enable VMDq flag so device will be set in VM mode */ 7572 /* Enable VMDq flag so device will be set in VM mode */
7571 adapter->flags |= IXGBE_FLAG_VMDQ_ENABLED | IXGBE_FLAG_SRIOV_ENABLED; 7573 adapter->flags |= IXGBE_FLAG_VMDQ_ENABLED | IXGBE_FLAG_SRIOV_ENABLED;
7572 adapter->ring_feature[RING_F_VMDQ].limit = adapter->num_rx_pools; 7574 adapter->ring_feature[RING_F_VMDQ].limit = limit + 1;
7573 adapter->ring_feature[RING_F_RSS].limit = vdev->num_tx_queues; 7575 adapter->ring_feature[RING_F_RSS].limit = vdev->num_tx_queues;
7574 7576
7575 /* Force reinit of ring allocation with VMDQ enabled */ 7577 /* Force reinit of ring allocation with VMDQ enabled */
@@ -7597,11 +7599,13 @@ static void ixgbe_fwd_del(struct net_device *pdev, void *priv)
7597{ 7599{
7598 struct ixgbe_fwd_adapter *fwd_adapter = priv; 7600 struct ixgbe_fwd_adapter *fwd_adapter = priv;
7599 struct ixgbe_adapter *adapter = fwd_adapter->real_adapter; 7601 struct ixgbe_adapter *adapter = fwd_adapter->real_adapter;
7602 unsigned int limit;
7600 7603
7601 clear_bit(fwd_adapter->pool, &adapter->fwd_bitmask); 7604 clear_bit(fwd_adapter->pool, &adapter->fwd_bitmask);
7602 adapter->num_rx_pools--; 7605 adapter->num_rx_pools--;
7603 7606
7604 adapter->ring_feature[RING_F_VMDQ].limit = adapter->num_rx_pools; 7607 limit = find_last_bit(&adapter->fwd_bitmask, 32);
7608 adapter->ring_feature[RING_F_VMDQ].limit = limit + 1;
7605 ixgbe_fwd_ring_down(fwd_adapter->netdev, fwd_adapter); 7609 ixgbe_fwd_ring_down(fwd_adapter->netdev, fwd_adapter);
7606 ixgbe_setup_tc(pdev, netdev_get_num_tc(pdev)); 7610 ixgbe_setup_tc(pdev, netdev_get_num_tc(pdev));
7607 netdev_dbg(pdev, "pool %i:%i queues %i:%i VSI bitmask %lx\n", 7611 netdev_dbg(pdev, "pool %i:%i queues %i:%i VSI bitmask %lx\n",