Re: [PATCH] nvmet-fcloop: fail LS request synchronously when remote port is gone
From: Daniel Wagner
Date: Mon Sep 21 2026 - 07:33:05 EST
On Sun, Sep 20, 2026 at 11:38:04PM +0700, Nguyen Ngoc Thang wrote:
> fcloop_t2h_ls_req() handles a missing remoteport by queueing the request
> on tport->ls_list and completing it with -ECONNREFUSED from a work item.
>
> nvmet_fc_delete_assoc_work() sends the Disconnect Association LS this
> way. When it runs during nvmet_fc_unregister_targetport(), the work is
> queued after flush_workqueue() has started, so it is not waited for.
> nvmet_fc_free_pending_reqs() then frees the still-pending lsop and the
> late work item calls lsreq->done() on freed memory:
>
> BUG: KASAN: slab-use-after-free in fcloop_rport_lsrqst_work+0x242/0x2e0
> Workqueue: nvmet-wq fcloop_tport_lsrqst_work
> Allocated by nvmet_fc_xmt_disconnect_assoc
> Freed by nvmet_fc_free_pending_reqs
> nvmet_fc_unregister_targetport
> fcloop_delete_target_port
>
> Return -ECONNREFUSED directly instead. __nvmet_fc_send_ls_req() unwinds
> and nvmet_fc_xmt_disconnect_assoc() frees the lsop, so no completion is
> left outstanding.
IIRC this has been added to free memory in a different execution
scenario. So I don't think you can just skip it.
And this is also a change in the behavior between HBA's behaviour in the
loopback behavior.