All of lore.kernel.org
 help / color / mirror / Atom feed
From: Dave Marquardt <davemarq@linux.ibm.com>
To: sashiko-bot@kernel.org
Cc: sashiko-reviews@lists.linux.dev, linux-scsi@vger.kernel.org
Subject: Re: [PATCH v13 08/11] scsi: ibmvfc: add interrupt routine for asynchronous sub CRQ
Date: Mon, 12 Oct 2026 14:44:56 -0500	[thread overview]
Message-ID: <87mrsivh3b.fsf@linux.ibm.com> (raw)
In-Reply-To: <sashiko-outbox-163322@kernel.org> (sashiko-bot@kernel.org's message of "Wed, 07 Oct 2026 19:44:57 +0000")

sashiko-bot@kernel.org writes:

> Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
> - [High] scsi/ibmvfc: missing load-store memory barrier allows DMA ring data corruption
> --
>
> commit 69de3faf2b9168cb1feb3f85a48430596c1d9283
> Author: Dave Marquardt <davemarq@linux.ibm.com>
>
> scsi: ibmvfc: add interrupt routine for asynchronous sub CRQ
>
> This commit introduces an interrupt handler and a drain routine for
> asynchronous sub-CRQ events. It adds direct traversal of the async
> sub-CRQ ring and processes available entries while managing the queue lock
> and hardware interrupts.
>
>> diff --git a/drivers/scsi/ibmvscsi/ibmvfc-core.c b/drivers/scsi/ibmvscsi/ibmvfc-core.c
>> index 6db9df91e9e68..32bc00a4be7ec 100644
>> --- a/drivers/scsi/ibmvscsi/ibmvfc-core.c
>> +++ b/drivers/scsi/ibmvscsi/ibmvfc-core.c
>
> [ ... ]
>
>> +static void ibmvfc_drain_async_subq(struct ibmvfc_queue *scrq)
>> +{
>> +	struct ibmvfc_host *vhost = scrq->vhost;
>> +	struct ibmvfc_async_crq_event ae = {
>> +		.type = IBMVFC_ASYNC_CRQ_SUB,
>> +	};
>> +	struct ibmvfc_async_sub_crq *crq;
>> +	unsigned long flags;
>> +	int done = 0;
>> +
>> +	spin_lock_irqsave(&vhost->host->host_lock, flags);
>> +	spin_lock(scrq->q_lock);
>> +	while (!done) {
>> +		while ((crq = ibmvfc_next_async_scrq(scrq)) != NULL) {
>> +			ae.subq = *crq;
>> +			ibmvfc_handle_async(&ae, scrq->vhost);
>> +			crq->valid = 0;
>
> [Severity: High]
> Could the store to crq->valid be reordered before the reads from the payload
> complete?
>
> On weakly-ordered architectures like PowerPC, a load from memory can be
> delayed and executed after a subsequent store unless separated by a memory
> barrier.
>
> While ibmvfc_handle_async() takes spinlocks in some paths, it does not
> execute any spinlock or hardware barrier before returning in others
> (such as IBMVFC_AE_LINK_UP or IBMVFC_AE_SCN_FABRIC).
>
> If the hardware observes valid == 0 early, it might overwrite the new event
> while the CPU is still reading it, causing the CPU to ingest corrupted data.
> Does this require an smp_mb() or smp_store_release() before clearing the
> valid bit?

Note that the IRQ is disabled in ibmvfc_interrupt_async_subq() before
calling ibmvfc_drain_async_subq():

	ibmvfc_toggle_scrq_irq(scrq, 0);
	ibmvfc_drain_async_subq(scrq);

So I'm unclear how the hardware would be writing to *crq. Certainly not
through an interrupt.

I don't think this is a valid concern.

>> +			wmb();	/* complete write */
>> +		}
>> +
>> +		ibmvfc_toggle_scrq_irq(scrq, 1);
>> +		crq = ibmvfc_next_async_scrq(scrq);
>> +		if (crq != NULL) {
>> +			ae.subq = *crq;
>> +			ibmvfc_toggle_scrq_irq(scrq, 0);
>> +			ibmvfc_handle_async(&ae, scrq->vhost);
>> +			crq->valid = 0;
>
> [Severity: High]
> Does this race-closure check also suffer from the same missing load-store
> barrier before clearing the valid bit?

Same issue here: interrupts are disabled.

>> +			wmb();	/* complete write */
>> +		} else
>> +			done = 1;
>> +	}
>> +	spin_unlock(scrq->q_lock);
>> +	spin_unlock_irqrestore(&vhost->host->host_lock, flags);
>> +}

  reply	other threads:[~2026-10-12 19:45 UTC|newest]

Thread overview: 41+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-07 19:25 [PATCH v13 00/11] scsi: ibmvfc: make ibmvfc support FPIN messages Dave Marquardt via B4 Relay
2026-10-07 19:25 ` Dave Marquardt
2026-10-07 19:25 ` [PATCH v13 01/11] scsi: ibmvfc: fix IRQ leak and guard deregister on channel reg failure Dave Marquardt via B4 Relay
2026-10-07 19:25   ` Dave Marquardt
2026-10-07 19:25 ` [PATCH v13 02/11] scsi: ibmvfc: fix potential clobbering of rc after failed irq setup Dave Marquardt via B4 Relay
2026-10-07 19:25   ` Dave Marquardt
2026-10-07 19:25 ` [PATCH v13 03/11] scsi: ibmvfc: fix potential NULL pointer dereference on failed queue allocation Dave Marquardt via B4 Relay
2026-10-07 19:25   ` Dave Marquardt
2026-10-07 19:44   ` sashiko-bot
2026-10-09 18:34     ` Dave Marquardt
2026-10-07 19:25 ` [PATCH v13 04/11] scsi: ibmvfc: add basic FPIN support Dave Marquardt via B4 Relay
2026-10-07 19:25   ` Dave Marquardt
2026-10-07 19:41   ` sashiko-bot
2026-10-08 21:24     ` Dave Marquardt
2026-10-09  5:20   ` kernel test robot
2026-10-09 14:45     ` Dave Marquardt
2026-10-07 19:25 ` [PATCH v13 05/11] scsi: ibmvfc: add NOOP command support Dave Marquardt via B4 Relay
2026-10-07 19:25   ` Dave Marquardt
2026-10-07 19:36   ` sashiko-bot
2026-10-12 19:24     ` Dave Marquardt
2026-10-07 19:25 ` [PATCH v13 06/11] scsi: ibmvfc: add FPIN extended flag and async sub-CRQ queue handle Dave Marquardt via B4 Relay
2026-10-07 19:25   ` Dave Marquardt
2026-10-07 19:25 ` [PATCH v13 07/11] scsi: ibmvfc: extend async event handlers for async sub-CRQ events Dave Marquardt via B4 Relay
2026-10-07 19:25   ` Dave Marquardt
2026-10-09 13:22   ` kernel test robot
2026-10-09 14:50     ` Dave Marquardt
2026-10-07 19:25 ` [PATCH v13 08/11] scsi: ibmvfc: add interrupt routine for asynchronous sub CRQ Dave Marquardt via B4 Relay
2026-10-07 19:25   ` Dave Marquardt
2026-10-07 19:44   ` sashiko-bot
2026-10-12 19:44     ` Dave Marquardt [this message]
2026-10-07 19:25 ` [PATCH v13 09/11] scsi: ibmvfc: extend channel reg/dereg helpers for async sub-CRQ Dave Marquardt via B4 Relay
2026-10-07 19:25   ` Dave Marquardt
2026-10-07 19:25 ` [PATCH v13 10/11] scsi: ibmvfc: register and use asynchronous sub CRQ for events Dave Marquardt via B4 Relay
2026-10-07 19:25   ` Dave Marquardt
2026-10-07 19:42   ` sashiko-bot
2026-10-07 19:25 ` [PATCH v13 11/11] scsi: ibmvfc: handle extended FPIN events Dave Marquardt via B4 Relay
2026-10-07 19:25   ` Dave Marquardt
2026-10-07 19:33   ` sashiko-bot
2026-10-07 19:52     ` Dave Marquardt
2026-10-09 20:29   ` kernel test robot
2026-10-12 19:50     ` 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=87mrsivh3b.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 \
    /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.