[PATCH v4 0/4] scsi: libiscsi: tighten task completion
From: Yehyeong Lee
Date: Tue Nov 17 2026 - 05:16:06 EST
1/4 stops the receive path from completing a management task that is still
queued or still being filled in, so a slot cannot be returned to the task
pool while the transmit path still owns it. 2/4 stops it from completing a
NOP-Out sent with RESERVED_ITT, whose single reference belongs to the
transport, so that reference cannot be dropped twice. 3/4 makes the
transmit path hold a reference before it publishes the state the other two
test, and makes the SCSI command lookup honour that state at all. 4/4
stops the receive path copying a Data-In into a command that has been
handed back.
v3 -> v4:
- 1/4 and 2/4 are unchanged.
- 4/4 is new.
- 3/4 drops the two hunks that kept iscsi_xmit_task() from handing a task
to the transport once the receive path had completed it: the early
return in the conn->task branch, and the ISCSI_TASK_RUNNING test around
storing the task in conn->task. Both release the last reference to a
task whose PDU the transport has only half sent, and for iscsi_tcp
tcp_sw_conn->out.segment then still points into the sg list that
scsi_done() has handed back, which the next task's
iscsi_tcp_task_xmit() flushes first. Mainline holds the task until the
transport reports the PDU done, and 3/4 now leaves that alone. The
second hunk also re-added the test that commit 533ac412fdb4 ("scsi:
iscsi: Remove unneeded task state check") removed, so that Fixes tag
goes with it.
- 3/4's SCSI lookup refuses ISCSI_TASK_FREE as well as
ISCSI_TASK_PENDING, because iscsi_alloc_task() stores the state before
->sc and under frwd_lock only, so a slot being handed out can be seen
with its new ->sc and the state it was freed with.
- 3/4's changelog follows.
One older problem is left alone, because it is not a completion condition.
iscsi_xmit_task() still sends one Data-Out for a command the target has
answered, from conn->task and from conn->requeue alike; nothing is freed
there, because the reference is taken before the queue's one is dropped,
and skipping the send is what the two dropped hunks show to be unsafe.
3/4 needs 1/4 underneath, and is marked for stable for the same reason.
4/4 is independent of the first three.
v1 of 1/4:
https://lore.kernel.org/all/20261113145140.282504-1-yhlee@xxxxxxxxxxxxxxxxxx/
v1 of 2/4:
https://lore.kernel.org/all/20261113232322.395246-1-yhlee@xxxxxxxxxxxxxxxxxx/
v2:
https://lore.kernel.org/all/20261113233938.397415-1-yhlee@xxxxxxxxxxxxxxxxxx/
v3:
https://lore.kernel.org/all/20261115122122.1446791-1-yhlee@xxxxxxxxxxxxxxxxxx/
Best regards,
Yehyeong Lee
Yehyeong Lee (4):
scsi: libiscsi: only complete a task that has been sent
scsi: libiscsi: do not complete a task sent with a reserved ITT
scsi: libiscsi: take a transmit reference before a task is published
scsi: libiscsi_tcp: do not accept a Data-In for a finished command
drivers/scsi/libiscsi.c | 56 +++++++++++++++++++++++++++++++------
drivers/scsi/libiscsi_tcp.c | 3 +-
2 files changed, 50 insertions(+), 9 deletions(-)
base-commit: 7e1392a42ea288d70a266f6553fe06f57f8647ea
--
2.43.0