mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH v2 0/2] RDMA/srp: fix use-after-free of a request in srp_destroy_qp()
@ 2026-08-18  3:52 Yehyeong Lee
  2026-08-18  3:52 ` [PATCH v2 1/2] " Yehyeong Lee
                   ` (2 more replies)
  0 siblings, 3 replies; 8+ messages in thread
From: Yehyeong Lee @ 2026-08-18  3:52 UTC (permalink / raw)
  To: linux-rdma; +Cc: bvanassche, jgg, leon, linux-kernel, Yehyeong Lee

Bart asked whether reordering srp_remove_target() also fixes the crash.
It does.  Against the same test target, the report appears in 5 of 5
runs without his patch and in 0 of 5 with it.  The drain still finds
the same two completions; the request pool now outlives it.  A
conforming target was unchanged over 5 runs each way.  Both patches
applied together behave the same way.  I never reached the SCSI error
handler.

Each patch stops the crash on its own, so this series carries both.
Patch 1 takes the shared ib_cqe out of the request; it is tagged for
stable.  Patch 2 is Bart's, carried as posted.  Whether it should go to
stable too is his call.

Two notes on patch 2, from source only.  srp_stop_rport_timers() is
documented as "Must be called after srp_remove_host() and
scsi_remove_host()" (scsi_transport_srp.c:789); patch 2 calls it before
both.  And the host now stays SHOST_RUNNING until the end, so a device
added by a late scan would miss the cache sync.  Its commands fail with
DID_NO_CONNECT, so that is a lost sync, not a crash.

v1: https://lore.kernel.org/linux-rdma/20260812190418.200337-1-yhlee@isslab.korea.ac.kr/

Bart Van Assche (1):
  RDMA/srp: Fix srp_remove_target()

Yehyeong Lee (1):
  RDMA/srp: fix use-after-free of a request in srp_destroy_qp()

 drivers/infiniband/ulp/srp/ib_srp.c | 30 +++++++++++++++++------------
 drivers/infiniband/ulp/srp/ib_srp.h |  8 +++++++-
 2 files changed, 25 insertions(+), 13 deletions(-)

-- 
2.43.0


^ permalink raw reply	[flat|nested] 8+ messages in thread
* Re: [PATCH v2 1/2] RDMA/srp: fix use-after-free of a request in srp_destroy_qp()
@ 2026-08-19  1:48 Yehyeong Lee
  0 siblings, 0 replies; 8+ messages in thread
From: Yehyeong Lee @ 2026-08-19  1:48 UTC (permalink / raw)
  To: bvanassche; +Cc: linux-rdma, jgg, leon, linux-kernel, stable

On 8/18/26 9:26 AM, Bart Van Assche wrote:
> This patch introduces a race condition because it associates a single
> CQE data structure with multiple concurrently submitted work requests.

Thanks for looking at this.

struct ib_cqe holds one member.  After this patch ch->reg_cqe.done and
ch->inv_cqe.done are written only in srp_create_ch_ib(), either before
the first QP exists or after srp_destroy_qp() has drained and destroyed
the previous one, and both writes store the same value every time.
srp_handle_qp_err() finds the channel through cq->cq_context, so neither
handler reads the cqe back.

The sharing is not new: one command posts up to mr_per_cmd REG_MR work
requests, all carrying &req->reg_cqe.  ib_srpt shares ch->zw_cqe the
same way this patch shares ch->reg_cqe.  Could you point at the two work
requests you have in mind?

One thing does get worse: "for CQE %p" in srp_handle_qp_err() used to
differ per request and now takes one of two values per channel.

If a completion has to identify its work request here, I accept that and
will drop patch 1.  Should patch 2 then carry Cc: stable?  Patch 1 is
the one tagged now.

Best regards,

Yehyeong Lee

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2026-09-04 17:51 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-08-18  3:52 [PATCH v2 0/2] RDMA/srp: fix use-after-free of a request in srp_destroy_qp() Yehyeong Lee
2026-08-18  3:52 ` [PATCH v2 1/2] " Yehyeong Lee
2026-08-18 16:26   ` Bart Van Assche
2026-08-19  2:10     ` Yehyeong Lee
2026-08-18  3:52 ` [PATCH v2 2/2] RDMA/srp: Fix srp_remove_target() Yehyeong Lee
2026-09-02 12:59 ` (subset) [PATCH v2 0/2] RDMA/srp: fix use-after-free of a request in srp_destroy_qp() Leon Romanovsky
2026-09-04 17:51   ` Bart Van Assche
2026-08-19  1:48 [PATCH v2 1/2] " Yehyeong Lee

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®