[PATCH 5/9] scsi: arm: Fix eh_abort race against the interrupt handler
From: Praneeth Balasubramanian
Date: Sat Dec 05 2026 - 01:33:42 EST
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@xxxxxxxxxxxxxxx
Signed-off-by: Praneeth Balasubramanian <praneethb2002@xxxxxxxxx>
---
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