Linux SCSI subsystem development
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Praneeth Balasubramanian" <praneethb2002@gmail.com>
Cc: linux-scsi@vger.kernel.org
Subject: Re: [PATCH 5/9] scsi: arm: Fix eh_abort race against the interrupt handler
Date: Sat, 05 Dec 2026 06:50:47 +0000	[thread overview]
Message-ID: <sashiko-outbox-251150@kernel.org> (raw)
In-Reply-To: <20261205063229.2518424-6-praneethb2002@gmail.com>

Thank you for your contribution! Sashiko AI review found 3 potential
issues to consider:
- [Medium] scsi: arm: fas216_eh_abort() still races with fas216_intr()
  on PREEMPT_RT
- [Low] scsi: arm: commit message and comment misidentify host_lock
  usage
- [Low] scsi: arm: Fixes tag cites 1da177e4c3f4 instead of 8fa728a26886
--

commit 1d23771aaa676d4441b57629afe17d79f3ca6e95
Author: Praneeth Balasubramanian <praneethb2002@gmail.com>

> scsi: arm: Fix eh_abort race against the interrupt handler
>
> fas216_eh_abort() calls fas216_find_command() with no lock held and
> interrupts enabled. fas216_find_command() checks whether the command is
> disconnectable and clears info->SCpnt in separate steps. If the device
> interrupt fires in between, fas216_reselected_intr() restores the
> disconnectable command and puts the bus into PHASE_MSGIN. The abort then
> stores NULL into info->SCpnt while the target is reconnected. The next
> target-driven interrupt ends in fas216_done() with no current command,
> which panics the kernel.
>
> fas216_intr() itself takes no lock. These boards are single processor, so
> taking host_lock with irqs disabled serializes the abort against the
> interrupt handler. This matches what the bus and host reset handlers
> already do.
>
> Hold host_lock with irqs disabled around the fas216_find_command() call.
> It only removes commands from the driver queues, clears a bit and prints,
> so it is safe to call in atomic context. Update the stale comment about
> io_request_lock and disabled irqs as well.
>
> This was found by an LLM-based audit that checks code against the rules
> stated in kernel comments.
>
> Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
> Cc: stable@vger.kernel.org
> Signed-off-by: Praneeth Balasubramanian <praneethb2002@gmail.com>

[Severity: Low]
Should the Fixes tag reference 8fa728a26886 ("[SCSI] allow sleeping in
->eh_abort_handler()") instead of 1da177e4c3f4 ("Linux-2.6.12-rc2")?

In 1da177e4c3f4 ("Linux-2.6.12-rc2"), drivers/scsi/scsi_error.c still held
host->host_lock with interrupts disabled around eh_abort_handler().
Commit 8fa728a26886 ("[SCSI] allow sleeping in ->eh_abort_handler()")
removed that locking without updating fas216_eh_abort().

> diff --git a/drivers/scsi/arm/fas216.c b/drivers/scsi/arm/fas216.c
> index d0752c0bf4254..7626f5102bf45 100644
> --- a/drivers/scsi/arm/fas216.c
> +++ b/drivers/scsi/arm/fas216.c
> @@ -2422,11 +2422,14 @@ static enum res_find fas216_find_command(FAS216_Info *info,
>   *
>   * Abort this command.
>   * Returns: FAILED if unable to abort
> - * Notes: io_request_lock is taken, and irqs are disabled
> + * Notes: the host lock is taken with irqs disabled while looking
> + * for the command
>   */

[Severity: Low]
Could this comment name info->host_lock explicitly?  This driver uses both
info->host_lock and info->host->host_lock, so "the host lock" is ambiguous.

The commit message also says this matches the bus and host reset handlers,
but fas216_eh_host_reset() acquires info->host->host_lock; it is
fas216_eh_device_reset() and fas216_eh_bus_reset() that take
info->host_lock.

In addition, while fas216_intr() itself takes no lock, its callees
fas216_disconnect_intr() and fas216_done() acquire info->host_lock around
fas216_kick().

[ ... ]

> @@ -2438,7 +2441,11 @@ int fas216_eh_abort(struct scsi_cmnd *SCpnt)
>  	print_debug_list();
>  	fas216_dumpstate(info);
>  
> -	switch (fas216_find_command(info, SCpnt)) {
> +	spin_lock_irqsave(&info->host_lock, flags);
> +	res = fas216_find_command(info, SCpnt);
> +	spin_unlock_irqrestore(&info->host_lock, flags);

[Severity: Medium]
Does spin_lock_irqsave(&info->host_lock, flags) still race with
fas216_intr() under CONFIG_PREEMPT_RT?

ARM selects ARCH_SUPPORTS_RT, so CONFIG_PREEMPT_RT can be enabled with
CONFIG_ARCH_RPC.  Because info->host_lock is a spinlock_t,
spin_lock_irqsave() leaves interrupts and preemption enabled on
PREEMPT_RT.

The IRQ-driven front-ends register handlers without IRQF_NO_THREAD, so
they run in SCHED_FIFO forced-threaded IRQ threads that skip
local_irq_disable() on PREEMPT_RT and can preempt fas216_eh_abort():

fas216_eh_abort()
  spin_lock_irqsave(&info->host_lock, flags)
  fas216_find_command()
    info->scsi.disconnectable = 0
  <preempted by forced-threaded IRQ>
    fas216_intr()
      fas216_reselected_intr()
        info->scsi.phase = PHASE_MSGIN
  info->SCpnt = NULL  <-- clears reconnected command
<next target IRQ>
  fas216_intr()
    ... -> fas216_done()  <-- panic: null command

In the polled arxescsi path, fas216_noqueue_command_lck() also invokes
fas216_intr() under info->host->host_lock instead of info->host_lock,
which provides no mutual exclusion against fas216_eh_abort() on PREEMPT_RT.

Converting info->host_lock to raw_spinlock_t would break lock nesting with
queue_remove_cmd()'s queue->queue_lock, so fixing this needs fas216_intr()
serialized under info->host_lock while refactoring the inner
info->host_lock acquisitions in fas216_disconnect_intr() and fas216_done().

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261205063229.2518424-1-praneethb2002@gmail.com?part=5

  reply	other threads:[~2026-12-05  6:50 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-12-05  6:32 [PATCH 0/9] scsi: fix missing locking and dump length checks in several drivers Praneeth Balasubramanian
2026-12-05  6:32 ` [PATCH 1/9] scsi: bnx2i: Hold the session back_lock around iscsi_itt_to_task() Praneeth Balasubramanian
2026-12-05  6:32 ` [PATCH 2/9] scsi: mpt3sas: do not keep an enclosure pointer across a host reset Praneeth Balasubramanian
2026-12-05  6:46   ` sashiko-bot
2026-12-05  6:32 ` [PATCH 3/9] scsi: pmcraid: Take host_lock around scsi_report_bus_reset() Praneeth Balasubramanian
2026-12-05  6:43   ` sashiko-bot
2026-12-05  6:32 ` [PATCH 4/9] scsi: ipr: Skip dump entries whose length is not a 4 byte multiple Praneeth Balasubramanian
2026-12-05  6:32 ` [PATCH 5/9] scsi: arm: Fix eh_abort race against the interrupt handler Praneeth Balasubramanian
2026-12-05  6:50   ` sashiko-bot [this message]
2026-12-05  6:32 ` [PATCH 6/9] scsi: csiostor: hold hw lock when issuing port stats mailbox command Praneeth Balasubramanian
2026-12-05  6:47   ` sashiko-bot
2026-12-05  6:32 ` [PATCH 7/9] scsi: fnic: Hold fnic_lock for the oxid calls in the FIP timer work Praneeth Balasubramanian
2026-12-05  6:32 ` [PATCH 8/9] scsi: qla2xxx: Hold qp_lock when completing command in abort timeout Praneeth Balasubramanian
2026-12-05  6:58   ` sashiko-bot
2026-12-05  6:32 ` [PATCH 9/9] scsi: target: core: Fix PRgeneration race in REGISTER AND MOVE Praneeth Balasubramanian
2026-12-05  6:56   ` 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=sashiko-outbox-251150@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=linux-scsi@vger.kernel.org \
    --cc=praneethb2002@gmail.com \
    --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