[PATCH 1/2] IB/isert: finish a Reject the target core allocated itself
From: Yehyeong Lee
Date: Mon Nov 16 2026 - 05:11:59 EST
iscsit_add_reject() builds the Reject from a command of its own, with
iscsit_allocate_cmd(), and iscsit_allocate_cmd() zeroes sizeof(struct
iscsit_cmd) plus the transport's priv_size. For iSER that zeroes struct
isert_cmd too, so conn, iscsit_cmd and rx_desc are all NULL where
isert_allocate_cmd() would have filled them in. The target's tx thread
then takes that command through isert_response_queue() ->
isert_put_reject() -> isert_post_response(), which hands the NULL
descriptor to isert_post_recv() and dereferences it.
One PDU after login is enough. iscsit_check_dataout_hdr() answers a
Data-Out whose DataSegmentLength exceeds
conn_ops->MaxXmitDataSegmentLength with iscsit_add_reject(), and it does
so before it looks the ITT up, so there is no SCSI command involved.
Against a LIO target with an iSER portal over soft-RoCE, with
TargetRecvDataSegmentLength negotiated down to 512 and one Data-Out
declaring and carrying 1024 bytes, 5 boots out of 5:
[ 3.750347] Oops: general protection fault, probably for non-canonical address 0xdffffc0000000484: 0000 [#1] SMP KASAN NOPTI
[ 3.752656] KASAN: probably user-memory-access in range [0x0000000000002420-0x0000000000002427]
[ 3.753703] CPU: 0 UID: 0 PID: 168 Comm: iscsi_ttx Not tainted 7.4.0-rc2-RJ6A-00716-g23c62304dde2 #1 PREEMPT(lazy)
[ 3.755172] Hardware name: QEMU Ubuntu 24.04 PC v2 (i440FX + PIIX, arch_caps fix, 1996), BIOS 1.16.3-debian-1.16.3-2 04/01/2014
[ 3.756829] RIP: 0010:isert_post_recv+0x98/0x210
[ 3.757519] Code: 89 f8 48 c7 44 24 48 00 00 00 00 48 c7 44 24 50 00 00 00 00 48 c1 e8 03 48 c7 44 24 58 00 00 00 00 48 c7 44 24 60 00 00 00 00 <0f> b6 04 10 84 c0 74 06 0f 8e 2c 01 00 00 31 ed 80 be 20 24 00 00
[ 3.759855] RSP: 0018:ffff888104ecfc10 EFLAGS: 00010206
[ 3.760580] RAX: 0000000000000484 RBX: 1ffff110209d9f83 RCX: 0000000000000001
[ 3.761476] RDX: dffffc0000000000 RSI: 0000000000000000 RDI: 0000000000002420
[ 3.762376] RBP: ffff888109625380 R08: 000000000000029d R09: 0000000000000001
[ 3.763288] R10: ffff888104d95447 R11: 00000000eb6dcbe3 R12: ffff888104af8000
[ 3.764184] R13: ffff888104af8000 R14: ffff888104b4f000 R15: ffff888109624f00
[ 3.765076] FS: 0000000000000000(0000) GS:ffff88816b45d000(0000) knlGS:0000000000000000
[ 3.766100] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
[ 3.766830] CR2: 00007f5dc1281000 CR3: 0000000104baf004 CR4: 0000000000770ef0
[ 3.767739] PKRU: 55555554
[ 3.768091] Call Trace:
[ 3.768407] <TASK>
[ 3.768679] ? __pfx_isert_post_recv+0x10/0x10
[ 3.769233] isert_post_response+0x85/0x1b0
[ 3.769745] ? __pfx_isert_post_response+0x10/0x10
[ 3.770338] ? isert_response_queue+0x91d/0x19a0
[ 3.770898] iscsi_target_tx_thread+0x3de/0x6f0
[ 3.771460] ? __pfx_iscsi_target_tx_thread+0x10/0x10
[ 3.772062] ? _raw_spin_lock_irq+0x10/0xe0
[ 3.772546] ? __pfx_autoremove_wake_function+0x10/0x10
[ 3.773148] ? __pfx_kthread_affine_node+0x10/0x10
[ 3.773714] ? __kthread_parkme+0x88/0x170
[ 3.774196] ? __pfx_iscsi_target_tx_thread+0x10/0x10
[ 3.774775] ? __pfx_iscsi_target_tx_thread+0x10/0x10
[ 3.775352] kthread+0x2c8/0x3b0
[ 3.775733] ? recalc_sigpending+0x15c/0x1e0
[ 3.776236] ? __pfx_kthread+0x10/0x10
[ 3.776671] ret_from_fork+0x36e/0x5a0
[ 3.777109] ? __pfx_ret_from_fork+0x10/0x10
[ 3.777604] ? __switch_to+0x572/0xdc0
[ 3.778041] ? __pfx_kthread+0x10/0x10
[ 3.778482] ret_from_fork_asm+0x1a/0x30
[ 3.778937] </TASK>
[ 3.779201] Modules linked in:
[ 3.779592] ---[ end trace 0000000000000000 ]---
The tx thread dies there, and the teardown that follows walks into the
connection it was using: a KASAN slab-use-after-free in do_send_sig_info()
from iscsit_cause_connection_reinstatement(), a refcount warning in
iscsit_close_connection() and a second Oops in kthread_stop().
So let isert_post_recv() accept a command that has no descriptor, beside
the already-reposted case it tolerates today, and fill in the two
back-pointers the completion path needs, which isert_put_cmd() is
already written for - its ISCSI_OP_REJECT arm releases a command whose
se_cmd was never set up.
The unsolicited NOP-In is the same shape and is already kept away from
iSER: iscsit_add_nopin() allocates its command the same way, and
iscsi_post_login_start_timers() does not arm that timer for
ISCSI_INFINIBAND.
Fixes: 4366b19ca5eb ("iser-target: Change the recv buffers posting logic")
Cc: stable@xxxxxxxxxxxxxxx
Signed-off-by: Yehyeong Lee <yhlee@xxxxxxxxxxxxxxxxxx>
---
drivers/infiniband/ulp/isert/ib_isert.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/drivers/infiniband/ulp/isert/ib_isert.c b/drivers/infiniband/ulp/isert/ib_isert.c
index efa8d7b7844c97..81164881dcc241 100644
--- a/drivers/infiniband/ulp/isert/ib_isert.c
+++ b/drivers/infiniband/ulp/isert/ib_isert.c
@@ -758,7 +758,8 @@ isert_post_recv(struct isert_conn *isert_conn, struct iser_rx_desc *rx_desc)
struct ib_recv_wr rx_wr;
int ret;
- if (!rx_desc->in_use) {
+ /* A command iscsit_add_reject() allocated has no descriptor. */
+ if (!rx_desc || !rx_desc->in_use) {
/*
* if the descriptor is not in-use we already reposted it
* for recv, so just silently return
@@ -1958,6 +1959,9 @@ isert_put_reject(struct iscsit_cmd *cmd, struct iscsit_conn *conn)
struct iscsi_reject *hdr =
(struct iscsi_reject *)&isert_cmd->tx_desc.iscsi_header;
+ isert_cmd->conn = isert_conn;
+ isert_cmd->iscsit_cmd = cmd;
+
isert_create_send_desc(isert_conn, isert_cmd, &isert_cmd->tx_desc);
iscsit_build_reject(cmd, conn, hdr);
isert_init_tx_hdrs(isert_conn, &isert_cmd->tx_desc);
--
2.43.0