* [PATCH] scsi: snic: Disable the devcmd2 WQ before freeing its results ring
@ 2026-11-24 18:02 Yuho Choi
2026-11-24 18:11 ` sashiko-bot
0 siblings, 1 reply; 2+ messages in thread
From: Yuho Choi @ 2026-11-24 18:02 UTC (permalink / raw)
To: Karan Tilak Kumar, Sesidhar Baddela, Narsimhulu Musini
Cc: James E.J. Bottomley, Martin K. Petersen, linux-scsi,
linux-kernel, Yuho Choi
vnic_dev_deinit_devcmd2() frees the devcmd2 results ring before it
disables the devcmd2 WQ. The adapter writes the result of each devcmd2
command into that ring. When a command times out in _svnic_dev_cmd2(),
its descriptor stays posted on the WQ, and snic_remove() ignores the
error from svnic_dev_close(), so the adapter can still complete the
command and write its result after the ring has been freed.
Disable the WQ first, so that the adapter has acknowledged stopping the
queue before the results ring is freed.
Fixes: c8806b6c9e82 ("snic: driver for Cisco SCSI HBA")
Signed-off-by: Yuho Choi <oss.patchbox@gmail.com>
---
Compile-tested only (x86_64, SCSI_SNIC=m, W=1). I have no Cisco VIC
adapter, and the late write would come from the adapter, so I could not
reproduce it.
drivers/scsi/snic/vnic_dev.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/scsi/snic/vnic_dev.c b/drivers/scsi/snic/vnic_dev.c
index 22303f827583..44a2cc59821c 100644
--- a/drivers/scsi/snic/vnic_dev.c
+++ b/drivers/scsi/snic/vnic_dev.c
@@ -421,8 +421,8 @@ static void vnic_dev_deinit_devcmd2(struct vnic_dev *vdev)
vdev->devcmd2 = NULL;
vdev->devcmd_rtn = NULL;
- svnic_dev_free_desc_ring(vdev, &dc2c->results_ring);
svnic_wq_disable(&dc2c->wq);
+ svnic_dev_free_desc_ring(vdev, &dc2c->results_ring);
svnic_wq_free(&dc2c->wq);
kfree(dc2c);
}
base-commit: 8dac6df92a2e66e2098bbc69061964cfe7e8375b
--
2.56.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] scsi: snic: Disable the devcmd2 WQ before freeing its results ring
2026-11-24 18:02 [PATCH] scsi: snic: Disable the devcmd2 WQ before freeing its results ring Yuho Choi
@ 2026-11-24 18:11 ` sashiko-bot
0 siblings, 0 replies; 2+ messages in thread
From: sashiko-bot @ 2026-11-24 18:11 UTC (permalink / raw)
To: Yuho Choi; +Cc: linux-scsi
Thank you for your contribution! Sashiko AI review found no new issues
in this patch, but noticed 1 related pre-existing issue it does not
introduce:
- [Critical] enic: DMA use-after-free in vnic_dev_deinit_devcmd2() [1]
--
commit 69fa45723f24d1ae5b1a578c30346f49638a7cfb
Author: Yuho Choi <oss.patchbox@gmail.com>
scsi: snic: Disable the devcmd2 WQ before freeing its results ring
This commit reorders vnic_dev_deinit_devcmd2() to disable the devcmd2 work
queue before freeing the devcmd2 results descriptor ring.
> diff --git a/drivers/scsi/snic/vnic_dev.c b/drivers/scsi/snic/vnic_dev.c
> index 22303f8275836..44a2cc59821c8 100644
> --- a/drivers/scsi/snic/vnic_dev.c
> +++ b/drivers/scsi/snic/vnic_dev.c
> @@ -421,8 +421,8 @@ static void vnic_dev_deinit_devcmd2(struct vnic_dev *vdev)
> vdev->devcmd2 = NULL;
> vdev->devcmd_rtn = NULL;
>
> - svnic_dev_free_desc_ring(vdev, &dc2c->results_ring);
> svnic_wq_disable(&dc2c->wq);
> + svnic_dev_free_desc_ring(vdev, &dc2c->results_ring);
> svnic_wq_free(&dc2c->wq);
> kfree(dc2c);
> }
[Severity: Critical]
This problem wasn't introduced by this patch, but can the adapter still
perform DMA to freed memory [1] when svnic_wq_disable() times out, or
along the svnic_dev_init_devcmd2() error path and the matching devcmd2
teardown code in enic and fnic?
svnic_wq_disable() returns -ETIMEDOUT if the hardware does not acknowledge
stopping the queue, yet vnic_dev_deinit_devcmd2() ignores its return value
and unconditionally frees both dc2c->results_ring and dc2c->wq.ring while
the queue remains active.
In the same file, svnic_dev_init_devcmd2() also frees dc2c->results_ring
before calling svnic_wq_disable():
drivers/scsi/snic/vnic_dev.c:svnic_dev_init_devcmd2() {
...
err_free_desc_ring:
svnic_dev_free_desc_ring(vdev, &dc2c->results_ring);
err_free_wq:
svnic_wq_disable(&dc2c->wq);
svnic_wq_free(&dc2c->wq);
...
}
The identical devcmd2 init and deinit paths in
drivers/net/ethernet/cisco/enic/vnic_dev.c and
drivers/scsi/fnic/vnic_dev.c likewise free results_ring before calling
vnic_wq_disable() and ignore the disable return value before freeing the WQ
descriptor ring.
[1] https://sashiko.dev/#/bug/linux-20f156a6-d2c2-49bc-b1ee-432c3af0d669
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261124180234.400564-2-oss.patchbox@gmail.com?part=1
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-11-24 18:11 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-24 18:02 [PATCH] scsi: snic: Disable the devcmd2 WQ before freeing its results ring Yuho Choi
2026-11-24 18:11 ` sashiko-bot
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox