* [PATCH AUTOSEL 5.8 14/53] ibmvnic fix NULL tx_pools and rx_tools issue at do_reset [not found] <20200907163220.1280412-1-sashal@kernel.org> @ 2020-09-07 16:31 ` Sasha Levin 2020-09-07 21:10 ` Jakub Kicinski 0 siblings, 1 reply; 3+ messages in thread From: Sasha Levin @ 2020-09-07 16:31 UTC (permalink / raw) To: linux-kernel, stable Cc: Sasha Levin, netdev, Mingming Cao, Dany Madden, linuxppc-dev, David S . Miller From: Mingming Cao <mmc@linux.vnet.ibm.com> [ Upstream commit 9f13457377907fa253aef560e1a37e1ca4197f9b ] At the time of do_rest, ibmvnic tries to re-initalize the tx_pools and rx_pools to avoid re-allocating the long term buffer. However there is a window inside do_reset that the tx_pools and rx_pools were freed before re-initialized making it possible to deference null pointers. This patch fix this issue by always check the tx_pool and rx_pool are not NULL after ibmvnic_login. If so, re-allocating the pools. This will avoid getting into calling reset_tx/rx_pools with NULL adapter tx_pools/rx_pools pointer. Also add null pointer check in reset_tx_pools and reset_rx_pools to safe handle NULL pointer case. Signed-off-by: Mingming Cao <mmc@linux.vnet.ibm.com> Signed-off-by: Dany Madden <drt@linux.ibm.com> Signed-off-by: David S. Miller <davem@davemloft.net> Signed-off-by: Sasha Levin <sashal@kernel.org> --- drivers/net/ethernet/ibm/ibmvnic.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/drivers/net/ethernet/ibm/ibmvnic.c b/drivers/net/ethernet/ibm/ibmvnic.c index 5afb3c9c52d20..d3a774331afc7 100644 --- a/drivers/net/ethernet/ibm/ibmvnic.c +++ b/drivers/net/ethernet/ibm/ibmvnic.c @@ -479,6 +479,9 @@ static int reset_rx_pools(struct ibmvnic_adapter *adapter) int i, j, rc; u64 *size_array; + if (!adapter->rx_pool) + return -1; + size_array = (u64 *)((u8 *)(adapter->login_rsp_buf) + be32_to_cpu(adapter->login_rsp_buf->off_rxadd_buff_size)); @@ -649,6 +652,9 @@ static int reset_tx_pools(struct ibmvnic_adapter *adapter) int tx_scrqs; int i, rc; + if (!adapter->tx_pool) + return -1; + tx_scrqs = be32_to_cpu(adapter->login_rsp_buf->num_txsubm_subcrqs); for (i = 0; i < tx_scrqs; i++) { rc = reset_one_tx_pool(adapter, &adapter->tso_pool[i]); @@ -2011,7 +2017,10 @@ static int do_reset(struct ibmvnic_adapter *adapter, adapter->req_rx_add_entries_per_subcrq != old_num_rx_slots || adapter->req_tx_entries_per_subcrq != - old_num_tx_slots) { + old_num_tx_slots || + !adapter->rx_pool || + !adapter->tso_pool || + !adapter->tx_pool) { release_rx_pools(adapter); release_tx_pools(adapter); release_napi(adapter); @@ -2024,10 +2033,14 @@ static int do_reset(struct ibmvnic_adapter *adapter, } else { rc = reset_tx_pools(adapter); if (rc) + netdev_dbg(adapter->netdev, "reset tx pools failed (%d)\n", + rc); goto out; rc = reset_rx_pools(adapter); if (rc) + netdev_dbg(adapter->netdev, "reset rx pools failed (%d)\n", + rc); goto out; } ibmvnic_disable_irqs(adapter); -- 2.25.1 ^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH AUTOSEL 5.8 14/53] ibmvnic fix NULL tx_pools and rx_tools issue at do_reset 2020-09-07 16:31 ` [PATCH AUTOSEL 5.8 14/53] ibmvnic fix NULL tx_pools and rx_tools issue at do_reset Sasha Levin @ 2020-09-07 21:10 ` Jakub Kicinski 2020-09-07 22:24 ` Sasha Levin 0 siblings, 1 reply; 3+ messages in thread From: Jakub Kicinski @ 2020-09-07 21:10 UTC (permalink / raw) To: Sasha Levin Cc: netdev, linux-kernel, stable, Mingming Cao, Dany Madden, linuxppc-dev, David S . Miller On Mon, 7 Sep 2020 12:31:40 -0400 Sasha Levin wrote: > [ Upstream commit 9f13457377907fa253aef560e1a37e1ca4197f9b ] > @@ -2024,10 +2033,14 @@ static int do_reset(struct ibmvnic_adapter *adapter, > } else { > rc = reset_tx_pools(adapter); > if (rc) > + netdev_dbg(adapter->netdev, "reset tx pools failed (%d)\n", > + rc); > goto out; > > rc = reset_rx_pools(adapter); > if (rc) > + netdev_dbg(adapter->netdev, "reset rx pools failed (%d)\n", > + rc); > goto out; > } > ibmvnic_disable_irqs(adapter); Hi Sasha! I just pushed this to net: 8ae4dff882eb ("ibmvnic: add missing parenthesis in do_reset()") You definitely want to pull that in if you decide to backport this one. ^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH AUTOSEL 5.8 14/53] ibmvnic fix NULL tx_pools and rx_tools issue at do_reset 2020-09-07 21:10 ` Jakub Kicinski @ 2020-09-07 22:24 ` Sasha Levin 0 siblings, 0 replies; 3+ messages in thread From: Sasha Levin @ 2020-09-07 22:24 UTC (permalink / raw) To: Jakub Kicinski Cc: netdev, linux-kernel, stable, Mingming Cao, Dany Madden, linuxppc-dev, David S . Miller On Mon, Sep 07, 2020 at 02:10:26PM -0700, Jakub Kicinski wrote: >On Mon, 7 Sep 2020 12:31:40 -0400 Sasha Levin wrote: >> [ Upstream commit 9f13457377907fa253aef560e1a37e1ca4197f9b ] > >> @@ -2024,10 +2033,14 @@ static int do_reset(struct ibmvnic_adapter *adapter, >> } else { >> rc = reset_tx_pools(adapter); >> if (rc) >> + netdev_dbg(adapter->netdev, "reset tx pools failed (%d)\n", >> + rc); >> goto out; >> >> rc = reset_rx_pools(adapter); >> if (rc) >> + netdev_dbg(adapter->netdev, "reset rx pools failed (%d)\n", >> + rc); >> goto out; >> } >> ibmvnic_disable_irqs(adapter); > >Hi Sasha! > >I just pushed this to net: > >8ae4dff882eb ("ibmvnic: add missing parenthesis in do_reset()") > >You definitely want to pull that in if you decide to backport this one. Will do, thanks! -- Thanks, Sasha ^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2020-09-07 22:25 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <20200907163220.1280412-1-sashal@kernel.org>
2020-09-07 16:31 ` [PATCH AUTOSEL 5.8 14/53] ibmvnic fix NULL tx_pools and rx_tools issue at do_reset Sasha Levin
2020-09-07 21:10 ` Jakub Kicinski
2020-09-07 22:24 ` Sasha Levin
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).