All of lore.kernel.org
 help / color / mirror / Atom feed
From: Dave Marquardt <davemarq@linux.ibm.com>
To: sashiko-reviews@lists.linux.dev
Cc: linux-scsi@vger.kernel.org
Subject: Re: [PATCH v7 7/8] scsi: ibmvfc: register and use asynchronous sub CRQ for events
Date: Tue, 08 Sep 2026 14:52:05 -0500	[thread overview]
Message-ID: <8733vj34ii.fsf@linux.ibm.com> (raw)
In-Reply-To: <20260831224601.C23911F000E9@smtp.kernel.org>

sashiko-bot@kernel.org writes:

> Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
>
> New issues:
> - [High] Unconditional deregistration of the uninitialized async sub-CRQ causes a NULL pointer dereference.
>
> Pre-existing issues:
> - [High] Buffer overflow due to out-of-bounds array writes and reads when processing unvalidated queue counts from the VIOS.
> --
>
> commit 908a7af2b04b0b17f4fc0a40814f0dacec88332a
> Author: Dave Marquardt <davemarq@linux.ibm.com>
> scsi: ibmvfc: register and use asynchronous sub CRQ for events
>
> This commit wires the asynchronous sub-CRQ into the sub-CRQ lifecycle so it is
> allocated, registered, and freed alongside the SCSI channel queues. It modifies
> multi-queue initialization and teardown paths to accommodate the new queue and
> advertises relevant capabilities to the VIOS.
>
>> diff --git a/drivers/scsi/ibmvscsi/ibmvfc-core.c b/drivers/scsi/ibmvscsi/ibmvfc-core.c
>> index cc1ef82580608..adc730af67d2b 100644
>> --- a/drivers/scsi/ibmvscsi/ibmvfc-core.c
>> +++ b/drivers/scsi/ibmvscsi/ibmvfc-core.c
>
> [ ... ]
>
>> @@ -5800,6 +5808,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]);
>> +		vhost->async_sub_crq.vios_cookie = be64_to_cpu(setup->async_sub_crq_handle);
>>  
>>  		ibmvfc_dbg(vhost, "Using %u SCSI channels\n",
>
> [Severity: High]
> This is a pre-existing issue, but can this out-of-bounds write occur if the
> VIOS returns untrusted queue counts?
>
> In ibmvfc_channel_setup_done(), the driver reads num_scsi_subq_channels and
> num_nvme_subq_channels from the VIOS response into active_queues without
> validating them against the dynamically allocated max_queues array size:
>
> ibmvfc_channel_setup_done() {
>     scsi->active_queues = be32_to_cpu(setup->num_scsi_subq_channels);
>     nvme->active_queues = be32_to_cpu(setup->num_nvme_subq_channels);
>     ...
> }
>
> The loop just above this patch hunk then directly uses this unvalidated value
> to write to the scrqs array:
>
> ibmvfc_channel_setup_done() {
>     ...
>     for (i = 0; i < scsi->active_queues; i++)
>         scsi->scrqs[i].vios_cookie =
>             be64_to_cpu(setup->channel_handles[i]);
>     ...
> }
>
> Could a compromised or malfunctioning VIOS provide values that exceed the
> locally allocated array size and cause a buffer overflow here?

We've always assumed the VIOS acts sanely. This issue will not be fixed
at this time.

> [ ... ]
>
>> @@ -7055,6 +7087,9 @@ static void ibmvfc_release_channels(struct ibmvfc_host *vhost,
>>  static void ibmvfc_release_sub_crqs(struct ibmvfc_host *vhost)
>>  {
>>  	ENTER;
>> +	ibmvfc_deregister_channel(vhost, &vhost->scsi_scrqs, -1);
>> +	ibmvfc_free_queue(vhost, &vhost->async_sub_crq);
>> +
>>  	if (!vhost->scsi_scrqs.scrqs)
>>  		return;
>
> [Severity: High]
> Does this unconditional teardown cause a NULL pointer dereference when
> multi-queue is disabled?
>
> During module unload or reset, if multi-queue was disabled (mq_enabled=0) or
> initialization failed, vhost->async_sub_crq is left zero-initialized.
>
> Unconditionally calling ibmvfc_deregister_channel() routes to a cleanup path
> that behaves as follows:
>
> ibmvfc_deregister_channel() {
>     ...
>     /* Clean out the queue */
>     memset(scrq->msgs.crq, 0, PAGE_SIZE);
>     ...
> }
>
> Since msgs.crq aliases the unallocated msgs.handle (which is NULL), will this
> memset() write 4KB of zeroes to a NULL pointer and cause a deterministic
> kernel panic?

A new check against scrq->msgs.handle will be added to
ibmvfc_deregister_channel() in the next revision of this patch,
preventing memset() against a NULL pointer.

-Dave

  reply	other threads:[~2026-09-08 19:52 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-31 19:00 [PATCH v7 0/8] scsi: ibmvfc: make ibmvfc support FPIN messages Dave Marquardt via B4 Relay
2026-08-31 19:00 ` Dave Marquardt
2026-08-31 19:00 ` [PATCH v7 1/8] scsi: ibmvfc: add basic FPIN support Dave Marquardt via B4 Relay
2026-08-31 19:00   ` Dave Marquardt
2026-08-31 21:30   ` sashiko-bot
2026-09-02 20:29     ` Dave Marquardt
2026-09-02 21:59     ` Dave Marquardt
2026-08-31 19:00 ` [PATCH v7 2/8] scsi: ibmvfc: Add NOOP command support Dave Marquardt via B4 Relay
2026-08-31 19:00   ` Dave Marquardt
2026-08-31 21:40   ` sashiko-bot
2026-09-03 15:08     ` Dave Marquardt
2026-08-31 19:00 ` [PATCH v7 3/8] scsi: ibmvfc: add FPIN extended flag and async sub-CRQ queue handle Dave Marquardt via B4 Relay
2026-08-31 19:00   ` Dave Marquardt
2026-08-31 19:00 ` [PATCH v7 4/8] scsi: ibmvfc: extend async event handlers to handle async sub queue events Dave Marquardt via B4 Relay
2026-08-31 19:00   ` Dave Marquardt
2026-08-31 19:00 ` [PATCH v7 5/8] scsi: ibmvfc: add interrupt routine for asynchronous sub CRQ Dave Marquardt via B4 Relay
2026-08-31 19:00   ` Dave Marquardt
2026-08-31 22:18   ` sashiko-bot
2026-09-03 16:18     ` Dave Marquardt
2026-08-31 19:00 ` [PATCH v7 6/8] scsi: ibmvfc: extend channel registration and deregistration for async subq Dave Marquardt via B4 Relay
2026-08-31 19:00   ` Dave Marquardt
2026-08-31 22:34   ` sashiko-bot
2026-09-03 18:43     ` Dave Marquardt
2026-08-31 19:00 ` [PATCH v7 7/8] scsi: ibmvfc: register and use asynchronous sub CRQ for events Dave Marquardt via B4 Relay
2026-08-31 19:00   ` Dave Marquardt
2026-08-31 22:46   ` sashiko-bot
2026-09-08 19:52     ` Dave Marquardt [this message]
2026-08-31 19:00 ` [PATCH v7 8/8] scsi: ibmvfc: handle extended FPIN events Dave Marquardt via B4 Relay
2026-08-31 19:00   ` Dave Marquardt
2026-08-31 22:56   ` sashiko-bot
2026-09-08 19:53     ` 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=8733vj34ii.fsf@linux.ibm.com \
    --to=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.