All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Tyrel Datwyler" <tyreld@linux.ibm.com>
Cc: linux-scsi@vger.kernel.org
Subject: Re: [PATCH 03/20] scsi: ibmvfc: complete NVMe FCP requests on H_CLOSED send failure
Date: Wed, 16 Sep 2026 23:24:38 +0000	[thread overview]
Message-ID: <20260916232438.C6AE11F000FF@smtp.kernel.org> (raw)
In-Reply-To: <20260916230921.2204729-4-tyreld@linux.ibm.com>

Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [Critical] scsi: ibmvfc: double completion and UAF on NVMe H_CLOSED error path
- [High] scsi: ibmvfc: invalid assignment of -EBUSY to unsigned NVMe fcp_req->status
--

commit 09b742c396cef74ab36e606d794a591d97008dc8
Author: Tyrel Datwyler <tyreld@linux.ibm.com>

scsi: ibmvfc: complete NVMe FCP requests on H_CLOSED send failure

When ibmvfc_send_event() returns H_CLOSED the event is freed without
notifying the NVMe-FC transport, which left the transport waiting on a
request that was silently dropped. This commit fixes the hang by explicitly
completing the NVMe FCP request with a busy status before freeing the event.

> diff --git a/drivers/scsi/ibmvscsi/ibmvfc-core.c b/drivers/scsi/ibmvscsi/ibmvfc-core.c
> index 6c243b2a84d7a..26a73db662545 100644
> --- a/drivers/scsi/ibmvscsi/ibmvfc-core.c
> +++ b/drivers/scsi/ibmvscsi/ibmvfc-core.c
> @@ -1845,6 +1845,10 @@ int ibmvfc_send_event(struct ibmvfc_event *evt,
>  				dev_warn(vhost->dev, "Send warning. Receive queue closed, will retry.\n");
>  			if (evt->cmnd)
>  				scsi_dma_unmap(evt->cmnd);
> +			else if (evt->fcp_req) {
> +				evt->fcp_req->status = -EBUSY;
[Severity: High]
Does assigning -EBUSY to fcp_req->status result in an underflow? Since this
field is an unsigned 32-bit integer, -EBUSY (-16) becomes 0xfffffff0.

When the NVMe-FC completion handler nvme_fc_fcpio_done() checks if this
status is non-zero, it might translate it into a fatal
NVME_SC_HOST_PATH_ERROR instead of recognizing it as a retry request,
potentially causing a permanent I/O failure rather than a seamless retry.

> +				evt->fcp_req->done(evt->fcp_req);
> +			}
>  			ibmvfc_free_event(evt);
>  			return SCSI_MLQUEUE_HOST_BUSY;
[Severity: Critical]
Will this lead to a double completion and use-after-free? When
ibmvfc_send_event() returns SCSI_MLQUEUE_HOST_BUSY (which is a positive
value), the caller ibmvfc_nvme_fcp_io() propagates this non-zero error code
directly back to the NVMe-FC transport.

The NVMe-FC LLDD API contract requires that if the fcp_io callback returns a
non-zero value, it signifies a synchronous queueing failure, and the driver
must not call fcp_req->done().

Because the NVMe-FC core executes its own teardown path that unmaps the SG
list and completes the request when the fcp_io callback returns non-zero,
invoking done() here inline causes it to also be completed asynchronously,
resulting in a fatal use-after-free and double DMA unmap.

Should the driver instead omit calling done() completely and translate the
internal SCSI_MLQUEUE_HOST_BUSY into -EBUSY as the direct return value of
ibmvfc_nvme_fcp_io() to correctly signal a transport retry?

>  		}

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260916230921.2204729-1-tyreld@linux.ibm.com?part=3

  reply	other threads:[~2026-09-16 23:24 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-16 23:09 [PATCH 00/20] scsi: ibmvfc: Fixes and cleanup for NVMe/FC support Tyrel Datwyler
2026-09-16 23:09 ` [PATCH 01/20] scsi: ibmvfc: initialize evt->tgt for NVMe FCP commands Tyrel Datwyler
2026-09-16 23:09 ` [PATCH 02/20] scsi: ibmvfc: fix trace logging " Tyrel Datwyler
2026-09-16 23:21   ` sashiko-bot
2026-09-16 23:09 ` [PATCH 03/20] scsi: ibmvfc: complete NVMe FCP requests on H_CLOSED send failure Tyrel Datwyler
2026-09-16 23:24   ` sashiko-bot [this message]
2026-09-16 23:09 ` [PATCH 04/20] scsi: ibmvfc: defer NVMe local port registration out of atomic context Tyrel Datwyler
2026-09-16 23:27   ` sashiko-bot
2026-09-16 23:09 ` [PATCH 05/20] scsi: ibmvfc: fix uninitialized _done dereference for TMF events on send failure Tyrel Datwyler
2026-09-16 23:33   ` sashiko-bot
2026-09-16 23:09 ` [PATCH 06/20] scsi: ibmvfc: fix uninitialized shwqs in ibmvfc_purge_requests() Tyrel Datwyler
2026-09-16 23:09 ` [PATCH 07/20] scsi: ibmvfc: fix uninitialized status logged on LS abort send failure Tyrel Datwyler
2026-09-16 23:09 ` [PATCH 08/20] scsi: ibmvfc: fix inverted suppress-ABTS capability check in NVMe TMF path Tyrel Datwyler
2026-09-16 23:09 ` [PATCH 09/20] scsi: ibmvfc: fix infinite reset loop on NULL evt in implicit logout path Tyrel Datwyler
2026-09-16 23:09 ` [PATCH 10/20] scsi: ibmvfc: fix u16 overflow of max_cmds in ibmvfc_set_login_info() Tyrel Datwyler
2026-09-16 23:09 ` [PATCH 11/20] scsi: ibmvfc: fix UAF and hang in ibmvfc_cancel_all_mq() on send failure Tyrel Datwyler
2026-09-16 23:09 ` [PATCH 12/20] scsi: ibmvfc: fix data race on tgt->nvme_remote_port Tyrel Datwyler
2026-09-16 23:09 ` [PATCH 13/20] scsi: ibmvfc: make NVMe FCP abort callback asynchronous Tyrel Datwyler
2026-09-16 23:27   ` sashiko-bot
2026-09-16 23:09 ` [PATCH 14/20] scsi: ibmvfc: fix UAF and stall in NVMe LS abort callback Tyrel Datwyler
2026-09-16 23:33   ` sashiko-bot
2026-09-16 23:09 ` [PATCH 15/20] scsi: ibmvfc: unregister NVMe local port on adapter removal Tyrel Datwyler
2026-09-16 23:39   ` sashiko-bot
2026-09-16 23:09 ` [PATCH 16/20] scsi: ibmvfc: fix NVMe local port leak on fabric link bounce Tyrel Datwyler
2026-09-16 23:09 ` [PATCH 17/20] scsi: ibmvfc: fix TOCTOU race in ibmvfc_nvme_create_queue() on adapter removal Tyrel Datwyler
2026-09-16 23:09 ` [PATCH 18/20] scsi: ibmvfc: fix NVMe sub-queue registration failure disabling SCSI multiqueue Tyrel Datwyler
2026-09-16 23:39   ` sashiko-bot
2026-09-16 23:09 ` [PATCH 19/20] scsi: ibmvfc: fix concurrent SCSI and NVMe discover-targets race dropping targets Tyrel Datwyler
2026-09-16 23:41   ` sashiko-bot
2026-09-16 23:09 ` [PATCH 20/20] scsi: ibmvfc: fix nr_nvme_hw_queues module parameter ignored for NVMe queue sizing Tyrel Datwyler

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=20260916232438.C6AE11F000FF@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=linux-scsi@vger.kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    --cc=tyreld@linux.ibm.com \
    /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.