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 v6 8/8] scsi: ibmvfc: handle extended FPIN events
Date: Mon, 24 Aug 2026 10:25:16 -0500	[thread overview]
Message-ID: <87se43mtgj.fsf@linux.ibm.com> (raw)
In-Reply-To: <20260817204153.384DC1F000E9@smtp.kernel.org>

sashiko-bot@kernel.org writes:

> [Severity: High]
> Will extended FPIN events be incorrectly discarded here because of how the
> target lookup is performed?
>
> In the earlier part of ibmvfc_process_async_work(), node_name is read from
> the subq structure:
>
> ibmvfc_process_async_work() {
>         ...
>         if (is_subq) {
>                 subq = &aw->crq.subq;
>                 scsi_id = 0;
>                 wwpn = subq->wwpn;
>                 node_name = (subq->flags & IBMVFC_ASYNC_ID_IS_ASSOC_ID) ? 0 : subq->id.node_name;
>         }
>         ...
>         tgt = ibmvfc_find_target(&vhost->scsi_scrqs.targets, scsi_id, wwpn, node_name);
>         ...
>
> Because the ibmvfc_async_subq_fpin structure overlaps with the id union in
> ibmvfc_async_sub_crq, reading subq->id.node_name for extended FPINs will
> extract garbage bytes from the fpin_data.event_threshold and event_data
> fields.
>
> Does this cause ibmvfc_find_target() to fail and drop valid events?

Yes, quite possibly. I've updated the code that sets node_name in
ibmvfc_process_async_work() and ibmvfc_handle_async() to take into
account that node_name isn't available in the extended FPIN case.

> [Severity: High]
> Can this lead to a NULL pointer dereference during driver removal?
>
> When ibmvfc_remove() is called, the fpin_workq is destroyed:
>
> ibmvfc_remove() {
>         ...
>         destroy_workqueue(vhost->fpin_workq);
>         vhost->fpin_workq = NULL;
>         ...
> }
>
> If an FPIN interrupt arrives before the CRQ queues are disabled, the
> interrupt handler unconditionally queues work to it:
>
> ibmvfc_handle_async() {
>         ...
>         case IBMVFC_AE_FPIN:
>                 aw = kzalloc(sizeof(struct ibmvfc_async_work), GFP_ATOMIC);
>                 if (aw) {
>                         ...
>                         queue_work(vhost->fpin_workq, &aw->async_work_s);
>                 ...
> }
>
> Should the interrupts be disabled prior to tearing down the workqueue, or
> should we check if fpin_workq is NULL before queuing work?

Yes, fixed in v8.

>> diff --git a/drivers/scsi/ibmvscsi/ibmvfc_kunit.c b/drivers/scsi/ibmvscsi/ibmvfc_kunit.c
>> index 444e6e6e1c390..ce938b93ecb45 100644
>> --- a/drivers/scsi/ibmvscsi/ibmvfc_kunit.c
>> +++ b/drivers/scsi/ibmvscsi/ibmvfc_kunit.c
> [ ... ]
>> @@ -225,9 +226,118 @@ static void ibmvfc_full_fpin_test(struct kunit *test)
>>  			post[IBMVFC_AE_FPIN_CONGESTION_CLEARED]);
>>  }
>>  
>> +#define IBMVFC_TEST_FPIN_EXT(fs, ev, stat, crq) {		\
>> +	crq.valid = 0x80;					\
>> +	crq.flags = IBMVFC_ASYNC_IS_FPIN_EXT;			\
>> +	crq.link_state = IBMVFC_AE_LS_LINK_UP;			\
>> +	crq.fpin_status = (fs);					\
>> +	crq.event = cpu_to_be16(IBMVFC_AE_FPIN);		\
>> +	crq.wwpn = cpu_to_be64(tgt->wwpn);			\
>> +	crq.fpin_data.flags = IBMVFC_FPIN_EVENT_TYPE_VALID;	\
>> +	crq.fpin_data.event_type = cpu_to_be16((ev));		\
>> +	pre = READ_ONCE(tgt->rport->fpin_stats.stat);		\
>> +	ibmvfc_handle_async((struct ibmvfc_crq *)&crq, vhost, true);	\
>> +	msleep(1U);							\
>> +	post = READ_ONCE(tgt->rport->fpin_stats.stat);		\
>> +}
>
> [Severity: Medium]
> Is it expected that this macro only reads the pre and post statistics without
> asserting any changes? The KUNIT_EXPECT_* macros seem to be missing here
> to validate the update.

Yes, there is no validation. This is merely meant to exercise the
extended FPIN processing paths in the kernel and in multipathd.

> Additionally, could relying on msleep(1U) for synchronization lead to flaky
> test results when running under heavy load?

Fixed to use flush_workqueue().

>> +
>> +/**
>> + * ibmvfc_extended_fpin_test - unit test for extended FPIN events
>> + * @test: pointer to kunit structure
>> + *
>> + * Tests
>> + *
>> + * Return: void
>> + */
>> +static void ibmvfc_extended_fpin_test(struct kunit *test)
>> +{
> [ ... ]
>> +	for (fs = IBMVFC_AE_FPIN_LINK_CONGESTED; fs <= IBMVFC_AE_FPIN_CONGESTION_CLEARED; fs++) {
>> +		switch (fs) {
>> +		case IBMVFC_AE_FPIN_PORT_CLEARED:
>> +		case IBMVFC_AE_FPIN_CONGESTION_CLEARED:
>> +			crq[fs].valid = 0x80;
>> +			crq[fs].flags = IBMVFC_ASYNC_IS_FPIN_EXT;
>> +			crq[fs].link_state = IBMVFC_AE_LS_LINK_UP;
>> +			crq[fs].fpin_status = fs;
>> +			crq[fs].event = cpu_to_be16(IBMVFC_AE_FPIN);
>> +			crq[fs].wwpn = cpu_to_be64(tgt->wwpn);
>> +			crq[fs].fpin_data.flags = IBMVFC_FPIN_EVENT_TYPE_VALID;
>> +			crq[fs].fpin_data.event_type = cpu_to_be16(FPIN_CONGN_CLEAR);
>> +			pre = READ_ONCE(tgt->rport->fpin_stats.cn_clear);
>> +			ibmvfc_handle_async((struct ibmvfc_crq *)&crq[fs], vhost, true);
>> +			msleep(1U);
>> +			post = READ_ONCE(tgt->rport->fpin_stats.cn_clear);
>> +			break;
>
> [Severity: Medium]
> Similar to the macro above, this inline manual test logic is missing
> assertions to verify the stats actually changed. Does it need a KUNIT_EXPECT_*
> call here?

Same answer as above. Exercising the extended FPIN paths.

-Dave

      reply	other threads:[~2026-08-24 15:25 UTC|newest]

Thread overview: 35+ 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 ` Dave Marquardt
2026-08-17 20:27 ` [PATCH v6 1/8] scsi: ibmvfc: add basic FPIN support Dave Marquardt via B4 Relay
2026-08-17 20:27   ` Dave Marquardt
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:27   ` Dave Marquardt
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:27   ` Dave Marquardt
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:27   ` Dave Marquardt
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:27   ` Dave Marquardt
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:27   ` Dave Marquardt
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:28   ` Dave Marquardt
2026-08-17 20:42   ` sashiko-bot
2026-08-21 15:44     ` Dave Marquardt
2026-08-26 21:57       ` Tyrel Datwyler
2026-08-17 20:28 ` [PATCH v6 8/8] scsi: ibmvfc: handle extended FPIN events Dave Marquardt via B4 Relay
2026-08-17 20:28   ` Dave Marquardt
2026-08-17 20:41   ` sashiko-bot
2026-08-24 15:25     ` Dave Marquardt [this message]

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=87se43mtgj.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.