e1000: check on netif_running() before calling e1000_up()
Subsystems (2)
From: Bo Chen <[email protected]>
When the device is not up, the call to 'e1000_up()' from the error handling path of 'e1000_set_ringparam()' causes a kernel oops with a null-pointer dereference. The null-pointer dereference is triggered in function 'e1000_alloc_rx_buffers()' at line 'buffer_info = &rx_ring->buffer_info[i]'.
This bug was reported by COD, a tool for testing kernel module binaries I am building. This bug was also detected by KFI from Dr. Kai Cong.
This patch fixes the bug by checking on 'netif_running()' before calling 'e1000_up()' in 'e1000_set_ringparam()'.
--- drivers/net/ethernet/intel/e1000/e1000_ethtool.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/net/ethernet/intel/e1000/e1000_ethtool.c +2 -1
@@ -644,7 +644,8 @@ static int e1000_set_ringparam(struct net_device *netdev, err_alloc_rx:kfree (txdr); err_alloc_tx: -e1000_up (adapter); +if (netif_running (adapter->netdev)) +e1000_up (adapter); err_setup:clear_bit (__E1000_RESETTING, &adapter->flags);return err;
[Intel-wired-lan] e1000: ensure to free old tx/rx rings in set_ringparam()
From: Bo Chen <[email protected]>
In 'e1000_set_ringparam()', the tx_ring and rx_ring are updated with new value and the old tx/rx rings are freed only when the device is up. There are resource leaks on old tx/rx rings when the device is not up. This bug is reported by COD, a tool for testing kernel module binaries I am building.
This patch fixes the bug by always calling 'kfree()' on old tx/rx rings in 'e1000_set_ringparam()'.
--- drivers/net/ethernet/intel/e1000/e1000_ethtool.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/net/ethernet/intel/e1000/e1000_ethtool.c +2 -2
@@ -624,14 +624,14 @@ static int e1000_set_ringparam(struct net_device *netdev, adapter->tx_ring = tx_old;e1000_free_all_rx_resources (adapter);e1000_free_all_tx_resources (adapter); -kfree (tx_old); -kfree (rx_old); adapter->rx_ring = rxdr; adapter->tx_ring = txdr; err =e1000_up (adapter);if (err) goto err_setup; } +kfree (tx_old); +kfree (rx_old);clear_bit (__E1000_RESETTING, &adapter->flags);return 0 ;
Brown
Tested-by Aaron Brown[Intel-wired-lan] e1000: ensure to free old tx/rx rings in set_ringparam()
Quoted 18 lines
From: Intel-wired-lan [mailto:intel-wired-lan-bounces at osuosl.org] On Behalf Of Jeff Kirsher
Sent: Monday, July 23, 2018 9:02 AM
To: intel-wired-lan at lists.osuosl.org
Cc: Bo Chen <[email protected]>
Subject: [Intel-wired-lan] e1000: ensure to free old tx/rx rings inset_ringparam()From: Bo Chen <[email protected]>
In '
e1000_set_ringparam()', thetx_ringandrx_ringare updated with new value
and the old tx/rx rings are freed only when the device is up. There are resource
leaks on old tx/rx rings when the device is not up. This bug is reported by COD,
a tool for testing kernel module binaries I am building.
Quoted 8 lines
This patch fixes the bug by always calling '
kfree()' on old tx/rx rings in 'e1000_set_ringparam()'.Signed-off-by Bo Chen <[email protected]>Reviewed-by Alexander Duyck <[email protected]>--- drivers/net/ethernet/intel/e1000/e1000_ethtool.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
Brown
Tested-by Aaron BrownQuoted 19 lines
From: Intel-wired-lan [mailto:intel-wired-lan-bounces at osuosl.org] On Behalf Of Jeff Kirsher
Sent: Monday, July 23, 2018 9:01 AM
To: intel-wired-lan at lists.osuosl.org
Cc: Bo Chen <[email protected]>
Subject: [Intel-wired-lan] e1000: check onnetif_running()before callinge1000_up()From: Bo Chen <[email protected]>
When the device is not up, the call to '
e1000_up()' from the error handling path
of 'e1000_set_ringparam()' causes a kernel oops with a null-pointer dereference. The null-pointer dereference is triggered in function 'e1000_alloc_rx_buffers()' at line 'buffer_info= &rx_ring->buffer_info[i]'.This bug was reported by COD, a tool for testing kernel module binaries I am building. This bug was also detected by KFI from Dr. Kai Cong.
Quoted 8 lines
This patch fixes the bug by checking on '
netif_running()' before calling 'e1000_up()' in 'e1000_set_ringparam()'.Signed-off-by Bo Chen <[email protected]>Acked-by Alexander Duyck <[email protected]>--- drivers/net/ethernet/intel/e1000/e1000_ethtool.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)