Linux SCSI subsystem development
 help / color / mirror / Atom feed
From: Dave Marquardt <davemarq@linux.ibm.com>
To: sashiko-bot@kernel.org
Cc: "Tyrel Datwyler" <tyreld@linux.ibm.com>,
	sashiko-reviews@lists.linux.dev, linux-scsi@vger.kernel.org
Subject: Re: [PATCH v11 09/11] scsi: ibmvfc: extend channel reg/dereg helpers for async sub-CRQ
Date: Mon, 28 Sep 2026 10:55:25 -0500	[thread overview]
Message-ID: <87eced5q1e.fsf@linux.ibm.com> (raw)
In-Reply-To: <20260925050533.1FCBC1F000FF@smtp.kernel.org> (sashiko-bot@kernel.org's message of "Fri, 25 Sep 2026 05:05:32 +0000")

sashiko-bot@kernel.org writes:

> Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
> - [Low] scsi: ibmvfc: kernel-doc incorrectly instructs passing negative index
> --
>
> commit 6798e7ba7398cb1f91e10a6432ae9b3192653f37
> Author: Dave Marquardt <davemarq@linux.ibm.com>
>
> scsi: ibmvfc: extend channel reg/dereg helpers for async sub-CRQ
>
> ibmvfc_register_channel() and ibmvfc_deregister_channel() previously only
> handled SCSI and NVMe sub-CRQ channels identified by the channel protocol.
> The async sub-CRQ had no registration path through these helpers, requiring
> separate handling. This commit adds IBMVFC_PROTO_ASYNC to extend both
> functions to handle the async sub-CRQ.
>
>> diff --git a/drivers/scsi/ibmvscsi/ibmvfc-core.c b/drivers/scsi/ibmvscsi/ibmvfc-core.c
>> index b354bfb1a9b67..b967c82e99430 100644
>> --- a/drivers/scsi/ibmvscsi/ibmvfc-core.c
>> +++ b/drivers/scsi/ibmvscsi/ibmvfc-core.c
> [ ... ]
>> @@ -6812,6 +6812,21 @@ static int ibmvfc_init_crq(struct ibmvfc_host *vhost)
>>  	return retrc;
>>  }
>>  
>> +/**
>> + * ibmvfc_register_channel - Register a sub-CRQ channel with the hypervisor
>> + * @vhost:	ibmvfc host struct
>> + * @channels:	ibmvfc channels struct containing the channel array and protocol
>> + * @index:	index into the channels array for the queue to register, or
>> + *		a negative value to register the async sub-CRQ
>> + *
>> + * Register a sub-CRQ with the hypervisor via h_reg_sub_crq, map its hardware
>> + * IRQ to a Linux IRQ, and bind an interrupt handler to it. The handler is
>> + * selected based on the channel protocol (SCSI or NVMe) for normal queues, or
>> + * set to the async sub-CRQ handler when @index is negative.
>> + *
>> + * Return value:
>> + *	0 on success / non-zero on failure
>> + **/
>>  static int ibmvfc_register_channel(struct ibmvfc_host *vhost,
>>  				   struct ibmvfc_channels *channels,
>>  				   int index)
>
> [Severity: Low]
> Does this kernel-doc correctly document the expected index values?
>
> The documentation explicitly directs the caller to pass a negative index for
> async sub-CRQs, but ibmvfc_register_channel() begins with an unconditional
> array access:
>
>     struct ibmvfc_queue *scrq = &channels->scrqs[index];
>
> If a developer follows the documentation and passes a negative index, wouldn't
> this result in an immediate out-of-bounds array access? Currently, callers
> pass 0 for the async sub-CRQ, so this crash isn't reachable today, but the
> comment could mislead future users.

Right. This suggestion to use a negative index is an artifact of older
implementation choices and was missed in more recent patch
revisions. I'll fix it in v12.

> [ ... ]
>> @@ -6883,6 +6905,18 @@ static int ibmvfc_register_channel(struct ibmvfc_host *vhost,
>>  	return rc;
>>  }
>>  
>> +/**
>> + * ibmvfc_deregister_channel - Deregister a sub-CRQ channel with the hypervisor
>> + * @vhost:	ibmvfc host struct
>> + * @channels:	ibmvfc channels struct containing the sub-CRQ array
>> + * @index:	index into the sub-CRQ array, or -1 to deregister the
>> + *		asynchronous sub-CRQ
>> + *
>> + * Frees the IRQ, disposes of the IRQ mapping, and calls H_FREE_SUB_CRQ to
>> + * release the sub-CRQ with the hypervisor. On success the queue message
>> + * buffer is zeroed and the current index is reset. If H_FREE_SUB_CRQ fails,
>> + * an error is logged but the channel resources are cleaned up regardless.
>> + */
>>  static void ibmvfc_deregister_channel(struct ibmvfc_host *vhost,
>>  				      struct ibmvfc_channels *channels,
>>  				      int index)
>
> [Severity: Low]
> Is this the same documentation issue as above?
>
> The kernel-doc for ibmvfc_deregister_channel() directs using -1 for the
> asynchronous sub-CRQ, but similar to ibmvfc_register_channel(), it accesses
> the array unconditionally:
>
>     struct ibmvfc_queue *scrq = &channels->scrqs[index];
>
> Could this lead to an out-of-bounds array access if someone passes -1 as
> documented?

I'll fix this also.

-Dave

  reply	other threads:[~2026-09-28 15:55 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-25  4:48 [PATCH v11 00/11] scsi: ibmvfc: make ibmvfc support FPIN messages Tyrel Datwyler
2026-09-25  4:48 ` [PATCH v11 01/11] scsi: ibmvfc: fix IRQ leak and guard deregister on channel reg failure Tyrel Datwyler
2026-09-25  4:48 ` [PATCH v11 02/11] scsi: ibmvfc: fix potential clobbering of rc after failed irq setup Tyrel Datwyler
2026-09-25  4:48 ` [PATCH v11 03/11] scsi: ibmvfc: fix potential NULL pointer dereference on failed queue allocation Tyrel Datwyler
2026-09-25  4:48 ` [PATCH v11 04/11] scsi: ibmvfc: add basic FPIN support Tyrel Datwyler
2026-09-25  5:03   ` sashiko-bot
2026-09-25 16:16     ` Dave Marquardt
2026-09-25 16:36       ` Dave Marquardt
2026-09-28 14:11         ` Dave Marquardt
2026-09-25  4:48 ` [PATCH v11 05/11] scsi: ibmvfc: add NOOP command support Tyrel Datwyler
2026-09-25  4:48 ` [PATCH v11 06/11] scsi: ibmvfc: add FPIN extended flag and async sub-CRQ queue handle Tyrel Datwyler
2026-09-25  4:48 ` [PATCH v11 07/11] scsi: ibmvfc: extend async event handlers for async sub-CRQ events Tyrel Datwyler
2026-09-25  5:00   ` sashiko-bot
2026-09-28 15:45     ` Dave Marquardt
2026-09-25  4:48 ` [PATCH v11 08/11] scsi: ibmvfc: add interrupt routine for asynchronous sub CRQ Tyrel Datwyler
2026-09-25  4:48 ` [PATCH v11 09/11] scsi: ibmvfc: extend channel reg/dereg helpers for async sub-CRQ Tyrel Datwyler
2026-09-25  5:05   ` sashiko-bot
2026-09-28 15:55     ` Dave Marquardt [this message]
2026-09-25  4:48 ` [PATCH v11 10/11] scsi: ibmvfc: register and use asynchronous sub CRQ for events Tyrel Datwyler
2026-09-25  5:09   ` sashiko-bot
2026-09-28 22:30     ` Dave Marquardt
2026-09-29 15:33       ` Tyrel Datwyler
2026-09-25  4:49 ` [PATCH v11 11/11] scsi: ibmvfc: handle extended FPIN events Tyrel Datwyler

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=87eced5q1e.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 \
    --cc=tyreld@linux.ibm.com \
    /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