From: Dave Marquardt <davemarq@linux.ibm.com>
To: sashiko-bot@kernel.org
Cc: sashiko-reviews@lists.linux.dev, linux-scsi@vger.kernel.org
Subject: Re: [PATCH v12 04/11] scsi: ibmvfc: add basic FPIN support
Date: Wed, 30 Sep 2026 16:48:45 -0500 [thread overview]
Message-ID: <87ik3mjtqa.fsf@linux.ibm.com> (raw)
In-Reply-To: <20260930183931.565D31F0089A@smtp.kernel.org> (sashiko-bot@kernel.org's message of "Wed, 30 Sep 2026 18:39:30 +0000")
sashiko-bot@kernel.org writes:
> Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
> - [Medium] scsi: ibmvfc: unbalanced scsi_host_put() and UAF in kunit tests due to ignored scsi_host_get() result
> --
>
> commit 0f3f9d832e1029568dc3a6eb9097fdaa04016dcc
> Author: Dave Marquardt <davemarq@linux.ibm.com>
>
> scsi: ibmvfc: add basic FPIN support
>
> This commit implements support for a basic level of Fabric Performance
> Impact Notifications (FPIN) in the ibmvfc driver. It adds an async
> event handler for IBMVFC_AE_FPIN events that offloads FPIN processing
> to a dedicated workqueue, and introduces KUnit tests for validation.
>
>> diff --git a/drivers/scsi/ibmvscsi/ibmvfc-core.c b/drivers/scsi/ibmvscsi/ibmvfc-core.c
>> index cf775f0673a0f..e0fa9b547cbfe 100644
>> --- a/drivers/scsi/ibmvscsi/ibmvfc-core.c
>> +++ b/drivers/scsi/ibmvscsi/ibmvfc-core.c
>
> [ ... ]
>
>> @@ -7120,5 +7393,21 @@ static void __exit ibmvfc_module_exit(void)
>> fc_release_transport(ibmvfc_transport_template);
>> }
>>
>> +#if IS_ENABLED(CONFIG_KUNIT)
>> +VISIBLE_IF_KUNIT struct ibmvfc_host *ibmvfc_get_first_vhost(void)
>> +{
>> + struct ibmvfc_host *vhost = NULL;
>> +
>> + spin_lock(&ibmvfc_driver_lock);
>> + if (!list_empty(&ibmvfc_head))
>> + vhost = list_first_entry(&ibmvfc_head, struct ibmvfc_host, queue);
>> + if (vhost)
>> + scsi_host_get(vhost->host);
>
> [Severity: Medium]
> Does this code need to check the return value of scsi_host_get()?
>
> If it fails (for example, if the module is being concurrently unloaded and
> the host state becomes SHOST_DEL before vhost is removed from ibmvfc_head),
> this function will ignore the failure and return an unreferenced vhost
> pointer to the caller.
Yes, this is possible. In v13, if scsi_host_get() returns NULL,
ibmvfc_get_first_vhost() will return NULL.
>> + spin_unlock(&ibmvfc_driver_lock);
>> + return vhost;
>> +}
>> +EXPORT_SYMBOL_IF_KUNIT(ibmvfc_get_first_vhost);
>> +#endif
>
> [ ... ]
>
>> diff --git a/drivers/scsi/ibmvscsi/ibmvfc_kunit.c b/drivers/scsi/ibmvscsi/ibmvfc_kunit.c
>> new file mode 100644
>> index 0000000000000..7cc9d423d4a79
>> --- /dev/null
>> +++ b/drivers/scsi/ibmvscsi/ibmvfc_kunit.c
>
> [ ... ]
>
>> +static void ibmvfc_async_fpin_test(struct kunit *test)
>> +{
>
> [ ... ]
>
>> + KUNIT_EXPECT_EQ(test, pre[IBMVFC_AE_FPIN_CONGESTION_CLEARED],
>> + post[IBMVFC_AE_FPIN_CONGESTION_CLEARED]);
>> +
>> + kref_put(&tgt->kref, ibmvfc_release_tgt);
>> + put_device(&rport->dev);
>> + scsi_host_put(vhost->host);
>
> [Severity: Medium]
> Could this unconditional scsi_host_put() cause a refcount underflow if the
> earlier scsi_host_get() call failed?
>
> The test might also perform a use-after-free by accessing members of the
> unreferenced vhost if it was already freed concurrently by the unload path.
I assume you're referring to the earlier scsi_host_get() call as above
in ibmvfc_get_first_vhost(). Yes, this is currently a problem, but in
v13 this test will bail out as ibmvfc_get_first_vhost() will return NULL
if scsi_host_get() returns NULL.
-Dave
next prev parent reply other threads:[~2026-09-30 21:48 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-30 18:23 [PATCH v12 00/11] scsi: ibmvfc: make ibmvfc support FPIN messages Dave Marquardt via B4 Relay
2026-09-30 18:23 ` [PATCH v12 01/11] scsi: ibmvfc: fix IRQ leak and guard deregister on channel reg failure Dave Marquardt via B4 Relay
2026-09-30 18:23 ` [PATCH v12 02/11] scsi: ibmvfc: fix potential clobbering of rc after failed irq setup Dave Marquardt via B4 Relay
2026-09-30 18:23 ` [PATCH v12 03/11] scsi: ibmvfc: fix potential NULL pointer dereference on failed queue allocation Dave Marquardt via B4 Relay
2026-09-30 18:23 ` [PATCH v12 04/11] scsi: ibmvfc: add basic FPIN support Dave Marquardt via B4 Relay
2026-09-30 18:39 ` sashiko-bot
2026-09-30 21:48 ` Dave Marquardt [this message]
2026-09-30 18:23 ` [PATCH v12 05/11] scsi: ibmvfc: add NOOP command support Dave Marquardt via B4 Relay
2026-09-30 18:23 ` [PATCH v12 06/11] scsi: ibmvfc: add FPIN extended flag and async sub-CRQ queue handle Dave Marquardt via B4 Relay
2026-09-30 18:23 ` [PATCH v12 07/11] scsi: ibmvfc: extend async event handlers for async sub-CRQ events Dave Marquardt via B4 Relay
2026-09-30 18:23 ` [PATCH v12 08/11] scsi: ibmvfc: add interrupt routine for asynchronous sub CRQ Dave Marquardt via B4 Relay
2026-09-30 18:23 ` [PATCH v12 09/11] scsi: ibmvfc: extend channel reg/dereg helpers for async sub-CRQ Dave Marquardt via B4 Relay
2026-09-30 18:23 ` [PATCH v12 10/11] scsi: ibmvfc: register and use asynchronous sub CRQ for events Dave Marquardt via B4 Relay
2026-09-30 18:23 ` [PATCH v12 11/11] scsi: ibmvfc: handle extended FPIN events Dave Marquardt via B4 Relay
2026-09-30 18:36 ` sashiko-bot
2026-10-02 16:35 ` Dave Marquardt
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=87ik3mjtqa.fsf@linux.ibm.com \
--to=davemarq@linux.ibm.com \
--cc=linux-scsi@vger.kernel.org \
--cc=sashiko-bot@kernel.org \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox