From: Dave Marquardt <davemarq@linux.ibm.com>
To: sashiko-reviews@lists.linux.dev
Cc: linux-scsi@vger.kernel.org
Subject: Re: [PATCH v6 1/8] scsi: ibmvfc: add basic FPIN support
Date: Fri, 21 Aug 2026 10:09:05 -0500 [thread overview]
Message-ID: <87a4qfy0ha.fsf@linux.ibm.com> (raw)
In-Reply-To: <20260817203721.748DA1F000E9@smtp.kernel.org>
sashiko-bot@kernel.org writes:
>> diff --git a/drivers/scsi/ibmvscsi/ibmvfc-core.c b/drivers/scsi/ibmvscsi/ibmvfc-core.c
>> index 93b9f699c2e53..22b4d639e74be 100644
>> --- a/drivers/scsi/ibmvscsi/ibmvfc-core.c
>> +++ b/drivers/scsi/ibmvscsi/ibmvfc-core.c
>
> [ ... ]
>
>> @@ -6945,6 +7213,9 @@ static void ibmvfc_remove(struct vio_dev *vdev)
>> ENTER;
>> ibmvfc_remove_trace_file(&vhost->host->shost_dev.kobj, &ibmvfc_trace_attr);
>>
>> + destroy_workqueue(vhost->fpin_workq);
>> + vhost->fpin_workq = NULL;
>> +
>
> [Severity: High]
> Is the fpin_workq destroyed too early during driver removal?
>
> If an asynchronous FPIN event arrives from the fabric after this point but
> before the CRQ is torn down in ibmvfc_release_crq_queue() later in the
> function, ibmvfc_handle_async() could be called and attempt to queue work:
>
> ibmvfc_handle_async()
> ...
> queue_work(vhost->fpin_workq, &aw->async_work_s);
>
> Could this result in a NULL pointer dereference?
Yes, this is a problem. I've fixed it for v7.
>> spin_lock_irqsave(vhost->host->host_lock, flags);
>> ibmvfc_link_down(vhost, IBMVFC_HOST_OFFLINE);
>> spin_unlock_irqrestore(vhost->host->host_lock, flags);
>
> [ ... ]
>
>> diff --git a/drivers/scsi/ibmvscsi/ibmvfc_kunit.c b/drivers/scsi/ibmvscsi/ibmvfc_kunit.c
>> new file mode 100644
>> index 0000000000000..64a517a74af8e
>> --- /dev/null
>> +++ b/drivers/scsi/ibmvscsi/ibmvfc_kunit.c
>
> [ ... ]
>
>> +static void ibmvfc_async_fpin_test(struct kunit *test)
>> +{
>> + u64 post[IBMVFC_AE_FPIN_CONGESTION_CLEARED + 1];
>> + u64 pre[IBMVFC_AE_FPIN_CONGESTION_CLEARED + 1];
>> + enum ibmvfc_ae_fpin_status fs;
>> + struct fc_host_attrs *fc_host;
>> + struct ibmvfc_async_crq crq[IBMVFC_AE_FPIN_CONGESTION_CLEARED + 1];
>> + struct ibmvfc_target *tgt;
>> + struct ibmvfc_host *vhost;
>> + struct list_head *queue;
>> + struct list_head *headp;
>> +
>> + headp = ibmvfc_get_headp();
>> + if (list_empty(headp))
>> + kunit_skip(test, "No ibmvfc devices available");
>> + queue = headp->next;
>> + vhost = container_of_const(queue, struct ibmvfc_host, queue);
>> +
>> + KUNIT_ASSERT_GE_MSG(test, vhost->scsi_scrqs.num_targets, 1, "No targets");
>> + tgt = list_first_entry(&vhost->scsi_scrqs.targets, struct ibmvfc_target, queue);
>
> [Severity: Medium]
> Is it safe to iterate over the global ibmvfc_head list and access
> vhost->scsi_scrqs.targets without acquiring the ibmvfc_driver_lock or
> host_lock?
>
> If a device is unbound or a target logs out concurrently while the test
> runs, could the lists mutate and cause an invalid pointer dereference?
I'm not particularly concerned about this. I'm running the KUnit tests
on a quiet system.
>> + KUNIT_EXPECT_NOT_NULL(test, tgt->rport);
>> +
>> + fc_host = shost_to_fc_host(vhost->host);
>> +
>> + pre[IBMVFC_AE_FPIN_LINK_CONGESTED] = READ_ONCE(fc_host->fpin_stats.cn_device_specific);
>> + pre[IBMVFC_AE_FPIN_PORT_CONGESTED] = READ_ONCE(tgt->rport->fpin_stats.cn);
>
> [Severity: Medium]
> Since KUNIT_EXPECT_NOT_NULL() allows execution to continue on failure, could a
> NULL tgt->rport be immediately dereferenced on the following lines when reading
> tgt->rport->fpin_stats.cn?
>
> Should this use KUNIT_ASSERT_NOT_NULL() instead to abort the test and prevent a
> crash?
Changed to KUNIT_ASSERT_NOT_NULL() in v7.
>> + pre[IBMVFC_AE_FPIN_PORT_CLEARED] = READ_ONCE(tgt->rport->fpin_stats.cn_clear);
>> + pre[IBMVFC_AE_FPIN_PORT_DEGRADED] = READ_ONCE(tgt->rport->fpin_stats.li_failure_unknown);
>> + pre[IBMVFC_AE_FPIN_CONGESTION_CLEARED] = READ_ONCE(fc_host->fpin_stats.cn_clear);
>> +
>> + for (fs = IBMVFC_AE_FPIN_LINK_CONGESTED; fs <= IBMVFC_AE_FPIN_CONGESTION_CLEARED; fs++) {
>> + crq[fs].valid = 0x80;
>> + crq[fs].link_state = IBMVFC_AE_LS_LINK_UP;
>> + crq[fs].fpin_status = fs;
>> + crq[fs].event = cpu_to_be64(IBMVFC_AE_FPIN);
>> + crq[fs].scsi_id = cpu_to_be64(tgt->scsi_id);
>> + crq[fs].wwpn = cpu_to_be64(tgt->wwpn);
>> + crq[fs].node_name = cpu_to_be64(tgt->ids.node_name);
>> + ibmvfc_handle_async(&crq[fs], vhost);
>> + msleep(1U);
>> + }
>
> [Severity: Medium]
> Is msleep(1U) a reliable way to wait for the fpin_workq to process the
> offloaded FPIN event?
>
> Under load, it seems like 1 millisecond might be insufficient, causing the test
> to read stale counters and fail intermittently. Would it be safer to use
> flush_workqueue(vhost->fpin_workq) here instead of a hardcoded sleep?
Good idea. I've changed all of the KUnit tests throughout the series to
use flush_workqueue() rather than msleep() in v7.
-Dave
next prev parent reply other threads:[~2026-08-21 15:09 UTC|newest]
Thread overview: 24+ 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 [this message]
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-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
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=87a4qfy0ha.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox