Linux RDMA and InfiniBand development
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Konstantin Taranov" <kotaranov@linux.microsoft.com>
Cc: linux-rdma@vger.kernel.org
Subject: Re: [PATCH rdma-next 10/10] RDMA/mana_ib: Drain kernel receive and send queues
Date: Fri, 02 Oct 2026 09:13:02 +0000	[thread overview]
Message-ID: <20261002091302.7707C1F00898@smtp.kernel.org> (raw)
In-Reply-To: <20261001182015.1757203-11-kotaranov@linux.microsoft.com>

Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [High] rdma/mana_ib: null pointer dereference in mana_ib_drain_sq() on UD/GSI QPs
- [Medium] rdma/mana_ib: user-triggerable WARN_ONCE via manual comp_handler invocation for direct CQs
--

commit cbadbb6a8acdc7477a3606271c2a70d35b56708b
Author: Konstantin Taranov <kotaranov@microsoft.com>

RDMA/mana_ib: Drain kernel receive and send queues

This commit implements the core drain callbacks for the mana_ib driver
by moving the QP to the ERR state, posting a completion-bearing marker,
and waiting until that marker is flushed.

> diff --git a/drivers/infiniband/hw/mana/qp.c b/drivers/infiniband/hw/mana/qp.c
> index 0f60909cbe848..4e6f15fb4887b 100644
> --- a/drivers/infiniband/hw/mana/qp.c
> +++ b/drivers/infiniband/hw/mana/qp.c

[ ... ]

> +void mana_ib_drain_sq(struct ib_qp *ibqp)
> +{
> +	struct ib_qp_attr attr = { .qp_state = IB_QPS_ERR };
> +	struct mana_ib_drain_cqe sdrain;
> +	struct ib_rdma_wr swr = {
> +		.wr = {
> +			.next = NULL,
> +			.wr_cqe = &sdrain.cqe,
> +			.opcode = IB_WR_SEND,
> +		},
> +	};

[Severity: High]
Does this WR structure correctly handle IB_QPT_UD or IB_QPT_GSI queue types?

When mana_ib_drain_sq() is called on a UD QP, it submits this stack-allocated
ib_rdma_wr structure to ib_post_send(). The mana driver's send path in
mana_ib_post_send_ud_one() expects an ib_ud_wr structure and downcasts this
generic WR into it.

Because the ib_rdma_wr structure is smaller than ib_ud_wr, the downcast
results in an out-of-bounds stack read over the overlapping memory. This
causes the evaluated ah pointer to be NULL.

When the hardware scatter-gather list is built later via
gdma_sgl[0].address = ah->dma_handle, dereferencing the NULL ah pointer
causes a kernel panic.

Since unprivileged userspace applications can create and drain UD QPs via
uverbs, can this be exploited as a local denial-of-service vulnerability?

[ ... ]

> +	ret = ib_post_send(ibqp, &swr.wr, &bad_swr);
> +	if (ret) {
> +		ibdev_err(ibqp->device, "Failed to post SQ drain WR: %d\n", ret);
> +		return;
> +	}
> +
> +	if (cq->comp_handler)
> +		cq->comp_handler(cq, cq->cq_context);

[Severity: Medium]
Is it safe to execute the comp_handler here unconditionally before checking
if the CQ uses direct polling?

For CQs instantiated with IB_POLL_DIRECT, the RDMA core strictly assigns
ib_cq_completion_direct() to the comp_handler to emit a WARN_ONCE on any
unsolicited execution.

Unprivileged users can trigger QP draining via uverbs on direct polling CQs,
meaning they can trivially trip this warning.

If the system is configured with panic_on_warn, could this lead to an
unexpected denial of service?

> +
> +	if (cq->poll_ctx == IB_POLL_DIRECT) {

[ ... ]

> +void mana_ib_drain_rq(struct ib_qp *ibqp)
> +{

[ ... ]

> +	ret = ib_post_recv(ibqp, &rwr, NULL);
> +	if (ret) {
> +		ibdev_err(ibqp->device, "Failed to post RQ drain WR: %d\n", ret);
> +		return;
> +	}
> +
> +	if (cq->comp_handler)
> +		cq->comp_handler(cq, cq->cq_context);

[Severity: Medium]
Similarly to the send queue drain, will this unconditional comp_handler
execution trigger the core's unsolicited completion warning for direct CQs?

> +
> +	if (cq->poll_ctx == IB_POLL_DIRECT) {

[ ... ]

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261001182015.1757203-1-kotaranov@linux.microsoft.com?part=10

      reply	other threads:[~2026-10-02  9:13 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-01 18:20 [PATCH rdma-next 00/10] RDMA/mana_ib: Add kernel RC and fast registration support Konstantin Taranov
2026-10-01 18:20 ` [PATCH rdma-next 01/10] RDMA/mana_ib: Allocate and map fast-registration MRs Konstantin Taranov
2026-10-02  9:13   ` sashiko-bot
2026-10-01 18:20 ` [PATCH rdma-next 02/10] RDMA/mana: Create and destroy kernel RC QPs Konstantin Taranov
2026-10-02  9:13   ` sashiko-bot
2026-10-01 18:20 ` [PATCH rdma-next 03/10] net/mana: Extend GDMA encoding for new RDMA WQEs Konstantin Taranov
2026-10-02  9:13   ` sashiko-bot
2026-10-01 18:20 ` [PATCH rdma-next 04/10] RDMA/mana_ib: Maintain kernel RC QP state Konstantin Taranov
2026-10-02  9:13   ` sashiko-bot
2026-10-01 18:20 ` [PATCH rdma-next 05/10] RDMA/mana_ib: Post receive WRs on kernel RC QPs Konstantin Taranov
2026-10-02  9:13   ` sashiko-bot
2026-10-01 18:20 ` [PATCH rdma-next 06/10] RDMA/mana_ib: Post send and memory-management WRs on " Konstantin Taranov
2026-10-02  9:13   ` sashiko-bot
2026-10-01 18:20 ` [PATCH rdma-next 07/10] RDMA/mana_ib: Poll RC completions using PSN and FSN progress Konstantin Taranov
2026-10-02  9:13   ` sashiko-bot
2026-10-01 18:20 ` [PATCH rdma-next 08/10] RDMA/mana_ib: Flush and notify CQs when kernel QPs enter ERR Konstantin Taranov
2026-10-02  9:12   ` sashiko-bot
2026-10-01 18:20 ` [PATCH rdma-next 09/10] RDMA/mana_ib: Handle error CQEs for RC QPs Konstantin Taranov
2026-10-02  9:13   ` sashiko-bot
2026-10-01 18:20 ` [PATCH rdma-next 10/10] RDMA/mana_ib: Drain kernel receive and send queues Konstantin Taranov
2026-10-02  9:13   ` 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=20261002091302.7707C1F00898@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