From: sashiko-bot@kernel.org
To: "Abhijit Gangurde" <abhijit.gangurde@amd.com>
Cc: linux-rdma@vger.kernel.org
Subject: Re: [for-next v1 2/2] RDMA/ionic: Accept QP SQ and RQ rings as ioctl umem attributes
Date: Wed, 18 Nov 2026 15:51:34 +0000 [thread overview]
Message-ID: <sashiko-outbox-221381@kernel.org> (raw)
In-Reply-To: <20261118152313.113714-3-abhijit.gangurde@amd.com>
Thank you for your contribution! Sashiko AI review found 2 potential
issues to consider:
- [Medium] RDMA/ionic: double-fetch of buffer descriptor in
ionic_get_user_q_umem()
- [Medium] RDMA/ionic: missing DMABUF addr==0 handling in CQ and QP
qdesc validation
It also noticed 1 related pre-existing issue this patch does not
introduce:
- [Critical] RDMA/ionic: validation bypass via undefined behavior in
ionic_validate_qdesc() [1]
--
commit 2a0ba584011ea872720029ef7dae9322c2160a45
Author: Abhijit Gangurde <abhijit.gangurde@amd.com>
RDMA/ionic: Accept QP SQ and RQ rings as ioctl umem attributes
This commit adds support for pinning QP SQ and RQ rings from the
UVERBS_ATTR_CREATE_QP_SQ_BUF_UMEM and UVERBS_ATTR_CREATE_QP_RQ_BUF_UMEM
ioctl buffer descriptor attributes, splitting queue geometry validation into
ionic_validate_qdesc_geom() for dma-buf descriptors.
> diff --git a/drivers/infiniband/hw/ionic/ionic_controlpath.c b/drivers/infiniband/hw/ionic/ionic_controlpath.c
> index 11458262f280d..02f1972126ed0 100644
> --- a/drivers/infiniband/hw/ionic/ionic_controlpath.c
> +++ b/drivers/infiniband/hw/ionic/ionic_controlpath.c
> @@ -14,13 +14,9 @@
> #define ionic_set_ecn(tos) (((tos) | 2u) & ~1u)
> #define ionic_clear_ecn(tos) ((tos) & ~3u)
>
> -static int ionic_validate_qdesc(struct ionic_qdesc *q)
> +static int ionic_validate_qdesc_geom(struct ionic_qdesc *q)
> {
> - if (!q->addr || !q->size || !q->mask ||
> - !q->depth_log2 || !q->stride_log2)
> - return -EINVAL;
> -
> - if (q->addr & (PAGE_SIZE - 1))
> + if (!q->size || !q->mask || !q->depth_log2 || !q->stride_log2)
> return -EINVAL;
>
> if (q->mask != BIT(q->depth_log2) - 1)
> @@ -32,6 +28,14 @@ static int ionic_validate_qdesc(struct ionic_qdesc *q)
> return 0;
> }
>
> +static int ionic_validate_qdesc(struct ionic_qdesc *q)
> +{
> + if (!q->addr || (q->addr & (PAGE_SIZE - 1)))
> + return -EINVAL;
> +
> + return ionic_validate_qdesc_geom(q);
> +}
[Severity: Critical]
This problem wasn't introduced by this patch, but can a user bypass the queue
size check in ionic_validate_qdesc_geom() [1] when q->depth_log2 +
q->stride_log2 is 64 or greater?
drivers/infiniband/hw/ionic/ionic_controlpath.c:ionic_validate_qdesc_geom() {
...
if (q->size < BIT_ULL(q->depth_log2 + q->stride_log2))
return -EINVAL;
return 0;
}
Neither q->depth_log2 nor q->stride_log2 is bounded before the shift, so a
sum of 64 or more triggers shift undefined behavior (wrapping the shift count
modulo 64 on x86_64) and lets a small q->size pass validation before the
out-of-bounds queue parameters are sent to firmware.
> @@ -1993,10 +1997,57 @@ static void ionic_qp_sq_destroy_cmb(struct ionic_ibdev *dev,
> ionic_put_cmb(dev->lif_cfg.lif, qp->sq_cmb_pgid, qp->sq_cmb_order);
> }
>
> +static int ionic_get_user_q_umem(struct ionic_ibdev *dev, struct ionic_qdesc *q,
> + const struct uverbs_attr_bundle *attrs,
> + u16 attr_id, struct ib_umem **umem_out)
> +{
> + struct ib_uverbs_buffer_desc desc;
> + struct ib_umem *umem;
> + int rc;
> +
> + if (attrs && uverbs_attr_is_valid(attrs, attr_id)) {
> + rc = uverbs_get_buffer_desc(attrs, attr_id, &desc);
> + if (rc)
> + return rc;
> +
> + if (desc.length != q->size)
> + return -EINVAL;
> +
> + if (desc.type == IB_UVERBS_BUFFER_TYPE_DMABUF) {
> + if (desc.addr & (PAGE_SIZE - 1))
> + return -EINVAL;
> +
> + rc = ionic_validate_qdesc_geom(q);
[Severity: Medium]
Should the IB_UVERBS_BUFFER_TYPE_DMABUF branch also reject non-zero q->addr,
and does CQ creation need the same qdesc handling when req_cq->addr is zero?
The commit message notes that qdesc.addr is zero for a dma-buf descriptor,
which is why ionic_validate_qdesc_geom() is split out here, but this branch
does not check that q->addr is zero. Meanwhile, ionic_create_cq_common() in
commit "RDMA/ionic: Accept CQ ring buffers as ioctl umem attributes" still
calls ionic_validate_qdesc(req_cq) unconditionally before
ionic_cq_get_user_umem():
drivers/infiniband/hw/ionic/ionic_controlpath.c:ionic_create_cq_common() {
...
if (udata) {
rc = ionic_validate_qdesc(req_cq);
if (rc)
goto err_qdesc;
rc = ionic_cq_get_user_umem(dev, cq, req_cq, attrs, udma_idx);
...
}
Because ionic_validate_qdesc() rejects !q->addr, creating a dma-buf CQ with
req_cq->addr set to 0 always fails with -EINVAL.
> + } else if (desc.type == IB_UVERBS_BUFFER_TYPE_VA &&
> + desc.addr == q->addr) {
> + rc = ionic_validate_qdesc(q);
> + } else {
> + rc = -EINVAL;
> + }
> + if (rc)
> + return rc;
> +
> + umem = ib_umem_get_attr_or_va(&dev->ibdev, attrs, attr_id,
> + q->addr, q->size, 0);
[Severity: Medium]
Does calling ib_umem_get_attr_or_va() here re-fetch struct
ib_uverbs_buffer_desc from user memory after desc has already been validated?
UVERBS_ATTR_UMEM is defined without UA_ALLOC_AND_COPY and struct
ib_uverbs_buffer_desc is 32 bytes (not inline), so ib_umem_get_attr_or_va()
-> ib_umem_resolve_desc() -> uverbs_get_buffer_desc() performs a second
copy_from_user() of the descriptor and only checks that umem->length >=
q->size. A concurrent userspace thread modifying the descriptor between the
two reads can bypass the checks on desc.addr page alignment, desc.length ==
q->size, and desc.type, programming firmware with a mismatched or unaligned
ring mapping. Pinning the validated local descriptor via
ib_umem_get_desc(&dev->ibdev, &desc, 0) would avoid the second copy.
[1] https://sashiko.dev/#/bug/linux-f6f7b3eb-a66a-4c37-9e7c-001f6bd900bf
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261118152313.113714-1-abhijit.gangurde@amd.com?part=2
prev parent reply other threads:[~2026-11-18 15:51 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-18 15:23 [for-next v1 0/2] RDMA/ionic: Accept CQ, SQ, and RQ rings as umem attributes Abhijit Gangurde
2026-11-18 15:23 ` [for-next v1 1/2] RDMA/ionic: Accept CQ ring buffers as ioctl " Abhijit Gangurde
2026-11-18 15:54 ` sashiko-bot
2026-11-18 15:23 ` [for-next v1 2/2] RDMA/ionic: Accept QP SQ and RQ rings " Abhijit Gangurde
2026-11-18 15:51 ` 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-221381@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=abhijit.gangurde@amd.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