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

From: Yehyeong Lee

Date: Wed Nov 18 2026 - 06:39:33 EST


v1 was two isert patches with no cover letter:
https://lore.kernel.org/all/20261116101108.1650132-1-yhlee@xxxxxxxxxxxxxxxxxx/

Answering the review of v1 1/2 needs two patches in the target core, so v2
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 into a double free. No intermediate commit has a double free
or a use-after-free; the NULL dereference is in the base tree, and 3/4
removes it.

1/4 is not about iSER. iscsit_find_cmd_from_ttt() matches a command by
targ_xfer_tag alone, 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 two such NOP-Outs free it twice. That is reachable on plain
iscsi_tcp one PDU after login. It also gives the lookup's other caller,
iscsit_handle_data_ack(), the kind of command it actually wants.

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 on a LIO target with KASAN, one fresh boot per cell, arms
alternating; 2 boots per intermediate stage and 5 for the finished series,
on an iSER portal over soft-RoCE:

base 1/4 1-2/4 1-3/4 1-4/4
Reject + NOP-Out with a
reserved ITT and TTT 0 Oops Oops Oops clean clean
the same two PDUs paced Oops Oops Oops clean clean
nopin_timeout 0 then 3 on a
logged-in iSER session Oops Oops clean clean clean
200 Data-Outs with a
nonexistent ITT 128 128 128 128 200
one Data-Out over Target-
RecvDataSegmentLength - - - - clean
login, WRITE, READ verify,
unsolicited Data-Out, logout - - - - 10/10

Every cell of the finished series is KASAN-clean: 0 reports in 30 cells.
On plain iscsi_tcp, 20 Data-Out/NOP-Out(TTT 0) pairs in one write give 19
or 20 KASAN reports per cell on base, 5 cells out of 5, and 0 with 1/4.

Regression on iscsi_tcp, base against the finished series: the nopin timer
still fires and its answer is still matched, 5 cells each, and login, READ,
WRITE, readback, logout and a CHAP login all pass with no splat.

Still open: iscsit_handle_data_ack() is the one caller whose wanted kind I
could not exercise, so that hunk of 1/4 rests on the code alone.

Yehyeong Lee (4):
scsi: target: iscsi: match a NOP-In by opcode as well as by tag
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 | 3 +-
drivers/target/iscsi/iscsi_target_erl1.c | 2 +-
drivers/target/iscsi/iscsi_target_login.c | 5 ---
drivers/target/iscsi/iscsi_target_util.c | 16 +++++++--
drivers/target/iscsi/iscsi_target_util.h | 4 ++-
6 files changed, 51 insertions(+), 20 deletions(-)

--
2.43.0