Linux SCSI subsystem development
 help / color / mirror / Atom feed
* [PATCH RFC] scsi: aacraid: free aborted management FIBs on late completion
@ 2026-11-24 11:04 Benjamin Saiz
  2026-11-24 11:18 ` sashiko-bot
  0 siblings, 1 reply; 3+ messages in thread
From: Benjamin Saiz @ 2026-11-24 11:04 UTC (permalink / raw)
  To: linux-scsi; +Cc: mkp, James.Bottomley, aacraid

When a signal interrupts a process waiting in aac_fib_send() for a
management command (for example FSACTL_SEND_FIB from arcconf, maxView
or smartctl), aac_fib_send() marks the FIB as abandoned (done = 2) and
returns -ERESTARTSYS. The ioctl handlers then deliberately keep the
FIB, because the controller still owns it: ioctl_send_fib() only calls
aac_fib_free() when retval != -ERESTARTSYS, and aac_send_raw_srb()
does the same. The interrupt handler is expected to release the FIB
when the late response arrives.

aac_intr_normal() handles that late response but only calls
aac_fib_complete(); it never calls aac_fib_free(). The FIB is
therefore never returned to the free list. Since commit 6bf3b630d0a7
("aacraid: SCSI blk tag support"), the free list only holds the
AAC_NUM_MGT_FIB (8) management FIBs, so eight interrupted management
commands exhaust it: aac_fib_alloc() returns NULL and every later
management ioctl fails with -ENOMEM until the adapter is reset or the
host is rebooted. management_fib_count is decremented normally, so the
"No management Fibs Available" check never fires and nothing is
logged.

The exhausted pool also prevents aac_send_shutdown() from allocating a
FIB, so VM_CloseAll is silently not sent at shutdown.

Observed on an Adaptec 6805 (Linux 5.10) with kprobes on aac_fib_send(),
aac_fib_complete() and aac_fib_free(). Before the test, 1000 management
commands all used the same FIB. arcconf was then killed (SIGKILL) while
waiting for a ContainerCommand:

  54803.925692 arcconf-1091331, CPU 11: aac_fib_send() returns -512
  54803.927570 <idle>-0, CPU 12, hardirq:
               aac_fib_complete(fib=0xffff96570a8e7b00)

The late response arrived 1.9 ms later in hard interrupt context and
completed the FIB, but aac_fib_free() was never called for it. The next
812 management commands all used another FIB; 0xffff96570a8e7b00 was
never allocated again.

Commit cacb6dc3d7fe ("[SCSI] aacraid: fix File System going into
read-only mode") introduced the done = 2 handshake and freed the FIB
in both aac_response_normal() and aac_intr_normal(). Commit
6bf3b630d0a7 removed the aac_fib_free() calls from aac_intr_normal(),
as I/O FIBs became indexed by block layer tags and must not be put on
the management free list. The abandoned-FIB path, however, only ever
sees management FIBs: every synchronous sender (wait != 0, no
callback) gets its FIB from aac_fib_alloc(). Commit 423400e64d37
("scsi: aacraid: Include HBA direct interface") restored
aac_fib_free() for the callback-less async case but not for this one.
aac_response_normal() still frees the FIB.

Free the FIB after completing it in both the native HBA and the
regular branch. done is set to 1 before the call, so the early return
in aac_fib_free() for done == 2 does not apply.

The issue was found, and this patch and its changelog were drafted,
with the help of an AI coding assistant (Claude). I reviewed the
analysis and the change and take responsibility for them.

Fixes: 6bf3b630d0a7 ("aacraid: SCSI blk tag support")
Cc: stable@vger.kernel.org
Signed-off-by: Benjamin Saiz <benj.saiz@gmail.com>
---
RFC because the fix itself is only build-tested (x86_64, v7.0 headers,
W=1, no new warnings). The leak was reproduced on the affected host as
described above, but that host is a production NAS (Adaptec 6805,
Debian 11, Linux 5.10) and the patched module was not loaded there.

Every synchronous sender (wait != 0, no callback) in aachba.c,
commctrl.c, commsup.c and comminit.c gets its FIB from aac_fib_alloc(),
so the done == 2 path cannot return a block layer tagged FIB to the
management free list.

For reference, Microchip's out-of-tree driver 1.2.1-60001 frees the FIB
at the same place (both done == 2 branches of aac_intr_normal()); its
aac_fib_free() only returns pool FIBs to the free list.

Not addressed here: on -ERESTARTSYS, aac_send_raw_srb() also strands its
SG buffers and DMA mappings (bugzilla 220504).

 drivers/scsi/aacraid/dpcsup.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/drivers/scsi/aacraid/dpcsup.c b/drivers/scsi/aacraid/dpcsup.c
index 169c41d..a965f18 100644
--- a/drivers/scsi/aacraid/dpcsup.c
+++ b/drivers/scsi/aacraid/dpcsup.c
@@ -379,8 +379,10 @@ unsigned int aac_intr_normal(struct aac_dev *dev, u32 index, int isAif,
 					mflags);
 
 				FIB_COUNTER_INCREMENT(aac_config.NativeRecved);
-				if (completed)
+				if (completed) {
 					aac_fib_complete(fib);
+					aac_fib_free(fib);
+				}
 			}
 		} else {
 			struct hw_fib *hwfib = fib->hw_fib_va;
@@ -432,8 +434,10 @@ unsigned int aac_intr_normal(struct aac_dev *dev, u32 index, int isAif,
 					mflags);
 
 				FIB_COUNTER_INCREMENT(aac_config.NormalRecved);
-				if (completed)
+				if (completed) {
 					aac_fib_complete(fib);
+					aac_fib_free(fib);
+				}
 			}
 		}
 
-- 
2.43.0


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

end of thread, other threads:[~2026-11-24 12:48 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-24 11:04 [PATCH RFC] scsi: aacraid: free aborted management FIBs on late completion Benjamin Saiz
2026-11-24 11:18 ` sashiko-bot
2026-11-24 12:47   ` Benjamin Saiz

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