From: Leon Romanovsky <leon@kernel.org>
To: Cygnus Qiu <eritque-arcus@ikuyo.dev>
Cc: bernard.metzler@linux.dev, jgg@ziepe.ca, cel@kernel.org,
linux-nfs@vger.kernel.org, linux-rdma@vger.kernel.org,
linux-kernel@vger.kernel.org, stable@vger.kernel.org
Subject: Re: [PATCH] RDMA/siw: don't complete a fenced READ twice on flush
Date: Thu, 26 Nov 2026 15:55:08 +0200 [thread overview]
Message-ID: <20261126135508.GO774860@unreal> (raw)
In-Reply-To: <20261125060646.155172-1-eritque-arcus@ikuyo.dev>
On Wed, Nov 25, 2026 at 01:06:46AM -0500, Cygnus Qiu wrote:
> siw_sq_flush() completes the READ in the TX slot while it is still
> SIW_WR_QUEUED, assuming a queued READ is not in the ORQ yet. That only
> holds when a full ORQ fenced it. siw_activate_tx_from_sq() copies a READ
> into a free ORQ slot, and siw_check_tx_fence() copies a fenced READ into
> the ORQ once a Read Response frees a slot; in both cases the WQE stays
> QUEUED until the TX path sends the Read Request. A flush in that window
> completes the READ from the ORQ and again from the TX slot: two
> IB_WC_WR_FLUSH_ERR completions for one work request.
>
> The peer controls the window. It advertises IRD 1, so the ORQ holds one
> READ, and answers the first Read Request with a Read Response and a FIN
> in one TCP segment: the FIN suspends TX before the Read Response moves
> the next READ into the ORQ, and the close flushes it.
>
> svcrdma's svc_rdma_wc_read_done() then puts the receive context twice,
> which links it into sc_recv_ctxts as a loop, and svc_rdma_free() reads
> it after freeing it and frees it a second time, a double free. svcrdma
> pulls the Read chunk before it decodes the RPC, so the peer needs no
> RPC credentials and no export access.
>
> Complete a QUEUED READ from the TX slot only while the ORQ fence is set.
>
> Found with afb-afl, an LLM-driven kernel audit/repro pipeline; the fix
> and this changelog were also drafted with LLM assistance. Reproduced on
> an unmodified KASAN build of mainline: a plain TCP client sends nfsd's
> svcrdma listener on siw an RDMA_NOMSG call whose Read chunk has two
> segments and answers the first Read Request as above.
> svcrdma_wc_read_flush fires twice for the chunk (5 of 5 runs), then:
>
> BUG: KASAN: slab-use-after-free in llist_del_first+0x150/0x170
> Read of size 8 at addr ffff8881119d9000 by task nfsd/183
> llist_del_first+0x150/0x170
> svc_rdma_recv_ctxts_destroy+0xf3/0x1b0
> svc_rdma_free+0xd8/0x2e0
> svc_xprt_free+0x22c/0x420
> Freed by task 183:
> kfree+0x162/0x500
> svc_rdma_recv_ctxts_destroy+0xe7/0x1b0
>
> Without KASAN and with SLAB_FREELIST_HARDENED, the double free is
> caught as "kernel BUG at mm/slub.c:605" in kfree() from
> svc_rdma_recv_ctxts_destroy() (4 of 4 runs).
>
> With this patch the chunk is flushed once and KASAN stays silent (4 of 4
> runs). The rdma-core tests could not run: the siw provider of rdma-core
> 66 fails an assertion in siw_destroy_cq() on the first test, with and
> without this patch.
>
> Fixes: f29dd55b0236 ("rdma/siw: queue pair methods")
> Cc: stable@vger.kernel.org
> Signed-off-by: Cygnus Qiu <eritque-arcus@ikuyo.dev>
> ---
> Tested on mainline 4405c18c95d2 (v7.4-rc3+) in QEMU. Applies to
> mainline 8d7fe9885c62.
>
> Sending the FIN only after the second Read Request has gone out, or
> with no Read Response at all (the fenced READ never enters the ORQ),
> gives one flush completion before and after the patch.
>
> siw_sq_flush() now relies on orq_fence. That bit shares a byte with
> tx_suspend, which siw_cm_llp_state_change() sets without the QP state
> lock. A lost update there already stalls the fenced READ in
> siw_check_tx_fence(); with this patch it would also lose that READ's
> flush completion. I did not try to hit that window.
>
> A reproducer and the test logs are available on request.
>
> drivers/infiniband/sw/siw/siw_qp.c | 7 ++++---
> 1 file changed, 4 insertions(+), 3 deletions(-)
Please read this suggestion https://lore.kernel.org/all/0037554862c0d9dce3ddafd1238347e4b16a5079.1795581896.git.wqu@suse.com
It is applicable to this patch as well.
Rewrote the commit message, add full KASAN stack trace and resubmit.
Thanks
prev parent reply other threads:[~2026-11-26 13:55 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-25 6:06 [PATCH] RDMA/siw: don't complete a fenced READ twice on flush Cygnus Qiu
2026-11-25 6:19 ` sashiko-bot
2026-11-26 13:55 ` Leon Romanovsky [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=20261126135508.GO774860@unreal \
--to=leon@kernel.org \
--cc=bernard.metzler@linux.dev \
--cc=cel@kernel.org \
--cc=eritque-arcus@ikuyo.dev \
--cc=jgg@ziepe.ca \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-nfs@vger.kernel.org \
--cc=linux-rdma@vger.kernel.org \
--cc=stable@vger.kernel.org \
/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