[PATCH v3 0/4] isert: the commands the target core allocates itself

From: Yehyeong Lee

Date: Wed Nov 18 2026 - 16:15:21 EST


Link: https://lore.kernel.org/all/20261118113905.2361969-1-yhlee@xxxxxxxxxxxxxxxxxx/ (v2)
Link: https://lore.kernel.org/all/20261116101108.1650132-1-yhlee@xxxxxxxxxxxxxxxxxx/ (v1)

Changes since v2: 1/4 is replaced. Comparing the opcode inside
iscsit_find_cmd_from_ttt() stopped a Reject being taken for a NOP-In, but
not two NOP-Outs being given the same real NOP-In, which queues it for
removal twice. 1/4 now gives the NOP-Out path its own lookup that takes
the command under conn->cmd_lock and clears its tag, so only the first
answer gets it, and it leaves iscsit_find_cmd_from_ttt() and its Data ACK
SNACK caller alone. 2/4 to 4/4 are unchanged.

Answering the review of v1 1/2 needs two patches in the target core, so v3
has four. 1/4 and 2/4 are drivers/target/iscsi and 3/4 and 4/4 are
drivers/infiniband/ulp/isert, but 3/4 depends on 1/4: it lets a Reject the
core allocated reach the wire, and without 1/4 first that turns a NULL
dereference in the base tree into a double free.

1/4 is not about iSER. iscsit_find_cmd_from_ttt() matches a command by
targ_xfer_tag alone and leaves it on conn_cmd_list, so a NOP-Out with a
reserved ITT and TTT 0 is given the Reject the core allocated, which
carries TTT 0 and is still waiting to be sent, and a second NOP-Out with
the same TTT is given it again - either shape ends in a double release.
Both are reachable on plain iscsi_tcp one PDU after login.

2/4 keeps the unsolicited NOP-In off iSER. The transport check in
iscsi_post_login_start_timers() runs once, at login, and
iscsit_process_nop_out() and iscsit_na_nopin_timeout() arm the nopin timer
again on a connection that is already logged in, so it moves into
__iscsit_start_nopin_timer(), which all three go through. Gating it is the
fix rather than only the dereference because isert releases a command on
its Send completion, so the answer to a NOP-In cannot be matched to it.

3/4 is v1's 1/2 with the fix generalised. struct isert_cmd is all zero for
a command the core allocated, so the back pointers are filled in where the
core hands one over, in isert_immediate_queue() and isert_response_queue(),
which also covers the ISTATE_REMOVE the review pointed at.

4/4 is v1's 2/2, unchanged.

Measured with KASAN, one fresh boot per cell, arms alternating. On an
iSER portal over soft-RoCE, 3 boots per cell on the finished series and 2
on the intermediate stages:

base 1/4 1-2/4 1-4/4
Reject + NOP-Out, TTT 0 Oops Oops Oops clean
the same two PDUs paced Oops Oops Oops clean
nopin_timeout 0 then 3 Oops - - clean
200 Data-Outs, nonexistent ITT 128 - - 200
one Data-Out over TRDSL Oops - - clean
login/WRITE/READ/logout - - - 10/10

No cell at any stage produced a double free, and the finished series is
KASAN-clean. Where a cell oopsed, the use-after-free reports that follow
come from the teardown of the killed thread and are the same set at base.

On plain iscsi_tcp: two NOP-Outs answering one real NOP-In are both taken
on base and the second is refused with 1/4, 5 cells each; 20 Data-Out and
NOP-Out(TTT 0) pairs in one write give 19 or 20 KASAN reports per cell on
base and 0 with 1/4, and one legitimate answer still works on both; 3
cells each.

Yehyeong Lee (4):
scsi: target: iscsi: retire an unsolicited NOP-In only once
scsi: target: iscsi: do not arm the nopin timer on an iSER connection
IB/isert: finish a Reject the target core allocated itself
IB/isert: do not leak the receive descriptor of a dropped Data-Out

drivers/infiniband/ulp/isert/ib_isert.c | 41 +++++++++++++++++------
drivers/target/iscsi/iscsi_target.c | 34 +++++++++++++++++--
drivers/target/iscsi/iscsi_target_login.c | 5 ---
drivers/target/iscsi/iscsi_target_util.c | 10 ++++++
4 files changed, 72 insertions(+), 18 deletions(-)

--
2.43.0