All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Nicolas Morey" <nmorey@suse.com>
Cc: linux-rdma@vger.kernel.org
Subject: Re: [PATCH v3] RDMA/rxe: Sanitize receive WQE in local buffer
Date: Thu, 10 Sep 2026 09:02:41 +0000	[thread overview]
Message-ID: <20260910090242.053F51F000FF@smtp.kernel.org> (raw)
In-Reply-To: <20260910083712.1595862-1-nmorey@suse.com>

Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:

New issues:
- [High] Copying into the inner `wqe` field triggers a FORTIFY_SOURCE field-spanning write WARN_ONCE or panic.

Pre-existing issues:
- [Critical] Double-fetch TOCTOU vulnerability in the send path (`rxe_req.c`) leading to out-of-bounds memory access.
--

commit 5c427e8b4bbe51e8f334533fce0d0db77db27960
Author: Nicolas Morey <nmorey@suse.com>

RDMA/rxe: Sanitize receive WQE in local buffer

This patch sanitizes receive work queue elements by copying them to a local
buffer and validating their fields. This addresses TOCTOU races and
out-of-bounds accesses during the receive path.

> diff --git a/drivers/infiniband/sw/rxe/rxe_resp.c b/drivers/infiniband/sw/rxe/rxe_resp.c
> --- a/drivers/infiniband/sw/rxe/rxe_resp.c
> +++ b/drivers/infiniband/sw/rxe/rxe_resp.c
[ ... ]
> @@ -257,6 +257,47 @@ static enum resp_states check_op_valid(struct rxe_qp *qp,
>  	return RESPST_CHK_RESOURCE;
>  }
>  
> +static enum resp_states recv_wqe_sanitize(struct rxe_qp *qp,
> +					struct rxe_recv_wqe *kernel_wqe,
> +					struct rxe_recv_wqe *user_wqe,
> +					int max_sge)
> +{
[ ... ]
> +	size = struct_size(user_wqe, dma.sge, num_sge);
> +	memcpy(kernel_wqe, user_wqe, size);

[Severity: High]
Will this memcpy trigger a FORTIFY_SOURCE warning or kernel panic due to a
field-spanning write?

When recv_wqe_sanitize is called from get_srq_wqe, it is passed a pointer to
the inner wqe sub-object:

> +	err = recv_wqe_sanitize(qp, &qp->resp.srq_wqe.wqe, wqe, srq->rq.max_sge);

Because the destination pointer points specifically to the nested wqe struct
within the larger srq_wqe struct, the compiler evaluates the size of this
object to exactly 40 bytes. When memcpy attempts to write up to
40 + 16 * max_sge bytes, it violates this strict bounds check, resulting in a
denial of service on the receive path.

[ ... ]

[Severity: Critical]
This is a pre-existing issue, but I noticed the symmetric send path appears
to suffer from a very similar TOCTOU vulnerability that might lead to an
out-of-bounds memory access.

In rxe_req.c, rxe_requester performs a bounds check on cur_sge while the
data is still in shared memory:

        if (unlikely(wqe->dma.num_sge > qp->sq.max_sge ||
                     (wqe->dma.resid &&
                      wqe->dma.cur_sge >= qp->sq.max_sge))) {

However, a malicious user could potentially overwrite cur_sge immediately
after this check. Later, copy_data in rxe_mr.c re-fetches cur_sge directly
from the shared memory and uses it as an array index:

        struct rxe_sge          *sge    = &dma->sge[dma->cur_sge];

Could this bypass the validation and read memory outside the wqe if the
value is mutated between the check and the use?

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260910083712.1595862-1-nmorey@suse.com?part=1

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

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-10  8:37 [PATCH v3] RDMA/rxe: Sanitize receive WQE in local buffer Nicolas Morey
2026-09-10  9:02 ` 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=20260910090242.053F51F000FF@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=linux-rdma@vger.kernel.org \
    --cc=nmorey@suse.com \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.