From: trix@redhat.com
To: selvin.xavier@broadcom.com, devesh.sharma@broadcom.com,
dledford@redhat.com, jgg@ziepe.ca, leon@kernel.org,
maxg@mellanox.com, galpress@amazon.com, michaelgur@nvidia.com,
monis@mellanox.com, gustavoars@kernel.org
Cc: linux-rdma@vger.kernel.org, linux-kernel@vger.kernel.org,
Tom Rix <trix@redhat.com>
Subject: [PATCH] RDMA/ocrdma: fix use after free in ocrdma_dealloc_ucontext_pd()
Date: Tue, 29 Dec 2020 18:46:53 -0800 [thread overview]
Message-ID: <20201230024653.1516495-1-trix@redhat.com> (raw)
From: Tom Rix <trix@redhat.com>
In ocrdma_dealloc_ucontext_pd() uctx->cntxt_pd is assigned to
the variable pd and then after uctx->cntxt_pd is freed, the
variable pd is passed to function _ocrdma_dealloc_pd() which
dereferences pd directly or through its call to
ocrdma_mbx_dealloc_pd().
Reorder the free using the variable pd.
Fixes: 21a428a019c9 ("RDMA: Handle PD allocations by IB/core")
Signed-off-by: Tom Rix <trix@redhat.com>
---
drivers/infiniband/hw/ocrdma/ocrdma_verbs.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/infiniband/hw/ocrdma/ocrdma_verbs.c b/drivers/infiniband/hw/ocrdma/ocrdma_verbs.c
index bc98bd950d99..3acb5c10b155 100644
--- a/drivers/infiniband/hw/ocrdma/ocrdma_verbs.c
+++ b/drivers/infiniband/hw/ocrdma/ocrdma_verbs.c
@@ -434,9 +434,9 @@ static void ocrdma_dealloc_ucontext_pd(struct ocrdma_ucontext *uctx)
pr_err("%s(%d) Freeing in use pdid=0x%x.\n",
__func__, dev->id, pd->id);
}
- kfree(uctx->cntxt_pd);
uctx->cntxt_pd = NULL;
_ocrdma_dealloc_pd(dev, pd);
+ kfree(pd);
}
static struct ocrdma_pd *ocrdma_get_ucontext_pd(struct ocrdma_ucontext *uctx)
--
2.27.0
next reply other threads:[~2020-12-30 2:48 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-12-30 2:46 trix [this message]
2020-12-30 5:31 ` [PATCH] RDMA/ocrdma: fix use after free in ocrdma_dealloc_ucontext_pd() Leon Romanovsky
2021-01-07 20:41 ` Jason Gunthorpe
2021-01-07 21:43 ` Tom Rix
2021-01-11 18:09 ` Selvin Xavier
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=20201230024653.1516495-1-trix@redhat.com \
--to=trix@redhat.com \
--cc=devesh.sharma@broadcom.com \
--cc=dledford@redhat.com \
--cc=galpress@amazon.com \
--cc=gustavoars@kernel.org \
--cc=jgg@ziepe.ca \
--cc=leon@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-rdma@vger.kernel.org \
--cc=maxg@mellanox.com \
--cc=michaelgur@nvidia.com \
--cc=monis@mellanox.com \
--cc=selvin.xavier@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 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).