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 v14 07/11] scsi: ibmvfc: extend async event handlers for async sub-CRQ events
Date: Fri, 16 Oct 2026 09:47:26 -0500 [thread overview]
Message-ID: <87y0bxbt35.fsf@linux.ibm.com> (raw)
In-Reply-To: <sashiko-outbox-173052@kernel.org> (sashiko-bot@kernel.org's message of "Thu, 15 Oct 2026 15:20:27 +0000")
sashiko-bot@kernel.org writes:
> Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
> - [High] scsi: ibmvfc: UAF and module unload crash due to untracked async work
> --
>
> commit e22506651b699f9db9776870465be492a807fad7
> Author: Dave Marquardt <davemarq@linux.ibm.com>
>
> scsi: ibmvfc: extend async event handlers for async sub-CRQ events
>
> This commit refactors async event handling to support both traditional async
> CRQs and new asynchronous sub-queue CRQs. It introduces a tagged union
> struct ibmvfc_async_crq_event to hold either event type and updates the
> corresponding handlers and FPIN processing logic.
>
>> diff --git a/drivers/scsi/ibmvscsi/ibmvfc-core.c b/drivers/scsi/ibmvscsi/ibmvfc-core.c
>> index 9c710897cd546..87ee19057551e 100644
>> --- a/drivers/scsi/ibmvscsi/ibmvfc-core.c
>> +++ b/drivers/scsi/ibmvscsi/ibmvfc-core.c
>
> [ ... ]
>
>> @@ -3629,14 +3711,14 @@ static void ibmvfc_handle_async(struct ibmvfc_async_crq *crq,
>> }
>> INIT_WORK(&aw->async_work_s, ibmvfc_process_async_work);
>> aw->vhost = vhost;
>> - aw->crq = *crq;
>> + aw->event = *ae;
>> schedule_work(&aw->async_work_s);
>
> [Severity: High]
> Does this code leave the scheduled work item untracked without a cancelation
> path during module unload or device removal?
>
> Looking at ibmvfc_remove(), it executes without flushing the system workqueue
> or canceling these specific work items. It then calls ibmvfc_free_mem() which
> unconditionally destroys vhost->tgt_pool via mempool_destroy():
This is the same issue as patch 4, and is being addressed.
> drivers/scsi/ibmvscsi/ibmvfc-core.c:ibmvfc_remove() {
> ...
> flush_work(&vhost->rport_add_work_q);
> fc_remove_host(vhost->host);
> scsi_remove_host(vhost->host);
> ...
> ibmvfc_free_mem(vhost);
> spin_lock(&ibmvfc_driver_lock);
> list_del(&vhost->queue);
> spin_unlock(&ibmvfc_driver_lock);
> scsi_host_put(vhost->host);
> }
>
> If the work executes after the target pool is destroyed,
> ibmvfc_process_async_work() looks up a target, takes a reference, and
> eventually calls ibmvfc_release_tgt(), which triggers a use-after-free
> by calling mempool_free() on the already-destroyed pool:
>
> drivers/scsi/ibmvscsi/ibmvfc-core.c:ibmvfc_release_tgt() {
> struct ibmvfc_target *tgt = container_of(kref, struct ibmvfc_target, kref);
> mempool_free(tgt, tgt->vhost->tgt_pool);
> }
>
> Furthermore, since scsi_host_get() does not hold a module reference, rmmod
> could complete while the work is still queued. Could this lead to the system
> workqueue executing unmapped memory and causing a kernel panic?
Also fixed by using a vhost-specific workqueue, which will be done in
the next revision.
-Dave
next prev parent reply other threads:[~2026-10-16 14:47 UTC|newest]
Thread overview: 34+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-15 15:06 [PATCH v14 00/11] scsi: ibmvfc: make ibmvfc support FPIN messages Dave Marquardt via B4 Relay
2026-10-15 15:06 ` Dave Marquardt
2026-10-15 15:07 ` [PATCH v14 01/11] scsi: ibmvfc: fix IRQ leak and guard deregister on channel reg failure Dave Marquardt via B4 Relay
2026-10-15 15:07 ` Dave Marquardt
2026-10-15 15:07 ` [PATCH v14 02/11] scsi: ibmvfc: fix potential clobbering of rc after failed irq setup Dave Marquardt via B4 Relay
2026-10-15 15:07 ` Dave Marquardt
2026-10-15 15:07 ` [PATCH v14 03/11] scsi: ibmvfc: fix potential NULL pointer dereference on failed queue allocation Dave Marquardt via B4 Relay
2026-10-15 15:07 ` Dave Marquardt
2026-10-15 15:20 ` sashiko-bot
2026-10-15 16:15 ` Dave Marquardt
2026-10-15 15:07 ` [PATCH v14 04/11] scsi: ibmvfc: add basic FPIN support Dave Marquardt via B4 Relay
2026-10-15 15:07 ` Dave Marquardt
2026-10-15 15:18 ` sashiko-bot
2026-10-15 21:47 ` Dave Marquardt
2026-10-15 15:07 ` [PATCH v14 05/11] scsi: ibmvfc: add NOOP command support Dave Marquardt via B4 Relay
2026-10-15 15:07 ` Dave Marquardt
2026-10-15 15:07 ` [PATCH v14 06/11] scsi: ibmvfc: add FPIN extended flag and async sub-CRQ queue handle Dave Marquardt via B4 Relay
2026-10-15 15:07 ` Dave Marquardt
2026-10-15 15:07 ` [PATCH v14 07/11] scsi: ibmvfc: extend async event handlers for async sub-CRQ events Dave Marquardt via B4 Relay
2026-10-15 15:07 ` Dave Marquardt
2026-10-15 15:20 ` sashiko-bot
2026-10-16 14:47 ` Dave Marquardt [this message]
2026-10-15 15:07 ` [PATCH v14 08/11] scsi: ibmvfc: add interrupt routine for asynchronous sub CRQ Dave Marquardt via B4 Relay
2026-10-15 15:07 ` Dave Marquardt
2026-10-15 15:07 ` [PATCH v14 09/11] scsi: ibmvfc: extend channel reg/dereg helpers for async sub-CRQ Dave Marquardt via B4 Relay
2026-10-15 15:07 ` Dave Marquardt
2026-10-15 15:21 ` sashiko-bot
2026-10-16 15:53 ` Dave Marquardt
2026-10-15 15:07 ` [PATCH v14 10/11] scsi: ibmvfc: register and use asynchronous sub CRQ for events Dave Marquardt via B4 Relay
2026-10-15 15:07 ` Dave Marquardt
2026-10-15 15:28 ` sashiko-bot
2026-10-16 16:23 ` Dave Marquardt
2026-10-15 15:07 ` [PATCH v14 11/11] scsi: ibmvfc: handle extended FPIN events Dave Marquardt via B4 Relay
2026-10-15 15:07 ` 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=87y0bxbt35.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 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.