From: sashiko-bot@kernel.org
To: "Konstantin Taranov" <kotaranov@linux.microsoft.com>
Cc: linux-rdma@vger.kernel.org
Subject: Re: [PATCH rdma-next v2 04/10] RDMA/mana_ib: Maintain kernel RC QP state
Date: Sat, 03 Oct 2026 06:54:24 +0000 [thread overview]
Message-ID: <20261003065424.EDAA31F0089B@smtp.kernel.org> (raw)
In-Reply-To: <20261003064037.2092669-5-kotaranov@linux.microsoft.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] RDMA/mana_ib: NULL pointer dereference when arming doorbell for userspace RC QPs
--
commit d94733697b534fa1d978860b21f69a9735157978
Author: Konstantin Taranov <kotaranov@microsoft.com>
RDMA/mana_ib: Maintain kernel RC QP state
This commit updates mana_ib_modify_qp_state() to support RC QPs and initialize
the packet, message, and frame counters. It also arms the requester receive
queue at the initial PSN so that a CQE is generated when the PSN is
acknowledged.
> diff --git a/drivers/infiniband/hw/mana/qp.c b/drivers/infiniband/hw/mana/qp.c
> index edaf03372cd81..74cf80074e54f 100644
> --- a/drivers/infiniband/hw/mana/qp.c
> +++ b/drivers/infiniband/hw/mana/qp.c
[ ... ]
> @@ -1044,8 +1051,19 @@ static void mana_ib_modify_qp_state(struct ib_qp *ibqp, struct ib_qp_attr *attr,
> }
> }
>
> - if (attr_mask & IB_QP_SQ_PSN)
> + if (attr_mask & IB_QP_SQ_PSN) {
> + qp->sq_ssn = 1;
> + qp->sq_rsn = 1;
> + qp->sq_fsn = 1;
> qp->sq_psn = attr->sq_psn;
> + qp->pending_mmq_fence = false;
> +
> + if (qp->ibqp.qp_type == IB_QPT_RC) {
> + rq = qp->rc_qp.queues[MANA_RC_RECV_QUEUE_REQUESTER].kmem;
> + mana_gd_wq_ring_doorbell_ext(mdev_to_gc(mdev), rq, attr->sq_psn,
> + SET_ARM_BIT, MANA_PSN_CLIENT_OFFSET);
> + }
> + }
> }
[Severity: High]
Could this lead to a NULL pointer dereference when arming the doorbell for
userspace RC QPs?
When the RDMA Connection Manager (RDMA CM) handles connection establishment for
userspace RC QPs, it can call ib_modify_qp() with a NULL udata pointer. This
eventually invokes mana_ib_modify_qp_state().
Since udata is NULL during these kernel-driven CM transitions, the early return
check at the beginning of the function fails to distinguish userspace QPs, and
it incorrectly treats them as kernel QPs.
For userspace QPs, the kmem pointer fetched here is left uninitialized (NULL).
It is then passed to mana_gd_wq_ring_doorbell_ext(), which unconditionally
dereferences it when accessing queue->gdma_dev:
mana_gd_wq_ring_doorbell_ext()
mana_gd_ring_doorbell(gc, queue->gdma_dev->doorbell, ...)
This can result in a kernel panic that can be triggered by unprivileged
userspace applications initiating or receiving an RDMA CM connection. This
issue does not appear to be fixed in subsequent patches in the series.
Is there another way to correctly identify userspace QPs during these CM
transitions so we avoid dereferencing an uninitialized kmem pointer?
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261003064037.2092669-1-kotaranov@linux.microsoft.com?part=4
next prev parent reply other threads:[~2026-10-03 6:54 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-03 6:40 [PATCH rdma-next v2 00/10] RDMA/mana_ib: Add kernel RC and fast registration support Konstantin Taranov
2026-10-03 6:40 ` [PATCH rdma-next v2 01/10] RDMA/mana_ib: Allocate and map fast-registration MRs Konstantin Taranov
2026-10-03 6:55 ` sashiko-bot
2026-10-03 6:40 ` [PATCH rdma-next v2 02/10] RDMA/mana: Create and destroy kernel RC QPs Konstantin Taranov
2026-10-03 6:55 ` sashiko-bot
2026-10-03 6:40 ` [PATCH rdma-next v2 03/10] net/mana: Extend GDMA encoding for new RDMA WQEs Konstantin Taranov
2026-10-03 6:55 ` sashiko-bot
2026-10-03 6:40 ` [PATCH rdma-next v2 04/10] RDMA/mana_ib: Maintain kernel RC QP state Konstantin Taranov
2026-10-03 6:54 ` sashiko-bot [this message]
2026-10-03 6:40 ` [PATCH rdma-next v2 05/10] RDMA/mana_ib: Post receive WRs on kernel RC QPs Konstantin Taranov
2026-10-03 6:51 ` sashiko-bot
2026-10-03 6:40 ` [PATCH rdma-next v2 06/10] RDMA/mana_ib: Post send and memory-management WRs on " Konstantin Taranov
2026-10-03 6:58 ` sashiko-bot
2026-10-03 6:40 ` [PATCH rdma-next v2 07/10] RDMA/mana_ib: Poll RC completions using PSN and FSN progress Konstantin Taranov
2026-10-03 6:54 ` sashiko-bot
2026-10-03 6:40 ` [PATCH rdma-next v2 08/10] RDMA/mana_ib: Flush and notify CQs when kernel QPs enter ERR Konstantin Taranov
2026-10-03 6:58 ` sashiko-bot
2026-10-03 6:40 ` [PATCH rdma-next v2 09/10] RDMA/mana_ib: Handle error CQEs for RC QPs Konstantin Taranov
2026-10-03 6:53 ` sashiko-bot
2026-10-03 6:40 ` [PATCH rdma-next v2 10/10] RDMA/mana_ib: Drain kernel receive and send queues Konstantin Taranov
2026-10-03 7:01 ` sashiko-bot
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=20261003065424.EDAA31F0089B@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=kotaranov@linux.microsoft.com \
--cc=linux-rdma@vger.kernel.org \
--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