From: sashiko-bot@kernel.org
To: "Piyus Kedia" <piyus@iiitd.ac.in>, linux-rdma@vger.kernel.org
Subject: Re: [PATCH net v2] net/rds: do not leave ic->i_cm_id pointing at a freed cm_id
Date: Wed, 02 Dec 2026 12:03:56 +0000 [thread overview]
Message-ID: <sashiko-outbox-245659@kernel.org> (raw)
In-Reply-To: <20261201120335.3527546-1-piyus@iiitd.ac.in>
Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Medium] net/rds: transient ERR_PTR in ic->i_cm_id in
rds_ib_conn_path_connect()
--
commit 4e0ce09e70c35a382957e4408ddec7b9d686e123
Author: Piyus Kedia <piyus@iiitd.ac.in>
net/rds: do not leave ic->i_cm_id pointing at a freed cm_id
This commit clears ic->i_cm_id with WRITE_ONCE() before calling
rdma_destroy_id() and reads it with READ_ONCE() in the FRMR registration
and invalidation paths, adding a NULL check in rds_ib_post_reg_frmr().
Link: https://lore.kernel.org/all/20261128033737.467966-1-piyus@iiitd.ac.in/
> diff --git a/net/rds/ib_cm.c b/net/rds/ib_cm.c
> index 16bfeaaf3b974..1de3866b1ab62 100644
> --- a/net/rds/ib_cm.c
> +++ b/net/rds/ib_cm.c
> @@ -978,6 +978,7 @@ int rds_ib_conn_path_connect(struct rds_conn_path *cp)
> struct sockaddr_storage src, dest;
> rdma_cm_event_handler handler;
> struct rds_ib_connection *ic;
> + struct rdma_cm_id *cm_id;
> int ret;
>
> ic = conn->c_transport_data;
> @@ -994,7 +995,7 @@ int rds_ib_conn_path_connect(struct rds_conn_path *cp)
> RDMA_PS_TCP, IB_QPT_RC);
> if (IS_ERR(ic->i_cm_id)) {
> ret = PTR_ERR(ic->i_cm_id);
> - ic->i_cm_id = NULL;
> + WRITE_ONCE(ic->i_cm_id, NULL);
> rdsdebug("rdma_create_id() failed: %d\n", ret);
> goto out;
> }
[Severity: Medium]
Can a lockless reader observe an ERR_PTR in ic->i_cm_id when
rdma_create_id() fails?
rds_ib_conn_path_connect() assigns the return value of rdma_create_id()
directly to ic->i_cm_id before checking IS_ERR(ic->i_cm_id) and clearing
it with WRITE_ONCE(ic->i_cm_id, NULL). Because the lockless readers in
rds_ib_get_mr(), rds_ib_post_reg_frmr() and rds_ib_post_inv() only check
!i_cm_id before dereferencing i_cm_id->qp, a concurrent reader can sample
the error pointer during that window and fault:
CPU0 CPU1
rds_ib_conn_path_connect()
ic->i_cm_id = rdma_create_id(...)
/* returns ERR_PTR(-ENOMEM) */
rds_ib_post_inv()
i_cm_id = READ_ONCE(ibmr->ic->i_cm_id)
if (!i_cm_id || !i_cm_id->qp ...)
/* faults on ERR_PTR->qp */
if (IS_ERR(ic->i_cm_id))
WRITE_ONCE(ic->i_cm_id, NULL)
Storing the result of rdma_create_id() in the local cm_id variable and
only publishing it to ic->i_cm_id with WRITE_ONCE() after IS_ERR(cm_id)
succeeds would avoid exposing an error pointer to readers.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261201120335.3527546-1-piyus@iiitd.ac.in?part=1
prev parent reply other threads:[~2026-12-02 12:03 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-01 12:03 [PATCH net v2] net/rds: do not leave ic->i_cm_id pointing at a freed cm_id Piyus Kedia
2026-12-02 12:03 ` sashiko-bot [this message]
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=sashiko-outbox-245659@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=linux-rdma@vger.kernel.org \
--cc=piyus@iiitd.ac.in \
--cc=sashiko-reviews@lists.linux.dev \
/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