From: sashiko-bot@kernel.org
To: "Andrew Stellman" <bugs@stellman-greene.com>
Cc: target-devel@vger.kernel.org, linux-scsi@vger.kernel.org
Subject: Re: [PATCH v3 scsi-fixes 2/2] scsi: target: iscsi: Fix UAF on an immediate data digest error
Date: Sun, 29 Nov 2026 16:12:36 +0000 [thread overview]
Message-ID: <sashiko-outbox-239780@kernel.org> (raw)
In-Reply-To: <20261129155252.2217-2-bugs@stellman-greene.com>
Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [High] scsi: target: iscsi: RX thread self-deadlock in
iscsit_add_reject()
--
commit ee60b35a65525f8ccfdd012ce8a26204ba7f7593
Author: Andrew Stellman <astellman@stellman-greene.com>
scsi: target: iscsi: Fix UAF on an immediate data digest error
This commit fixes a use-after-free on immediate data digest errors at
ErrorRecoveryLevel >= 1 by sending the Reject PDU with iscsit_add_reject()
and freeing the failed WRITE command directly in the RX thread.
> diff --git a/drivers/target/iscsi/cxgbit/cxgbit_target.c b/drivers/target/iscsi/cxgbit/cxgbit_target.c
> index 3698f2eb097e3..0b0a3cc3361f3 100644
> --- a/drivers/target/iscsi/cxgbit/cxgbit_target.c
> +++ b/drivers/target/iscsi/cxgbit/cxgbit_target.c
> @@ -871,7 +871,7 @@ cxgbit_handle_immediate_data(struct iscsit_cmd *cmd, struct iscsi_scsi_req *hdr,
> return IMMEDIATE_DATA_CANNOT_RECOVER;
> }
>
> - iscsit_reject_cmd(cmd, ISCSI_REASON_DATA_DIGEST_ERROR,
> + iscsit_add_reject(conn, ISCSI_REASON_DATA_DIGEST_ERROR,
> (unsigned char *)hdr);
> return IMMEDIATE_DATA_ERL1_CRC_FAILURE;
> }
> @@ -946,8 +946,8 @@ cxgbit_get_immediate_data(struct iscsit_cmd *cmd, struct iscsi_scsi_req *hdr,
> } else if (immed_ret == IMMEDIATE_DATA_ERL1_CRC_FAILURE) {
> /*
> * Immediate Data failed DataCRC and ERL>=1,
> - * silently drop this PDU and let the initiator
> - * plug the CmdSN gap.
> + * reject this PDU and let the initiator plug the CmdSN gap.
> + * The Reject uses a separate command, so this WRITE can be freed.
> *
> * FIXME: Send Unsolicited NOPIN with reserved
> * TTT here to help the initiator figure out
> @@ -955,8 +955,11 @@ cxgbit_get_immediate_data(struct iscsit_cmd *cmd, struct iscsi_scsi_req *hdr,
> * intelligent enough to determine the missing
> * CmdSN and issue a retry to plug the sequence.
> */
> - cmd->i_state = ISTATE_REMOVE;
> - iscsit_add_cmd_to_immediate_queue(cmd, conn, cmd->i_state);
> + spin_lock_bh(&conn->cmd_lock);
> + list_del_init(&cmd->i_conn_node);
> + spin_unlock_bh(&conn->cmd_lock);
> + target_put_sess_cmd(&cmd->se_cmd);
> + iscsit_free_cmd(cmd, false);
> } else /* immed_ret == IMMEDIATE_DATA_CANNOT_RECOVER */
> return -1;
>
> diff --git a/drivers/target/iscsi/iscsi_target.c b/drivers/target/iscsi/iscsi_target.c
> index 359c66d1051ab..fafd3d31a2a5d 100644
> --- a/drivers/target/iscsi/iscsi_target.c
> +++ b/drivers/target/iscsi/iscsi_target.c
> @@ -1360,8 +1360,8 @@ iscsit_get_immediate_data(struct iscsit_cmd *cmd, struct iscsi_scsi_req *hdr,
> } else if (immed_ret == IMMEDIATE_DATA_ERL1_CRC_FAILURE) {
> /*
> * Immediate Data failed DataCRC and ERL>=1,
> - * silently drop this PDU and let the initiator
> - * plug the CmdSN gap.
> + * reject this PDU and let the initiator plug the CmdSN gap.
> + * The Reject uses a separate command, so this WRITE can be freed.
> *
> * FIXME: Send Unsolicited NOPIN with reserved
> * TTT here to help the initiator figure out
> @@ -1369,8 +1369,11 @@ iscsit_get_immediate_data(struct iscsit_cmd *cmd, struct iscsi_scsi_req *hdr,
> * intelligent enough to determine the missing
> * CmdSN and issue a retry to plug the sequence.
> */
> - cmd->i_state = ISTATE_REMOVE;
> - iscsit_add_cmd_to_immediate_queue(cmd, cmd->conn, cmd->i_state);
> + spin_lock_bh(&cmd->conn->cmd_lock);
> + list_del_init(&cmd->i_conn_node);
> + spin_unlock_bh(&cmd->conn->cmd_lock);
> + target_put_sess_cmd(&cmd->se_cmd);
> + iscsit_free_cmd(cmd, false);
> } else /* immed_ret == IMMEDIATE_DATA_CANNOT_RECOVER */
> return -1;
>
> @@ -2656,9 +2659,9 @@ static int iscsit_handle_immediate_data(
> (unsigned char *)hdr);
> return IMMEDIATE_DATA_CANNOT_RECOVER;
> } else {
> - iscsit_reject_cmd(cmd,
> - ISCSI_REASON_DATA_DIGEST_ERROR,
> - (unsigned char *)hdr);
> + iscsit_add_reject(conn,
> + ISCSI_REASON_DATA_DIGEST_ERROR,
> + (unsigned char *)hdr);
> return IMMEDIATE_DATA_ERL1_CRC_FAILURE;
> }
> } else {
[Severity: High]
Can calling iscsit_add_reject() before freeing cmd deadlock the RX thread
in iscsit_wait_for_tag()?
iscsit_add_reject() calls iscsit_allocate_cmd(conn, TASK_INTERRUPTIBLE) to
allocate a new command tag from se_sess->sess_tag_pool while the failed
WRITE cmd still holds its own tag until iscsit_get_immediate_data() (or
cxgbit_get_immediate_data()) frees it. If cmd took the last available tag
in se_sess->sess_tag_pool, and the remaining tags are held by commands
waiting for the RX thread to process subsequent PDUs (for example, sent
responses awaiting ExpStatSN acknowledgement via
iscsit_ack_from_expstatsn(), or multi-PDU WRITEs awaiting Data-Out PDUs),
the RX thread sleeps in iscsit_wait_for_tag() and cannot make progress to
free cmd or read the PDUs needed to release other tags.
Freeing cmd in iscsit_get_immediate_data() and cxgbit_get_immediate_data()
before calling iscsit_add_reject() would return its tag to
se_sess->sess_tag_pool first.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261129155252.2217-1-bugs@stellman-greene.com?part=2
prev parent reply other threads:[~2026-11-29 16:12 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-28 19:17 [PATCH scsi-fixes] scsi: target: iscsi: Fix UAF on an immediate data digest error Andrew Stellman
2026-11-28 19:38 ` sashiko-bot
2026-11-29 0:17 ` [PATCH v2 " Andrew Stellman
2026-11-29 0:36 ` sashiko-bot
2026-11-29 15:52 ` [PATCH v3 scsi-fixes 1/2] scsi: target: iscsi: Reserve tags on standalone Rejects Andrew Stellman
2026-11-29 15:52 ` [PATCH v3 scsi-fixes 2/2] scsi: target: iscsi: Fix UAF on an immediate data digest error Andrew Stellman
2026-11-29 16:12 ` 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-239780@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=bugs@stellman-greene.com \
--cc=linux-scsi@vger.kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
--cc=target-devel@vger.kernel.org \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.