Linux SCSI subsystem development
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Dave Marquardt" <davemarq@linux.ibm.com>
Cc: linux-scsi@vger.kernel.org
Subject: Re: [PATCH v18 09/13] scsi: ibmvfc: extend async event handlers for async sub-CRQ events
Date: Thu, 05 Nov 2026 18:25:37 +0000	[thread overview]
Message-ID: <sashiko-outbox-199759@kernel.org> (raw)
In-Reply-To: <20261105-ibmvfc-fpin-support-v18-9-d683b74736a3@linux.ibm.com>

Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [High] scsi: ibmvfc: NULL crq dereference in ibmvfc_process_async_work()
- [High] scsi: ibmvfc: uninitialized tgt read in ibmvfc_process_async_work()
--

commit 6abed589f0fb0c5ef9d54c07ceaaef90b5ef640d
Author: Dave Marquardt <davemarq@linux.ibm.com>

scsi: ibmvfc: extend async event handlers for async sub-CRQ events

This commit refactors async event handling in ibmvfc to support both main
CRQ and async sub-CRQ events via a tagged union struct
ibmvfc_async_crq_event, and adds ibmvfc_full_fpin_to_desc() and assoc_id
target matching.

> diff --git a/drivers/scsi/ibmvscsi/ibmvfc-core.c b/drivers/scsi/ibmvscsi/ibmvfc-core.c
> index b9b571db44649..7406e7182777c 100644
> --- a/drivers/scsi/ibmvscsi/ibmvfc-core.c
> +++ b/drivers/scsi/ibmvscsi/ibmvfc-core.c
[ ... ]
> @@ -3483,33 +3528,59 @@ static struct ibmvfc_target *ibmvfc_find_target(struct list_head *target_list,
>   */
>  VISIBLE_IF_KUNIT void ibmvfc_process_async_work(struct work_struct *work)
>  {
> +	struct ibmvfc_async_sub_crq *subq = NULL;
>  	struct ibmvfc_async_work *aw;
> -	struct ibmvfc_async_crq *crq;
> +	struct ibmvfc_async_crq *crq = NULL;
>  	struct ibmvfc_target *tgt;

[Severity: High]
Should tgt be initialized to NULL here?

When scsi_id, wwpn, node_name, and assoc_id are all zero,
ibmvfc_process_async_work() jumps directly to the send_fpin label before
tgt is assigned by ibmvfc_find_target():

	if (!scsi_id && !wwpn && !node_name && !assoc_id) {
		if (fpin_status == IBMVFC_AE_FPIN_LINK_CONGESTED ||
		    fpin_status == IBMVFC_AE_FPIN_CONGESTION_CLEARED)
			fpin = ibmvfc_basic_fpin_to_desc(crq,
					cpu_to_be64(fc_host_port_name(vhost->host)), 0);
		goto send_fpin;
	}

At the end of send_fpin, the cleanup checks:

	if (tgt)
		kref_put(&tgt->kref, ibmvfc_release_tgt);

Wouldn't that evaluate and potentially dereference an uninitialized tgt
pointer on the zero-identifier path?

>  	struct ibmvfc_host *vhost;
> -	struct fc_els_fpin *fpin;
> +	struct fc_els_fpin *fpin = NULL;
>  	unsigned long flags;
> +	__be64 assoc_id;
> +	__be64 node_name;
> +	__be64 scsi_id;
> +	__be64 wwpn;
> +	u8 fpin_status;
>  
>  	aw = container_of_const(work, struct ibmvfc_async_work, async_work_s);
>  	vhost = aw->vhost;
> -	crq = &aw->crq;
> +	if (aw->event.type == IBMVFC_ASYNC_CRQ_SUB) {
> +		subq = &aw->event.subq;
> +		scsi_id = 0;
> +		wwpn = subq->wwpn;
> +		fpin_status = subq->fpin_status;
> +		if (subq->flags & IBMVFC_ASYNC_ID_IS_ASSOC_ID) {
> +			node_name = 0;
> +			assoc_id = subq->id.assoc_id;
> +		} else if (subq->flags & IBMVFC_ASYNC_IS_FPIN_EXT) {
> +			node_name = 0;
> +			assoc_id = 0;
> +		} else {
> +			node_name = subq->id.node_name;
> +			assoc_id = 0;
> +		}
> +	} else {
> +		crq = &aw->event.async_crq;
> +		scsi_id = crq->scsi_id;
> +		wwpn = crq->wwpn;
> +		node_name = crq->node_name;
> +		fpin_status = crq->fpin_status;
> +		assoc_id = 0;
> +	}
>  
> -	if (!crq->scsi_id && !crq->wwpn && !crq->node_name) {
> -		if (crq->fpin_status == IBMVFC_AE_FPIN_LINK_CONGESTED ||
> -		    crq->fpin_status == IBMVFC_AE_FPIN_CONGESTION_CLEARED)
> +	if (!scsi_id && !wwpn && !node_name && !assoc_id) {
> +		if (fpin_status == IBMVFC_AE_FPIN_LINK_CONGESTED ||
> +		    fpin_status == IBMVFC_AE_FPIN_CONGESTION_CLEARED)
>  			fpin = ibmvfc_basic_fpin_to_desc(crq,
>  					cpu_to_be64(fc_host_port_name(vhost->host)), 0);
>  		goto send_fpin;
>  	}

[Severity: High]
Can this dereference a NULL crq pointer when handling an async sub-CRQ
event?

When aw->event.type is IBMVFC_ASYNC_CRQ_SUB, subq is populated and crq
remains NULL. If scsi_id, wwpn, node_name, and assoc_id are all zero for a
host-scope IBMVFC_AE_FPIN_LINK_CONGESTED or
IBMVFC_AE_FPIN_CONGESTION_CLEARED event, this block unconditionally calls
ibmvfc_basic_fpin_to_desc(crq, ...), which immediately dereferences
crq->fpin_status:

static struct fc_els_fpin *
ibmvfc_basic_fpin_to_desc(struct ibmvfc_async_crq *crq, __be64 detecting_wwpn,
			  u64 wwpn)
{
	__be16 type;

	switch (crq->fpin_status) {

Should this path check if (crq) and dispatch to
ibmvfc_full_fpin_to_desc(subq, ...) when crq is NULL, matching the target
fallback path further down in ibmvfc_process_async_work()?

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261105-ibmvfc-fpin-support-v18-0-d683b74736a3@linux.ibm.com?part=9

  reply	other threads:[~2026-11-05 18:25 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-05 17:22 [PATCH v18 00/13] scsi: ibmvfc: make ibmvfc support FPIN messages Dave Marquardt via B4 Relay
2026-11-05 17:22 ` [PATCH v18 01/13] scsi: ibmvfc: fix IRQ leak and guard deregister on channel reg failure Dave Marquardt via B4 Relay
2026-11-05 17:22 ` [PATCH v18 02/13] scsi: ibmvfc: fix potential clobbering of rc after failed irq setup Dave Marquardt via B4 Relay
2026-11-05 17:22 ` [PATCH v18 03/13] scsi: ibmvfc: fix potential NULL pointer dereference on failed queue allocation Dave Marquardt via B4 Relay
2026-11-05 17:22 ` [PATCH v18 04/13] scsi: ibmvfc: fix stale rc and IRQ mapping leak in ibmvfc_register_channel() Dave Marquardt via B4 Relay
2026-11-05 17:22 ` [PATCH v18 05/13] scsi: ibmvfc: fix resource leaks on partial queue allocation failure Dave Marquardt via B4 Relay
2026-11-05 18:00   ` sashiko-bot
2026-11-05 17:22 ` [PATCH v18 06/13] scsi: ibmvfc: add basic FPIN support Dave Marquardt via B4 Relay
2026-11-05 18:09   ` sashiko-bot
2026-11-05 17:23 ` [PATCH v18 07/13] scsi: ibmvfc: add NOOP command support Dave Marquardt via B4 Relay
2026-11-05 17:23 ` [PATCH v18 08/13] scsi: ibmvfc: add FPIN extended flag and async sub-CRQ queue handle Dave Marquardt via B4 Relay
2026-11-05 17:23 ` [PATCH v18 09/13] scsi: ibmvfc: extend async event handlers for async sub-CRQ events Dave Marquardt via B4 Relay
2026-11-05 18:25   ` sashiko-bot [this message]
2026-11-05 17:23 ` [PATCH v18 10/13] scsi: ibmvfc: add interrupt routine for asynchronous sub CRQ Dave Marquardt via B4 Relay
2026-11-05 17:23 ` [PATCH v18 11/13] scsi: ibmvfc: extend channel registration for async sub-CRQ Dave Marquardt via B4 Relay
2026-11-05 17:23 ` [PATCH v18 12/13] scsi: ibmvfc: register and use asynchronous sub CRQ for events Dave Marquardt via B4 Relay
2026-11-05 17:23 ` [PATCH v18 13/13] scsi: ibmvfc: handle extended FPIN events Dave Marquardt via B4 Relay

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-199759@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox