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 v13 10/11] scsi: ibmvfc: register and use asynchronous sub CRQ for events
Date: Tue, 13 Oct 2026 17:02:24 -0500 [thread overview]
Message-ID: <87ik35b6of.fsf@linux.ibm.com> (raw)
In-Reply-To: <sashiko-outbox-163319@kernel.org> (sashiko-bot@kernel.org's message of "Wed, 07 Oct 2026 19:42:45 +0000")
sashiko-bot@kernel.org writes:
> Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
> - [High] scsi: ibmvfc: host state machine stall if ibmvfc_reg_sub_crqs() fails
> - [High] scsi: ibmvfc: NULL pointer deref in channel setup when mq_enabled=0
> --
>
> commit 3dd02df8d62690f440ff03238afa2613397c578a
> 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. Updates
> ibmvfc_set_login_info() to advertise related capabilities.
>
>> diff --git a/drivers/scsi/ibmvscsi/ibmvfc-core.c b/drivers/scsi/ibmvscsi/ibmvfc-core.c
>> index 76246002ac724..acc11f3a237e1 100644
>> --- a/drivers/scsi/ibmvscsi/ibmvfc-core.c
>> +++ b/drivers/scsi/ibmvscsi/ibmvfc-core.c
> [ ... ]
>> @@ -5821,6 +5828,7 @@ 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]);
>> + async->scrqs[0].vios_cookie = be64_to_cpu(setup->async_sub_crq_handle);
>
> [Severity: High]
> Can this cause a NULL pointer dereference when the module parameter mq_enabled
> is 0?
>
> If mq_enabled is 0, ibmvfc_init_sub_crqs() returns early and skips allocation,
> leaving async->scrqs as NULL but vhost->do_enquiry as 1.
>
> If the VIOS later advertises IBMVFC_CAN_SUPPORT_CHANNELS during NPIV login,
> ibmvfc_npiv_login_done() sees do_enquiry is true and issues a channel enquiry.
> When that completes, we reach this code and unconditionally dereference the
> unallocated async->scrqs array.
Yes, it is a problem! I will fix in v14.
> [ ... ]
>> @@ -5880,6 +5889,7 @@ static void ibmvfc_channel_setup(struct ibmvfc_host *vhost)
>> for (i = 0; i < nvme_channels; i++)
>> setup_buf->channel_handles[scsi_channels + i] =
>> cpu_to_be64(nvme->scrqs[i].cookie);
>> + setup_buf->async_sub_crq_handle = cpu_to_be64(async->scrqs[0].cookie);
>> }
>
> [Severity: High]
> Similarly, can this unconditional access to async->scrqs[0].cookie trigger a
> NULL pointer dereference when mq_enabled is 0?
Yes.
> [ ... ]
>> @@ -7023,17 +7039,38 @@ static int ibmvfc_alloc_channels(struct ibmvfc_host *vhost,
> [ ... ]
>> static void ibmvfc_init_sub_crqs(struct ibmvfc_host *vhost)
>> {
>> ENTER;
>> if (!vhost->mq_enabled)
>> return;
>>
>> - if (ibmvfc_alloc_channels(vhost, &vhost->scsi_scrqs)) {
>> - vhost->do_enquiry = 0;
>> - vhost->mq_enabled = 0;
>> - return;
>> - }
>> + /* register async_sub_crq channel */
>> + if (ibmvfc_alloc_channels(vhost, &vhost->async_scrqs))
>> + goto out;
>> +
>> + ibmvfc_reg_sub_crqs(vhost, &vhost->async_scrqs);
>
> [Severity: High]
> Does this cause a host state machine stall if ibmvfc_reg_sub_crqs() fails?
>
> If ibmvfc_reg_sub_crqs() fails internally, it clears vhost->do_enquiry but
> leaves vhost->mq_enabled set to 1. Because mq_enabled remains true,
> ibmvfc_set_login_info() continues to advertise IBMVFC_CAN_USE_CHANNELS to
> the VIOS.
>
> When the VIOS responds with IBMVFC_CAN_SUPPORT_CHANNELS,
> ibmvfc_npiv_login_done() enters the multi-queue branch, but because
> do_enquiry is now 0, it skips calling ibmvfc_channel_enquiry().
>
> It also bypasses the fallback block that would normally set
> IBMVFC_HOST_ACTION_QUERY and wake up vhost->work_wait_q:
>
> 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);
> }
> }
>
> Will this cause the initialization process to stall indefinitely in
> IBMVFC_HOST_ACTION_INIT_WAIT?
Yes, this appears to cause a stall.
-Dave
next prev parent reply other threads:[~2026-10-13 22:02 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-07 19:25 [PATCH v13 00/11] scsi: ibmvfc: make ibmvfc support FPIN messages Dave Marquardt via B4 Relay
2026-10-07 19:25 ` [PATCH v13 01/11] scsi: ibmvfc: fix IRQ leak and guard deregister on channel reg failure Dave Marquardt via B4 Relay
2026-10-07 19:25 ` [PATCH v13 02/11] scsi: ibmvfc: fix potential clobbering of rc after failed irq setup Dave Marquardt via B4 Relay
2026-10-07 19:25 ` [PATCH v13 03/11] scsi: ibmvfc: fix potential NULL pointer dereference on failed queue allocation Dave Marquardt via B4 Relay
2026-10-07 19:44 ` sashiko-bot
2026-10-09 18:34 ` Dave Marquardt
2026-10-07 19:25 ` [PATCH v13 04/11] scsi: ibmvfc: add basic FPIN support Dave Marquardt via B4 Relay
2026-10-07 19:41 ` sashiko-bot
2026-10-08 21:24 ` Dave Marquardt
2026-10-09 5:20 ` kernel test robot
2026-10-09 14:45 ` Dave Marquardt
2026-10-07 19:25 ` [PATCH v13 05/11] scsi: ibmvfc: add NOOP command support Dave Marquardt via B4 Relay
2026-10-07 19:36 ` sashiko-bot
2026-10-12 19:24 ` Dave Marquardt
2026-10-07 19:25 ` [PATCH v13 06/11] scsi: ibmvfc: add FPIN extended flag and async sub-CRQ queue handle Dave Marquardt via B4 Relay
2026-10-07 19:25 ` [PATCH v13 07/11] scsi: ibmvfc: extend async event handlers for async sub-CRQ events Dave Marquardt via B4 Relay
2026-10-09 13:22 ` kernel test robot
2026-10-09 14:50 ` Dave Marquardt
2026-10-07 19:25 ` [PATCH v13 08/11] scsi: ibmvfc: add interrupt routine for asynchronous sub CRQ Dave Marquardt via B4 Relay
2026-10-07 19:44 ` sashiko-bot
2026-10-12 19:44 ` Dave Marquardt
2026-10-07 19:25 ` [PATCH v13 09/11] scsi: ibmvfc: extend channel reg/dereg helpers for async sub-CRQ Dave Marquardt via B4 Relay
2026-10-07 19:25 ` [PATCH v13 10/11] scsi: ibmvfc: register and use asynchronous sub CRQ for events Dave Marquardt via B4 Relay
2026-10-07 19:42 ` sashiko-bot
2026-10-13 22:02 ` Dave Marquardt [this message]
2026-10-07 19:25 ` [PATCH v13 11/11] scsi: ibmvfc: handle extended FPIN events Dave Marquardt via B4 Relay
2026-10-07 19:33 ` sashiko-bot
2026-10-07 19:52 ` Dave Marquardt
2026-10-09 20:29 ` kernel test robot
2026-10-12 19:50 ` 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=87ik35b6of.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