All of lore.kernel.org
 help / color / mirror / Atom feed
From: Praneeth Balasubramanian <praneethb2002@gmail.com>
To: Russell King <linux@armlinux.org.uk>,
	"James E.J. Bottomley" <James.Bottomley@HansenPartnership.com>,
	"Martin K. Petersen" <mkp@kernel.org>
Cc: Praneeth Balasubramanian <praneethb2002@gmail.com>,
	stable@vger.kernel.org, linux-arm-kernel@lists.infradead.org,
	linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH 5/9] scsi: arm: Fix eh_abort race against the interrupt handler
Date: Fri,  4 Dec 2026 22:32:25 -0800	[thread overview]
Message-ID: <20261205063229.2518424-6-praneethb2002@gmail.com> (raw)
In-Reply-To: <20261205063229.2518424-1-praneethb2002@gmail.com>

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>
---

Notes:
    This was found by an LLM-based audit, part of research at UCSB SecLab.
    An LLM turned a kernel comment into a rule, and three LLM votes checked
    the code against it. The fix and changelog were drafted with GLM-5.3 and
    checked against the source with Claude Opus 5.5. I reviewed the patch
    and take responsibility for it.
    
    Testing: builds without new warnings with W=1 (x86_64 allmodconfig; arm
    rpc_defconfig, GCC 8.5), clang 23 unless noted. checkpatch.pl is clean.
    Not runtime-tested, and there is no reproducer. I do not have this
    hardware.
    
    These boards are uniprocessor ARM (RiscPC). Compile-tested with
    rpc_defconfig and the Acorn SCSI drivers as modules, using the
    kernel.org GCC 8.5 cross compiler (the platform needs GCC older than
    9.1).

 drivers/scsi/arm/fas216.c | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/drivers/scsi/arm/fas216.c b/drivers/scsi/arm/fas216.c
index d0752c0bf425..7626f5102bf4 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
  */
 int fas216_eh_abort(struct scsi_cmnd *SCpnt)
 {
 	FAS216_Info *info = (FAS216_Info *)SCpnt->device->host->hostdata;
+	unsigned long flags;
+	enum res_find res;
 	int result = FAILED;
 
 	fas216_checkmagic(info);
@@ -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);
+
+	switch (res) {
 	/*
 	 * We found the command, and cleared it out.  Either
 	 * the command is still known to be executing on the
-- 
2.25.1


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

Thread overview: 19+ 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  8:20     ` Praneeth Balasubramanian
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 ` Praneeth Balasubramanian [this message]
2026-12-05  6:50   ` [PATCH 5/9] scsi: arm: Fix eh_abort race against the interrupt handler sashiko-bot
2026-12-05  8:20     ` Praneeth Balasubramanian
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  8:20     ` Praneeth Balasubramanian
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=20261205063229.2518424-6-praneethb2002@gmail.com \
    --to=praneethb2002@gmail.com \
    --cc=James.Bottomley@HansenPartnership.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-scsi@vger.kernel.org \
    --cc=linux@armlinux.org.uk \
    --cc=mkp@kernel.org \
    --cc=stable@vger.kernel.org \
    /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.