All of lore.kernel.org
 help / color / mirror / Atom feed
From: Selvin Xavier <selvin.xavier@broadcom.com>
To: jgg@ziepe.ca, dledford@redhat.com
Cc: linux-rdma@vger.kernel.org,
	Naresh Kumar PBS <nareshkumar.pbs@broadcom.com>,
	Selvin Xavier <selvin.xavier@broadcom.com>
Subject: [PATCH for-rc 6/6] RDMA/bnxt_re: Fix driver crash on unaligned PSN entry address
Date: Mon, 24 Aug 2020 11:14:36 -0700	[thread overview]
Message-ID: <1598292876-26529-7-git-send-email-selvin.xavier@broadcom.com> (raw)
In-Reply-To: <1598292876-26529-1-git-send-email-selvin.xavier@broadcom.com>

From: Naresh Kumar PBS <nareshkumar.pbs@broadcom.com>

When computing the first psn entry, driver checks
for page alignment. If this address is not page aligned,it
attempts to compute the offset in that page for later
use by using ALIGN macro. ALIGN macro does not return offset
bytes but the requested aligned address and hence cannot
be used directly to store as offset.
Since driver was using the address itself instead of offset,
it resulted in invalid address when filling the psn buffer.

Fixed driver to use PAGE_MASK macro to calculate the offset.

Fixes: fddcbbb02af4 ("RDMA/bnxt_re: Simplify obtaining queue entry from hw ring")
Signed-off-by: Naresh Kumar PBS <nareshkumar.pbs@broadcom.com>
Signed-off-by: Selvin Xavier <selvin.xavier@broadcom.com>
---
 drivers/infiniband/hw/bnxt_re/qplib_fp.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/infiniband/hw/bnxt_re/qplib_fp.c b/drivers/infiniband/hw/bnxt_re/qplib_fp.c
index 3535130..9f90cfe 100644
--- a/drivers/infiniband/hw/bnxt_re/qplib_fp.c
+++ b/drivers/infiniband/hw/bnxt_re/qplib_fp.c
@@ -937,10 +937,10 @@ static void bnxt_qplib_init_psn_ptr(struct bnxt_qplib_qp *qp, int size)
 
 	sq = &qp->sq;
 	hwq = &sq->hwq;
+	/* First psn entry */
 	fpsne = (u64)bnxt_qplib_get_qe(hwq, hwq->depth, &psn_pg);
 	if (!IS_ALIGNED(fpsne, PAGE_SIZE))
-		indx_pad = ALIGN(fpsne, PAGE_SIZE) / size;
-
+		indx_pad = (fpsne & ~PAGE_MASK) / size;
 	hwq->pad_pgofft = indx_pad;
 	hwq->pad_pg = (u64 *)psn_pg;
 	hwq->pad_stride = size;
-- 
2.5.5


  parent reply	other threads:[~2020-08-24 18:15 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-08-24 18:14 [PATCH for-rc 0/6] RDMA/bnxt_re: Bug fixes Selvin Xavier
2020-08-24 18:14 ` [PATCH for-rc 1/6] RDMA/bnxt_re: Remove the qp from list only if the qp destroy succeeds Selvin Xavier
2020-08-24 19:01   ` Leon Romanovsky
2020-08-24 19:36     ` Selvin Xavier
2020-08-24 22:00       ` Jason Gunthorpe
2020-08-25 11:44         ` Gal Pressman
2020-08-24 18:14 ` [PATCH for-rc 2/6] RDMA/bnxt_re: Do not report transparent vlan from QP1 Selvin Xavier
2020-08-24 18:14 ` [PATCH for-rc 3/6] RDMA/bnxt_re: Fix the qp table indexing Selvin Xavier
2020-08-24 18:14 ` [PATCH for-rc 4/6] RDMA/bnxt_re: Static NQ depth allocation Selvin Xavier
2020-08-24 18:14 ` [PATCH for-rc 5/6] RDMA/bnxt_re: Restrict the max_gids to 256 Selvin Xavier
2020-08-24 18:14 ` Selvin Xavier [this message]
2020-08-27 12:31 ` [PATCH for-rc 0/6] RDMA/bnxt_re: Bug fixes Jason Gunthorpe

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1598292876-26529-7-git-send-email-selvin.xavier@broadcom.com \
    --to=selvin.xavier@broadcom.com \
    --cc=dledford@redhat.com \
    --cc=jgg@ziepe.ca \
    --cc=linux-rdma@vger.kernel.org \
    --cc=nareshkumar.pbs@broadcom.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.