All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] target: iscsi: reject ImmediateData on non-WRITE commands
@ 2026-10-08  6:03 sung byeongchan
  2026-10-08  6:24 ` sashiko-bot
  0 siblings, 1 reply; 2+ messages in thread
From: sung byeongchan @ 2026-10-08  6:03 UTC (permalink / raw)
  To: Martin K . Petersen; +Cc: linux-scsi, target-devel

ImmediateData carries unsolicited write payload and is not valid for a
command without the W bit.  iscsit_setup_scsi_cmd() nevertheless accepts
it on READ commands and passes the payload into write-data handling.

This permits two independently reproduced failure modes.  If the immediate
data is larger than the READ CDB-derived data length while DataDigest is
enabled, iscsit_crc_sglist() walks beyond the command scatterlist and
dereferences a NULL entry.  If the expected transfer and immediate-data
lengths are equal, the receive path can execute the command before CmdSN
sequencing and the sequencing path can execute the same se_cmd again after
its first completion.

Reject ImmediateData on non-WRITE commands before parsing the CDB or
allocating backend state.

Both failures reproduced twice on the originally tested baseline with an
authenticated CHAP-SHA256 initiator.  The fixed kernel rejected both
inputs twice.  A READ without ImmediateData and a WRITE carrying
ImmediateData continued to complete normally.

The demonstrated impact is authenticated remote denial of service of the
target kernel.  No controlled write, disclosure, RCE, or LPE was
demonstrated.  The source reproducer is available privately on request and
is intentionally omitted from this public submission.

Fixes: e48354ce078c ("iscsi-target: Add iSCSI fabric support for target v4.1")
Assisted-by: LLM
Signed-off-by: sung byeongchan <tjdqudcks0424@naver.com>
---
 drivers/target/iscsi/iscsi_target.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/drivers/target/iscsi/iscsi_target.c b/drivers/target/iscsi/iscsi_target.c
index 124ff269b8e75..b8e26e00cd462 100644
--- a/drivers/target/iscsi/iscsi_target.c
+++ b/drivers/target/iscsi/iscsi_target.c
@@ -1098,6 +1098,12 @@ int iscsit_setup_scsi_cmd(struct iscsit_conn *conn, struct iscsit_cmd *cmd,
 					     ISCSI_REASON_BOOKMARK_INVALID, buf);
 	}
 
+	if (payload_length && !(hdr->flags & ISCSI_FLAG_CMD_WRITE)) {
+		pr_err("Immediate data for non-WRITE command\n");
+		return iscsit_add_reject_cmd(cmd,
+					     ISCSI_REASON_PROTOCOL_ERROR, buf);
+	}
+
 	cdb = hdr->cdb;
 
 	if (hdr->hlength) {
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-10-08  6:24 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-10-08  6:03 [PATCH] target: iscsi: reject ImmediateData on non-WRITE commands sung byeongchan
2026-10-08  6:24 ` sashiko-bot

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.