From: sashiko-bot@kernel.org
To: "Dave Marquardt" <davemarq@linux.ibm.com>
Cc: linux-scsi@vger.kernel.org
Subject: Re: [PATCH v14 10/11] scsi: ibmvfc: register and use asynchronous sub CRQ for events
Date: Thu, 15 Oct 2026 15:28:19 +0000 [thread overview]
Message-ID: <sashiko-outbox-173070@kernel.org> (raw)
In-Reply-To: <20261015-ibmvfc-fpin-support-v14-10-a0b063b8d825@linux.ibm.com>
Thank you for your contribution! Sashiko AI review found 3 potential issue(s) to consider:
- [Critical] scsi: ibmvfc: DMA Use-After-Free due to skipped sub-CRQ deregistration
- [High] scsi: ibmvfc: data race on host state bitfields due to lockless mq_enabled write
- [High] scsi: ibmvfc: missing bounds check on active_queues causes heap overflow
--
commit 4d5dd0876862baa994058a6b3ad652d84e0497a5
Author: Dave Marquardt <davemarq@linux.ibm.com>
scsi: ibmvfc: register and use asynchronous sub CRQ for events
Wire the async sub-CRQ into the sub-CRQ lifecycle so it is allocated,
registered, and freed alongside the SCSI channel queues.
> diff --git a/drivers/scsi/ibmvscsi/ibmvfc-core.c b/drivers/scsi/ibmvscsi/ibmvfc-core.c
> index b12655f028879..594e5f136040a 100644
> --- a/drivers/scsi/ibmvscsi/ibmvfc-core.c
> +++ b/drivers/scsi/ibmvscsi/ibmvfc-core.c
[ ... ]
> @@ -5817,6 +5824,7 @@ static void ibmvfc_channel_setup_done(struct ibmvfc_event *evt)
> vhost->do_enquiry = 0;
> scsi->active_queues = be32_to_cpu(setup->num_scsi_subq_channels);
> nvme->active_queues = be32_to_cpu(setup->num_nvme_subq_channels);
[Severity: High]
Does this code overflow scsi->scrqs[] or nvme->scrqs[] if the hypervisor
returns a value for setup->num_scsi_subq_channels or
setup->num_nvme_subq_channels that is larger than the allocated
scsi->max_queues or nvme->max_queues?
The active_queues values are read directly from the hypervisor response
without any bounds checking, and are then used as limits in the
initialization loops below.
If a buggy or malicious hypervisor sends excessively large values, could it
cause an out-of-bounds write into the scrqs array or cause page faults on
the setup buffer?
> + async->active_queues = (async->scrqs && setup->async_sub_crq_handle) ? 1 : 0;
>
> if (flags & IBMVFC_CHANNELS_CANCELED) {
> ibmvfc_dbg(vhost, "Channels Canceled\n");
> @@ -5832,6 +5840,8 @@ static void ibmvfc_channel_setup_done(struct ibmvfc_event *evt)
> for (i = 0; i < nvme->active_queues; i++)
> nvme->scrqs[i].vios_cookie =
> be64_to_cpu(setup->channel_handles[scsi->active_queues + i]);
> + for (i = 0; i < async->active_queues; i++)
> + async->scrqs[i].vios_cookie = be64_to_cpu(setup->async_sub_crq_handle);
>
> ibmvfc_dbg(vhost, "Using %u SCSI channels\n",
> scsi->active_queues);
[ ... ]
> @@ -6988,6 +7004,7 @@ static void ibmvfc_reg_sub_crqs(struct ibmvfc_host *vhost,
> for (j = i; j > 0; j--)
> ibmvfc_deregister_channel(vhost, channels, j - 1);
> vhost->do_enquiry = 0;
> + vhost->mq_enabled = 0;
[Severity: High]
Since vhost->do_enquiry and vhost->mq_enabled are bitfields, these
assignments compile into read-modify-write operations on the containing
word.
ibmvfc_reg_sub_crqs() is called by worker threads like
ibmvfc_reenable_crq_queue() outside of the host_lock.
If a tasklet concurrently processes an event and calls a completion handler
like ibmvfc_channel_setup_done() (which executes under host_lock and writes
to another bitfield in the same word, such as vhost->using_channels = 1),
could this lockless read-modify-write overwrite the locked modifications
and corrupt the host state machine flags?
[Severity: Critical]
If channel registration fails here, vhost->mq_enabled is cleared to 0.
Since async_scrqs is successfully registered earlier in
ibmvfc_init_sub_crqs(), when teardown happens, ibmvfc_release_sub_crqs()
will call ibmvfc_dereg_sub_crqs() for async_scrqs.
However, ibmvfc_dereg_sub_crqs() returns immediately if
!vhost->mq_enabled:
drivers/scsi/ibmvscsi/ibmvfc-core.c:ibmvfc_dereg_sub_crqs() {
if (!vhost->mq_enabled || !channels->scrqs)
return;
...
}
Will this cause ibmvfc_dereg_sub_crqs() to bypass deregistering the async
sub-CRQ, leaving the hypervisor DMA mappings and IRQ handlers active while
the memory is subsequently freed by ibmvfc_release_channels()?
> return;
> }
> }
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261015-ibmvfc-fpin-support-v14-0-a0b063b8d825@linux.ibm.com?part=10
next prev parent reply other threads:[~2026-10-15 15:28 UTC|newest]
Thread overview: 31+ 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-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-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 [this message]
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=sashiko-outbox-173070@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.