Linux SCSI subsystem development
 help / color / mirror / Atom feed
From: Tyrel Datwyler <tyreld@linux.ibm.com>
To: Dave Marquardt <davemarq@linux.ibm.com>, sashiko-reviews@lists.linux.dev
Cc: linux-scsi@vger.kernel.org
Subject: Re: [PATCH v6 7/8] scsi: ibmvfc: register and use asynchronous sub CRQ for events
Date: Wed, 26 Aug 2026 14:57:22 -0700	[thread overview]
Message-ID: <7f3e63da-c28c-4696-9a4a-fe8fa7cd1d8e@linux.ibm.com> (raw)
In-Reply-To: <87jypjwk9f.fsf@linux.ibm.com>

On 8/21/26 8:44 AM, Dave Marquardt wrote:
> sashiko-bot@kernel.org writes:
> 
>> Thank you for your contribution! Sashiko AI review found 5 potential issue(s) to consider:
>>
>> New issues:
>> - [High] The newly added async_sub_crq is leaked and leaves its IRQ registered if ibmvfc_alloc_channels() fails during SCSI channel initialization.
>> - [High] The async_sub_crq is completely omitted from the CRQ reset and re-enable sequences, breaking its lifecycle.
>>
>> Pre-existing issues:
>> - [Critical] NULL pointer dereference in ibmvfc_channel_setup() when mq_enabled == 0.
>> - [High] Missing bounds checks on hypervisor-provided queue counts can lead to out-of-bounds array accesses.
>> - [High] Error codes from request_irq() are unconditionally clobbered, silently masking critical failures.
>> --
>>
>> --- Patch [7]: [PATCH v6 7/8] scsi: ibmvfc: register and use asynchronous sub CRQ for events ---
>> commit 10af0529db6ade6b831181ddc695f2e8713b38ee
>> 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
>>> --- a/drivers/scsi/ibmvscsi/ibmvfc-core.c
>>> +++ b/drivers/scsi/ibmvscsi/ibmvfc-core.c
>> [ ... ]
>>> @@ -5792,6 +5794,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]);
>>
>> [Severity: High]
>> This is a pre-existing issue, but is it possible for an unexpectedly large
>> response from the hypervisor to cause out-of-bounds array accesses here?
> 
> Up to this point in the driver history, we have trusted the answeres
> from PHYP, the IBM PowerVM hypervisor.
> 
>> Looking at drivers/scsi/ibmvscsi/ibmvfc-core.c:ibmvfc_channel_setup_done(),
>> the unvalidated active_queues count returned by the VIOS is used directly
>> as a loop limit to write into the driver's nvme->scrqs and scsi->scrqs
>> arrays.
>>
>> Could a malformed or compromised response corrupt adjacent memory?
>>
>>> +		vhost->async_sub_crq.vios_cookie = be64_to_cpu(setup->async_sub_crq_handle);
>>>  
>>>  		ibmvfc_dbg(vhost, "Using %u SCSI channels\n",
>>>  			   scsi->active_queues);
>> [ ... ]
>>> @@ -5851,6 +5854,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);
>>
>> [Severity: Critical]
>> This is a pre-existing issue, but does this loop risk a NULL pointer
>> dereference when mq_enabled is 0?
>>
>> Looking at drivers/scsi/ibmvscsi/ibmvfc-core.c:ibmvfc_channel_setup(),
>> if the driver is loaded with mq_enabled=0, ibmvfc_init_sub_crqs() returns
>> early without allocating scsi_scrqs.scrqs. 
>>
>> However, if a modern VIOS supports channels, the enquiry succeeds and sets
>> max_vios_scsi_channels > 0.
>>
>> This would cause ibmvfc_channel_setup() to compute scsi_channels > 0 and
>> unconditionally execute this loop, accessing the unallocated
>> scsi->scrqs[i].cookie array.
> 
> I will study this more, but it will not be fixed in the v7 patch series.

If mq=0 we do not do enquiry or channel setup, and fall back to legacy CRQ only
mode. This is a false-positive.

-Tyrel

  reply	other threads:[~2026-08-26 21:57 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-17 20:27 [PATCH v6 0/8] scsi: ibmvfc: make ibmvfc support FPIN messages Dave Marquardt via B4 Relay
2026-08-17 20:27 ` [PATCH v6 1/8] scsi: ibmvfc: add basic FPIN support Dave Marquardt via B4 Relay
2026-08-17 20:37   ` sashiko-bot
2026-08-21 15:09     ` Dave Marquardt
2026-08-17 20:27 ` [PATCH v6 2/8] scsi: ibmvfc: Add NOOP command support Dave Marquardt via B4 Relay
2026-08-17 20:41   ` sashiko-bot
2026-08-21 15:11     ` Dave Marquardt
2026-08-17 20:27 ` [PATCH v6 3/8] scsi: ibmvfc: define asynchronous sub-queue Dave Marquardt via B4 Relay
2026-08-17 20:39   ` sashiko-bot
2026-08-21 15:13     ` Dave Marquardt
2026-08-17 20:27 ` [PATCH v6 4/8] scsi: ibmvfc: extend async event handlers to handle async sub queue events Dave Marquardt via B4 Relay
2026-08-17 20:42   ` sashiko-bot
2026-08-21 15:16     ` Dave Marquardt
2026-08-17 20:27 ` [PATCH v6 5/8] scsi: ibmvfc: add interrupt routine for asynchronous sub CRQ Dave Marquardt via B4 Relay
2026-08-17 20:51   ` sashiko-bot
2026-08-21 15:29     ` Dave Marquardt
2026-08-17 20:27 ` [PATCH v6 6/8] scsi: ibmvfc: extend channel registration and deregistration for async subq Dave Marquardt via B4 Relay
2026-08-17 20:50   ` sashiko-bot
2026-08-21 15:30     ` Dave Marquardt
2026-08-17 20:28 ` [PATCH v6 7/8] scsi: ibmvfc: register and use asynchronous sub CRQ for events Dave Marquardt via B4 Relay
2026-08-17 20:42   ` sashiko-bot
2026-08-21 15:44     ` Dave Marquardt
2026-08-26 21:57       ` Tyrel Datwyler [this message]
2026-08-17 20:28 ` [PATCH v6 8/8] scsi: ibmvfc: handle extended FPIN events Dave Marquardt via B4 Relay
2026-08-17 20:41   ` sashiko-bot
2026-08-24 15:25     ` 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=7f3e63da-c28c-4696-9a4a-fe8fa7cd1d8e@linux.ibm.com \
    --to=tyreld@linux.ibm.com \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox