From: sashiko-bot@kernel.org
To: "Yehyeong Lee" <yhlee@isslab.korea.ac.kr>
Cc: linux-rdma@vger.kernel.org, target-devel@vger.kernel.org,
linux-scsi@vger.kernel.org
Subject: Re: [PATCH 1/2] IB/isert: finish a Reject the target core allocated itself
Date: Mon, 16 Nov 2026 10:30:59 +0000 [thread overview]
Message-ID: <sashiko-outbox-216740@kernel.org> (raw)
In-Reply-To: <20261116101108.1650132-1-yhlee@isslab.korea.ac.kr>
Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [High] IB/isert: late or missing isert_cmd init for target-allocated
commands
--
commit 7a5bd9118f37880c28b788536bd93564bfb3692e
Author: Yehyeong Lee <yhlee@isslab.korea.ac.kr>
IB/isert: finish a Reject the target core allocated itself
This commit updates isert_post_recv() to ignore commands without a receive
descriptor and initializes isert_cmd->conn and isert_cmd->iscsit_cmd in
isert_put_reject() for reject commands allocated by iscsit_add_reject().
> diff --git a/drivers/infiniband/ulp/isert/ib_isert.c b/drivers/infiniband/ulp/isert/ib_isert.c
> index efa8d7b7844c9..81164881dcc24 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);
[Severity: High]
Can a target-allocated command still reach isert_put_cmd() or
isert_send_done() with NULL isert_cmd->conn and isert_cmd->iscsit_cmd?
iscsit_add_reject() links the zeroed command (with targ_xfer_tag == 0) onto
conn->conn_cmd_list before queuing it to the response queue. If the
initiator sends an immediate NOP-Out with itt == 0xffffffff and ttt == 0,
iscsit_process_nop_out() matches the reject command on conn->conn_cmd_list
and queues it with ISTATE_REMOVE on the immediate queue:
drivers/target/iscsi/iscsi_target.c:iscsit_process_nop_out() {
...
if (hdr->ttt != cpu_to_be32(0xFFFFFFFF)) {
cmd_p = iscsit_find_cmd_from_ttt(conn, be32_to_cpu(hdr->ttt));
if (!cmd_p)
return -EINVAL;
iscsit_stop_nopin_response_timer(conn);
cmd_p->i_state = ISTATE_REMOVE;
iscsit_add_cmd_to_immediate_queue(cmd_p, conn, cmd_p->i_state);
iscsit_start_nopin_timer(conn);
return 0;
}
...
}
Because iscsi_target_tx_thread() drains the immediate queue before the
response queue, isert_immediate_queue() calls isert_put_cmd() before
isert_put_reject() has populated isert_cmd->conn and isert_cmd->iscsit_cmd,
causing a NULL pointer dereference (or freeing the command while it remains
queued on conn->response_queue_list).
In addition, both iscsit_process_nop_out() above and
iscsit_na_nopin_timeout() start nopin_timer without checking for
ISCSI_INFINIBAND. When that timer fires, iscsit_add_nopin() allocates an
unsolicited NOP-In via iscsit_allocate_cmd() and queues it to
isert_immediate_queue() -> isert_put_nopin(). Now that isert_post_recv()
accepts a NULL rx_desc, isert_put_nopin() posts the send work request
without setting isert_cmd->conn or isert_cmd->iscsit_cmd, and
isert_send_done() dereferences a NULL isert_cmd->iscsit_cmd on completion.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261116101108.1650132-1-yhlee@isslab.korea.ac.kr?part=1
prev parent reply other threads:[~2026-11-16 10:30 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-16 10:11 [PATCH 1/2] IB/isert: finish a Reject the target core allocated itself Yehyeong Lee
2026-11-16 10:11 ` [PATCH 2/2] IB/isert: do not leak the receive descriptor of a dropped Data-Out Yehyeong Lee
2026-11-16 10:30 ` sashiko-bot [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=sashiko-outbox-216740@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=linux-rdma@vger.kernel.org \
--cc=linux-scsi@vger.kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
--cc=target-devel@vger.kernel.org \
--cc=yhlee@isslab.korea.ac.kr \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox