netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net V2] cxgb4:Fix out-of-bounds MSI-X info array access
@ 2019-10-03 22:36 Vishal Kulkarni
  2019-10-04 21:42 ` David Miller
  0 siblings, 1 reply; 2+ messages in thread
From: Vishal Kulkarni @ 2019-10-03 22:36 UTC (permalink / raw)
  To: netdev, davem; +Cc: nirranjan, Vishal Kulkarni, Shahjada Abul Husain

When fetching free MSI-X vectors for ULDs, check for the error code
before accessing MSI-X info array. Otherwise, an out-of-bounds access is
attempted, which results in kernel panic.

Fixes: 94cdb8bb993a ("cxgb4: Add support for dynamic allocation of resources for ULD")
Signed-off-by: Shahjada Abul Husain <shahjada@chelsio.com>
Signed-off-by: Vishal Kulkarni <vishal@chelsio.com>
---
V2:
- Fix compilation warning
- Don't split Fixes tag into multiple lines
---
 drivers/net/ethernet/chelsio/cxgb4/cxgb4_uld.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_uld.c b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_uld.c
index 5b60224..a4dead4 100644
--- a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_uld.c
+++ b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_uld.c
@@ -137,13 +137,12 @@ static int uldrx_handler(struct sge_rspq *q, const __be64 *rsp,
 static int alloc_uld_rxqs(struct adapter *adap,
 			  struct sge_uld_rxq_info *rxq_info, bool lro)
 {
-	struct sge *s = &adap->sge;
 	unsigned int nq = rxq_info->nrxq + rxq_info->nciq;
+	int i, err, msi_idx, que_idx = 0, bmap_idx = 0;
 	struct sge_ofld_rxq *q = rxq_info->uldrxq;
 	unsigned short *ids = rxq_info->rspq_id;
-	unsigned int bmap_idx = 0;
+	struct sge *s = &adap->sge;
 	unsigned int per_chan;
-	int i, err, msi_idx, que_idx = 0;
 
 	per_chan = rxq_info->nrxq / adap->params.nports;
 
@@ -161,6 +160,10 @@ static int alloc_uld_rxqs(struct adapter *adap,
 
 		if (msi_idx >= 0) {
 			bmap_idx = get_msix_idx_from_bmap(adap);
+			if (bmap_idx < 0) {
+				err = -ENOSPC;
+				goto freeout;
+			}
 			msi_idx = adap->msix_info_ulds[bmap_idx].idx;
 		}
 		err = t4_sge_alloc_rxq(adap, &q->rspq, false,
-- 
1.8.3.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH net V2] cxgb4:Fix out-of-bounds MSI-X info array access
  2019-10-03 22:36 [PATCH net V2] cxgb4:Fix out-of-bounds MSI-X info array access Vishal Kulkarni
@ 2019-10-04 21:42 ` David Miller
  0 siblings, 0 replies; 2+ messages in thread
From: David Miller @ 2019-10-04 21:42 UTC (permalink / raw)
  To: vishal; +Cc: netdev, nirranjan, shahjada

From: Vishal Kulkarni <vishal@chelsio.com>
Date: Fri,  4 Oct 2019 04:06:15 +0530

> When fetching free MSI-X vectors for ULDs, check for the error code
> before accessing MSI-X info array. Otherwise, an out-of-bounds access is
> attempted, which results in kernel panic.
> 
> Fixes: 94cdb8bb993a ("cxgb4: Add support for dynamic allocation of resources for ULD")
> Signed-off-by: Shahjada Abul Husain <shahjada@chelsio.com>
> Signed-off-by: Vishal Kulkarni <vishal@chelsio.com>
> ---
> V2:
> - Fix compilation warning
> - Don't split Fixes tag into multiple lines

Applied, thanks.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2019-10-04 21:42 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-10-03 22:36 [PATCH net V2] cxgb4:Fix out-of-bounds MSI-X info array access Vishal Kulkarni
2019-10-04 21:42 ` David Miller

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).