From: sashiko-bot@kernel.org
To: "Dave Marquardt" <davemarq@linux.ibm.com>
Cc: linux-scsi@vger.kernel.org
Subject: Re: [PATCH v8 7/9] scsi: ibmvfc: fix IRQ leak and guard deregister on channel reg failure
Date: Wed, 09 Sep 2026 19:26:32 +0000 [thread overview]
Message-ID: <20260909192633.219E41F000FF@smtp.kernel.org> (raw)
In-Reply-To: <20260909-ibmvfc-fpin-support-v8-7-b27183b055af@linux.ibm.com>
Thank you for your contribution! Sashiko AI review found 6 potential issue(s) to consider:
Pre-existing issues:
- [Critical] Asynchronous timer deletion during teardown allows the timer callback to execute after the event pool memory has been freed.
- [High] Unknown channel protocol error path skips IRQ mapping disposal and falsely reports success, causing an IRQ leak and a subsequent kernel warning on teardown.
- [High] Sub-CRQ cookies are not zeroed after being freed via H_FREE_SUB_CRQ, leading to double-freeing the cookies during adapter resets or teardowns.
- [High] The adapter initialization state machine stalls indefinitely if channel registration fails.
- [Medium] ibmvfc_deregister_channel() unconditionally executes H_FREE_SUB_CRQ for unmapped or unregistered queues, causing spurious hypervisor errors and kernel log spam.
- [Medium] Event pool memory is permanently leaked if queue allocation fails midway in ibmvfc_alloc_queue().
--
commit 9f8024026aa5c4ef26997be7255cb4acbd34dd0f
Author: Dave Marquardt <davemarq@linux.ibm.com>
scsi: ibmvfc: fix IRQ leak and guard deregister on channel reg failure
If request_irq() fails during ibmvfc_register_channel(), the error path
disposes of the IRQ mapping via irq_dispose_mapping() but leaves scrq->irq
populated with the stale virq number. A subsequent call to
ibmvfc_deregister_channel() during teardown or reset cleanup then
unconditionally invokes free_irq() and irq_dispose_mapping() on the stale
IRQ descriptor, triggering kernel warnings.
Fix this by:
1. Explicitly setting scrq->irq to 0 after irq_dispose_mapping() in the
ibmvfc_register_channel() error path.
2. Guarding free_irq() and irq_dispose_mapping() with a check for scrq->irq
in ibmvfc_deregister_channel() so unmapped or unregistered queues are
safely skipped.
> diff --git a/drivers/scsi/ibmvscsi/ibmvfc-core.c b/drivers/scsi/ibmvscsi/ibmvfc-core.c
> index 1c660edcf608a..f88262ffad134 100644
> --- a/drivers/scsi/ibmvscsi/ibmvfc-core.c
> +++ b/drivers/scsi/ibmvscsi/ibmvfc-core.c
> @@ -6888,6 +6888,7 @@ static int ibmvfc_register_channel(struct ibmvfc_host *vhost,
> else
> dev_err(dev, "Couldn't register async sub-crq irq\n");
> irq_dispose_mapping(scrq->irq);
> + scrq->irq = 0;
> goto irq_failed;
> }
>
> @@ -6930,9 +6931,11 @@ static void ibmvfc_deregister_channel(struct ibmvfc_host *vhost,
>
> ENTER;
>
> - free_irq(scrq->irq, scrq);
> - irq_dispose_mapping(scrq->irq);
> - scrq->irq = 0;
> + if (scrq->irq) {
> + free_irq(scrq->irq, scrq);
> + irq_dispose_mapping(scrq->irq);
> + scrq->irq = 0;
> + }
>
> do {
> rc = plpar_hcall_norets(H_FREE_SUB_CRQ, vdev->unit_address,
[Severity: Medium]
This is a pre-existing issue, but does this unconditional hypercall cause
spurious hypervisor errors and kernel log spam?
During adapter teardown or reset, ibmvfc_dereg_sub_crqs() iteratively calls
ibmvfc_deregister_channel() on all allocated sub-CRQs up to max_queues,
regardless of whether they were successfully registered.
This results in H_FREE_SUB_CRQ being invoked on uninitialized queues where
scrq->cookie is 0.
[Severity: High]
This is a pre-existing issue, but is it possible for sub-CRQ cookies to be
double-freed during adapter resets or teardowns?
After calling H_FREE_SUB_CRQ above, scrq->cookie is not zeroed. If iterative
teardown functions call this again, could the double-free destroy an active
channel on the VIOS side if the hypervisor has reallocated that cookie?
This same issue occurs in the error path of ibmvfc_register_channel():
drivers/scsi/ibmvscsi/ibmvfc-core.c:ibmvfc_register_channel() {
...
irq_failed:
do {
hcall_rc = plpar_hcall_norets(H_FREE_SUB_CRQ, vdev->unit_address, scrq->cookie);
} while (hcall_rc == H_BUSY || H_IS_LONG_BUSY(hcall_rc));
...
}
Where the cookie is similarly freed but not zeroed.
drivers/scsi/ibmvscsi/ibmvfc-core.c:ibmvfc_register_channel() {
...
default:
dev_err(dev, "Unknown channel protocol (%d)\n",
channels->protocol);
goto irq_failed;
}
...
}
[Severity: High]
This is a pre-existing issue, but does the unknown channel protocol error path
skip IRQ mapping disposal and falsely report success?
If channels->protocol hits the default case, it jumps to irq_failed. Because
rc was initialized to -ENOMEM but overwritten to 0 by a successful
h_reg_sub_crq(), the function falsely returns 0.
This leaves scrq->irq non-zero and causes an IRQ leak and a subsequent kernel
warning on teardown when free_irq() is called on an unrequested IRQ.
drivers/scsi/ibmvscsi/ibmvfc-core.c:ibmvfc_alloc_queue() {
...
if (dma_mapping_error(dev, queue->msg_token)) {
free_page((unsigned long)queue->msgs.handle);
queue->msgs.handle = NULL;
return -ENOMEM;
}
...
}
[Severity: Medium]
This is a pre-existing issue, but does this error path leak the event pool
memory?
If get_zeroed_page() or dma_map_single() fail, the function returns -ENOMEM
without calling ibmvfc_free_event_pool() to clean up the event pool allocated
at the beginning of the function.
When handling the failure in ibmvfc_alloc_channels():
drivers/scsi/ibmvscsi/ibmvfc-core.c:ibmvfc_alloc_channels() {
...
if (rc) {
for (j = i; j > 0; j--) {
scrq = &channels->scrqs[j - 1];
ibmvfc_free_queue(vhost, scrq);
}
kfree(channels->scrqs);
...
}
The array is freed, losing the reference to the partially-allocated queue i
and permanently leaking its event pool.
drivers/scsi/ibmvscsi/ibmvfc-core.c:ibmvfc_fail_request() {
...
timer_delete(&evt->timer);
...
}
[Severity: Critical]
This is a pre-existing issue, but does asynchronous timer deletion during
teardown allow the timer callback to execute after the event pool memory has
been freed?
During adapter removal, ibmvfc_purge_requests() calls ibmvfc_fail_request()
which executes timer_delete() instead of timer_delete_sync(). Teardown then
quickly progresses to ibmvfc_free_event_pool().
If a command timeout occurs concurrently:
drivers/scsi/ibmvscsi/ibmvfc-core.c:ibmvfc_timeout() {
...
struct ibmvfc_event *evt = timer_container_of(evt, t, timer);
struct ibmvfc_host *vhost = evt->vhost;
...
}
Can the timer callback access fields on an event structure that has already
been freed, leading to a use-after-free and potential kernel crash?
drivers/scsi/ibmvscsi/ibmvfc-core.c:ibmvfc_npiv_login_done() {
...
if (ibmvfc_check_caps(vhost, IBMVFC_CAN_SUPPORT_CHANNELS)) {
if (ibmvfc_check_caps(vhost, IBMVFC_SUPPORT_SCSI))
vhost->do_scsi_login = 1;
if (ibmvfc_check_caps(vhost, IBMVFC_SUPPORT_NVMEOF))
vhost->do_nvme_login = 1;
if (vhost->do_enquiry)
ibmvfc_channel_enquiry(vhost);
} else {
vhost->do_enquiry = 0;
ibmvfc_set_host_action(vhost, IBMVFC_HOST_ACTION_QUERY);
wake_up(&vhost->work_wait_q);
}
...
}
[Severity: High]
This is a pre-existing issue, but can the adapter initialization state machine
stall indefinitely if channel registration fails?
If ibmvfc_alloc_queue() or ibmvfc_register_channel() fail,
vhost->do_enquiry is set to 0.
Later, in ibmvfc_npiv_login_done(), if the adapter supports channels but
vhost->do_enquiry is 0, the code skips ibmvfc_channel_enquiry() but doesn't
fall into the else branch.
Because it does not advance vhost->action or wake up the work queue, does the
state machine remain stuck in IBMVFC_HOST_ACTION_INIT_WAIT, rendering the
storage adapter unusable?
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260909-ibmvfc-fpin-support-v8-0-b27183b055af@linux.ibm.com?part=7
next prev parent reply other threads:[~2026-09-09 19:26 UTC|newest]
Thread overview: 53+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-09 19:07 [PATCH v8 0/9] scsi: ibmvfc: make ibmvfc support FPIN messages Dave Marquardt via B4 Relay
2026-09-11 2:08 ` Tyrel Datwyler
2026-09-09 19:07 ` Dave Marquardt
2026-09-09 19:07 ` [PATCH v8 1/9] scsi: ibmvfc: add basic FPIN support Dave Marquardt via B4 Relay
2026-09-09 19:07 ` Dave Marquardt
2026-09-09 19:29 ` sashiko-bot
2026-09-11 0:46 ` Tyrel Datwyler
2026-09-09 19:07 ` [PATCH v8 2/9] scsi: ibmvfc: add NOOP command support Dave Marquardt via B4 Relay
2026-09-09 19:07 ` Dave Marquardt
2026-09-09 19:19 ` sashiko-bot
2026-09-10 23:14 ` Tyrel Datwyler
2026-09-09 19:07 ` [PATCH v8 3/9] scsi: ibmvfc: add FPIN extended flag and async sub-CRQ queue handle Dave Marquardt via B4 Relay
2026-09-09 19:07 ` Dave Marquardt
2026-09-10 23:15 ` Tyrel Datwyler
2026-09-09 19:07 ` [PATCH v8 4/9] scsi: ibmvfc: extend async event handlers for async sub-CRQ events Dave Marquardt via B4 Relay
2026-09-09 19:07 ` Dave Marquardt
2026-09-09 19:23 ` sashiko-bot
2026-09-10 23:18 ` Tyrel Datwyler
2026-09-09 19:08 ` [PATCH v8 5/9] scsi: ibmvfc: add interrupt routine for asynchronous sub CRQ Dave Marquardt via B4 Relay
2026-09-09 19:08 ` Dave Marquardt
2026-09-10 23:19 ` Tyrel Datwyler
2026-09-09 19:08 ` [PATCH v8 6/9] scsi: ibmvfc: extend channel reg/dereg helpers for async sub-CRQ Dave Marquardt via B4 Relay
2026-09-09 19:08 ` Dave Marquardt
2026-09-10 23:19 ` Tyrel Datwyler
2026-09-09 19:08 ` [PATCH v8 7/9] scsi: ibmvfc: fix IRQ leak and guard deregister on channel reg failure Dave Marquardt via B4 Relay
2026-09-09 19:08 ` Dave Marquardt
2026-09-09 19:26 ` sashiko-bot [this message]
2026-09-10 23:22 ` Tyrel Datwyler
2026-09-09 19:08 ` [PATCH v8 8/9] scsi: ibmvfc: register and use asynchronous sub CRQ for events Dave Marquardt via B4 Relay
2026-09-09 19:08 ` Dave Marquardt
2026-09-09 19:26 ` sashiko-bot
2026-09-10 23:34 ` Tyrel Datwyler
2026-09-09 19:08 ` [PATCH v8 9/9] scsi: ibmvfc: handle extended FPIN events Dave Marquardt via B4 Relay
2026-09-09 19:08 ` Dave Marquardt
2026-09-09 19:28 ` sashiko-bot
2026-09-10 23:42 ` Tyrel Datwyler
2026-09-11 2:08 ` [PATCH v9 1/9] scsi: ibmvfc: add basic FPIN support Tyrel Datwyler
2026-09-11 2:42 ` sashiko-bot
2026-09-11 2:08 ` [PATCH v9 2/9] scsi: ibmvfc: add NOOP command support Tyrel Datwyler
2026-09-11 2:21 ` sashiko-bot
2026-09-11 2:08 ` [PATCH v9 3/9] scsi: ibmvfc: add FPIN extended flag and async sub-CRQ queue handle Tyrel Datwyler
2026-09-11 2:08 ` [PATCH v9 4/9] scsi: ibmvfc: extend async event handlers for async sub-CRQ events Tyrel Datwyler
2026-09-11 2:40 ` sashiko-bot
2026-09-11 2:08 ` [PATCH v9 5/9] scsi: ibmvfc: add interrupt routine for asynchronous sub CRQ Tyrel Datwyler
2026-09-11 2:31 ` sashiko-bot
2026-09-11 2:08 ` [PATCH v9 6/9] scsi: ibmvfc: extend channel reg/dereg helpers for async sub-CRQ Tyrel Datwyler
2026-09-11 2:08 ` [PATCH v9 7/9] scsi: ibmvfc: fix IRQ leak and guard deregister on channel reg failure Tyrel Datwyler
2026-09-11 2:27 ` sashiko-bot
2026-09-11 2:08 ` [PATCH v9 8/9] scsi: ibmvfc: register and use asynchronous sub CRQ for events Tyrel Datwyler
2026-09-11 2:23 ` sashiko-bot
2026-09-11 2:08 ` [PATCH v9 9/9] scsi: ibmvfc: handle extended FPIN events Tyrel Datwyler
2026-09-11 2:26 ` sashiko-bot
2026-09-11 2:12 ` [PATCH v8 0/9] scsi: ibmvfc: make ibmvfc support FPIN messages 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=20260909192633.219E41F000FF@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=davemarq@linux.ibm.com \
--cc=linux-scsi@vger.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 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.