Linux-ARM-Kernel Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/9] scsi: fix missing locking and dump length checks in several drivers
@ 2026-12-05  6:32 Praneeth Balasubramanian
  2026-12-05  6:32 ` [PATCH 5/9] scsi: arm: Fix eh_abort race against the interrupt handler Praneeth Balasubramanian
  0 siblings, 1 reply; 3+ messages in thread
From: Praneeth Balasubramanian @ 2026-12-05  6:32 UTC (permalink / raw)
  To: Nilesh Javali, Manish Rangankar, GR-ETH-Storage-Upstream,
	James E.J. Bottomley, Martin K. Petersen, Sathya Prakash,
	Sreekanth Reddy, Suganath Prabu Subramani, Ranjan Kumar,
	Brian King, Russell King, Satish Kharat, Sesidhar Baddela,
	Karan Tilak Kumar, GR-QLogic-Storage-Upstream
  Cc: Praneeth Balasubramanian, linux-scsi, linux-kernel,
	MPT-FusionLinux.pdl, linux-arm-kernel, target-devel

These 9 patches fix bugs that an LLM-based audit found. The audit checks
code against the rules stated in kernel comments, such as "the caller
must hold this lock" or "drop the reference when done". Each changelog
explains the rule and the path that breaks it.

The patches are independent of each other, and each one can be applied
on its own. They are against next-20261204 and also apply to mainline
(007722b8211f), except patch 3, which needs linux-next.

None of them was runtime-tested. There is no reproducer, and I do not
have the hardware. Each one builds without new warnings with W=1, and
checkpatch.pl is clean. Details are below the --- of each patch.

Tools: GLM-5.3 drafted the fixes and changelogs. Claude Opus 5.5 checked
each one against the source and rewrote parts where needed. I reviewed
every patch.

Praneeth Balasubramanian (9):
  scsi: bnx2i: Hold the session back_lock around iscsi_itt_to_task()
  scsi: mpt3sas: do not keep an enclosure pointer across a host reset
  scsi: pmcraid: Take host_lock around scsi_report_bus_reset()
  scsi: ipr: Skip dump entries whose length is not a 4 byte multiple
  scsi: arm: Fix eh_abort race against the interrupt handler
  scsi: csiostor: hold hw lock when issuing port stats mailbox command
  scsi: fnic: Hold fnic_lock for the oxid calls in the FIP timer work
  scsi: qla2xxx: Hold qp_lock when completing command in abort timeout
  scsi: target: core: Fix PRgeneration race in REGISTER AND MOVE

 drivers/scsi/arm/fas216.c            | 11 ++++++--
 drivers/scsi/bnx2i/bnx2i_hwi.c       | 11 ++++----
 drivers/scsi/csiostor/csio_lnode.c   |  3 +++
 drivers/scsi/fnic/fip.c              |  7 +++++
 drivers/scsi/ipr.c                   |  3 ++-
 drivers/scsi/mpt3sas/mpt3sas_scsih.c | 38 +++++++++++++++++-----------
 drivers/scsi/pmcraid.c               | 13 +++++++++-
 drivers/scsi/qla2xxx/qla_init.c      |  6 +++--
 drivers/target/target_core_pr.c      |  9 +------
 9 files changed, 66 insertions(+), 35 deletions(-)


base-commit: 29beb21c21ada7207692b2d69fc58dcd15dab6e9
-- 
2.25.1



^ permalink raw reply	[flat|nested] 3+ messages in thread

* [PATCH 5/9] scsi: arm: Fix eh_abort race against the interrupt handler
  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 ` Praneeth Balasubramanian
       [not found]   ` <sashiko-outbox-251150@kernel.org>
  0 siblings, 1 reply; 3+ messages in thread
From: Praneeth Balasubramanian @ 2026-12-05  6:32 UTC (permalink / raw)
  To: Russell King, James E.J. Bottomley, Martin K. Petersen
  Cc: Praneeth Balasubramanian, stable, linux-arm-kernel, linux-scsi,
	linux-kernel

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



^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH 5/9] scsi: arm: Fix eh_abort race against the interrupt handler
       [not found]   ` <sashiko-outbox-251150@kernel.org>
@ 2026-12-05  8:20     ` Praneeth Balasubramanian
  0 siblings, 0 replies; 3+ messages in thread
From: Praneeth Balasubramanian @ 2026-12-05  8:20 UTC (permalink / raw)
  To: sashiko-reviews
  Cc: Russell King, James E.J. Bottomley, Martin K. Petersen,
	linux-arm-kernel, linux-scsi, linux-kernel

On Sat, 05 Dec 2026 06:50:47 +0000, sashiko-bot@kernel.org wrote:
> [Severity: Low]
> Should the Fixes tag reference 8fa728a26886 ("[SCSI] allow sleeping in
> ->eh_abort_handler()") instead of 1da177e4c3f4 ("Linux-2.6.12-rc2")?

Yes. Before that commit the midlayer called eh_abort_handler with
host_lock held and irqs off. v2 uses that Fixes tag.

> [Severity: Low]
> Could this comment name info->host_lock explicitly?

Yes. v2 names info->host_lock in the comment and the changelog. It also
says that fas216_eh_device_reset() and fas216_eh_bus_reset() take that
lock, and that fas216_intr() itself takes none, while some of its callees
take it around fas216_kick().

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

It does. On PREEMPT_RT the lock leaves interrupts on, and the handler
runs in a thread. The device and bus reset handlers have the same limit
today. Closing it needs the interrupt path to take info->host_lock, and
its callees already take it around fas216_kick(), so that is a larger
rework. These are single processor RiscPC boards, so I kept v2 to the
non-RT case and said so below the --- of the patch.


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-12-05  8:20 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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 5/9] scsi: arm: Fix eh_abort race against the interrupt handler Praneeth Balasubramanian
     [not found]   ` <sashiko-outbox-251150@kernel.org>
2026-12-05  8:20     ` Praneeth Balasubramanian

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox