From: WenTao Liang <vulab@iscas.ac.cn>
To: Jason Gunthorpe <jgg@ziepe.ca>, Leon Romanovsky <leon@kernel.org>,
linux-rdma@vger.kernel.org
Cc: stable@vger.kernel.org, linux-kernel@vger.kernel.org,
WenTao Liang <vulab@iscas.ac.cn>
Subject: [PATCH] fix: infiniband/rxe: check_rkey: fix refcount underflow due to unchecked rxe_get return value
Date: Fri, 26 Jun 2026 23:05:11 +0800 [thread overview]
Message-ID: <20260626150511.50084-1-vulab@iscas.ac.cn> (raw)
rxe_get is a conditional get (kref_get_unless_zero) that returns 0 when
the object's refcount is already zero. In check_rkey, the return value of
rxe_get(mr) is ignored. If rxe_get fails (returns 0), the code continues
to use mr without a valid reference, and error paths will call
rxe_put(mr) on an unheld reference, causing a refcount underflow.
Check the return value of rxe_get and bail out with an error when it fails.
Cc: stable@vger.kernel.org
Fixes: 290c4a902b79 ("RDMA/rxe: Fix \"Replace mr by rkey in responder resources\"")
Signed-off-by: WenTao Liang <vulab@iscas.ac.cn>
---
drivers/infiniband/sw/rxe/rxe_resp.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/drivers/infiniband/sw/rxe/rxe_resp.c b/drivers/infiniband/sw/rxe/rxe_resp.c
index 9cb2f6fbf2dd..0c3f3930b494 100644
--- a/drivers/infiniband/sw/rxe/rxe_resp.c
+++ b/drivers/infiniband/sw/rxe/rxe_resp.c
@@ -514,7 +514,12 @@ static enum resp_states check_rkey(struct rxe_qp *qp,
if (mw->access & IB_ZERO_BASED)
qp->resp.offset = mw->addr;
- rxe_get(mr);
+ if (!rxe_get(mr)) {
+ rxe_put(mw);
+ mw = NULL;
+ state = get_rkey_violation_state(pkt);
+ goto err;
+ }
rxe_put(mw);
mw = NULL;
} else {
--
2.39.5 (Apple Git-154)
next reply other threads:[~2026-06-26 15:05 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-26 15:05 WenTao Liang [this message]
2026-06-27 1:42 ` yanjun.zhu
[not found] ` <6597C9CE-970B-4650-97BD-651F8226E3D9@iscas.ac.cn>
[not found] ` <f3a8dd38-7f9e-42d4-8e53-a5d1a973979d@linux.dev>
2026-07-05 12:26 ` Leon Romanovsky
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=20260626150511.50084-1-vulab@iscas.ac.cn \
--to=vulab@iscas.ac.cn \
--cc=jgg@ziepe.ca \
--cc=leon@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-rdma@vger.kernel.org \
--cc=stable@vger.kernel.org \
/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
all inboxes | Powered by JetHome®