Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795961324; b=3SZFDHUqlQZLaSMeRFtXG0jqcJysaLmzJkRLvp9lg8TvOpYItCAHbUTgIYAcHoCKbwQ3 Y4JUz1k8lhTRWlyGwvgVdJhM+H1MemyaqUhvbnzy45RodRTPwWGH14iBjtRkz2eHM2M4Z yRfk35jzXEwfU6KYt3qD/a+asNQtuL+Mc6fD17UzZZKsWthDACdRVQsf3rUhXFFWiM+3I 7wCTiCJVPvZZsXtQfQLdF3z+sxRUVYdVL61EXkt4qLHO2Z93cTmr+Esjsws2Ipe48rp1G ti8io6gWmanOzf6G5DEBRTrXlnhnsGdr7mq3cpyfNN+rc3Yr+1lXJFGWJkLA++zEQyg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795961324; h=Received:DKIM-Signature:Message-ID:From:Subject:Reply-To:To:Cc: In-Reply-To:References:Content-Type:Content-Transfer-Encoding:Date; bh=oVEAsbzQpFKmXcg5elrl9zV5fWgq/ymnBBpGPxJx5yI=; b=K1grfDslSc1+8zw3/7Ui1nkr2XGG/WVXOKL4Zb+gFOEDIzV81mV0Aa/naAVfWXsGkbQm KOxHZs5nGcvFh0Rw+Hrj17EF+bQn9NYU53ZsV+LAUKchG8tXkg3Vea3CQxjcSQpGqHoVw ThwuUDyBLg/RyaOFwfKKJcjWmwmnbNvfiPH+JWDYMrMRwlkAHA7e8grE1nbLDj2Znm4DA L9tFvXIICFIzazBBMNk7qPpyxEnPLXXdQcXxK+QJUkGAj7SbvZt2v4w79FLil/Uz3zsBU 5/VbMjM553yLxNQz5WQVob0FVVaxgmhRBsCOeV95+s1JQ6e7eqI4pyte1F/MhXMBNBw== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=TxhkFYQb; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E547D606A31C; Sun, 29 Nov 2026 14:08:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=TxhkFYQb Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8D55D1F000C1; Sun, 29 Nov 2026 14:08:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1795961323; bh=oVEAsbzQpFKmXcg5elrl9zV5fWgq/ymnBBpGPxJx5yI=; h=From:Subject:Reply-To:To:Cc:In-Reply-To:References:Date; b=TxhkFYQbslqsgesI4BiVi4uj6B2kqUBpd8wpFDev7lu2eMDcWb9+JbLOBCdDPBR2I GMmSMBKq54+K42x9GD4VXvDnYhJTB0VPceoRkgxcgDssuT2vm6nZtP11Tlya8ljsjZ dsgxObeF+83IGCBtCt7MrPN9VXm/L0bLJhjdDU7t5uaIjUvXI7bvVyhMaK5OJXZPQl fCIDtaTs0GVYvIeiGKK4J+6DMGglmMGwKRnHO12fvxGj6itaBn2DrrYt7KCWSo7yOm 95OC+faeUQL8YccIFooOVjVkxUjJ0mg/1BKYGeGVT4/4Gf52nVDCM7noUFfMm6W/zr lu72bnfKL1Gew== Message-ID: From: sashiko-bot@kernel.org Subject: Re: [PATCH] scsi: target: iscsi: Free dropped Text commands on DataDigest errors Reply-To: sashiko-reviews@lists.linux.dev To: "Andrew Stellman" Cc: target-devel@vger.kernel.org, linux-scsi@vger.kernel.org In-Reply-To: <20261129135303.80812-1-bugs@stellman-greene.com> References: <20261129135303.80812-1-bugs@stellman-greene.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Sun, 29 Nov 2026 14:08:43 +0000 X-Mailing-List: linux-scsi@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list Thank you for your contribution! Sashiko AI review found 1 potential issue to consider: - [Low] scsi: target: iscsi: inaccurate Fixes trailer for iscsit_handle_text_cmd() It also noticed 1 related pre-existing issue this patch does not introduce: - [Critical] scsi: target: iscsi: TCP stream desynchronization in non-SCSI handlers [1] -- commit 3e3312bd41bf89c36eb174a1346bc67aacc6f605 Author: Andrew Stellman > scsi: target: iscsi: Free dropped Text commands on DataDigest errors > > At ErrorRecoveryLevel 1 and above, iscsit_handle_text_cmd() and > cxgbit_handle_text_cmd() silently drop a Text Request whose DataDigest > doesn't match. When the request starts a new exchange (TTT 0xffffffff), > the receive path has already allocated a command and a session tag for > it, but the drop path returns without linking the command to the > connection or freeing it, so each such request leaks the command and > its tag. > > Free the command on both drop paths when TTT is 0xffffffff, as the > NOP-Out DataDigest error path already does. A Text Request that > continues an existing exchange uses a command that is already on the > connection list, so it's left alone. The PDU is still dropped silently. > > Tested over TCP on mainline in an arm64 QEMU guest with KASAN, ERL 1 > and DataDigest=3DCRC32C. Before the fix, after 140 Text Requests with a > bad DataDigest the target logged 136 digest errors and a following > NOP-Out got no NOP-In within 3 seconds; with the fix it got a NOP-In. > The cxgbit change was compiled but not run. > > The issue was found by Claude Opus 5.5 running Quality Playbook, an > LLM-driven code review tool: > https://github.com/andrewstellman/quality-playbook > The fix was drafted with OpenAI GPT-6 (Codex) and this changelog with > Claude Opus 5.5, and both were reviewed by me. > > Fixes: e48354ce078c ("iscsi-target: Add iSCSI fabric support for target v= 4.1") > Fixes: 9730ffcb8957 ("cxgbit: add files for cxgbit.ko") > Signed-off-by: Andrew Stellman [Severity: Low] In commit e48354ce078c ("iscsi-target: Add iSCSI fabric support for target v4.1"), iscsit_handle_text_cmd() validated the DataDigest before calling iscsit_allocate_cmd(), so the ERL >=3D 1 DataCRC drop path did not leak a command. The leak in iscsit_handle_text_cmd() was introduced when commit 64534aa79496 ("iscsi-target: Refactor ISCSI_OP_TEXT RX handling") hoisted iscsit_allocate_cmd() into iscsi_target_rx_opcode(). Should the first Fixes: tag be: Fixes: 64534aa79496 ("iscsi-target: Refactor ISCSI_OP_TEXT RX handling") [ ... ] > diff --git a/drivers/target/iscsi/iscsi_target.c b/drivers/target/iscsi/i= scsi_target.c > index 2b4956f46c132..9810e3dfcc1ce 100644 > --- a/drivers/target/iscsi/iscsi_target.c > +++ b/drivers/target/iscsi/iscsi_target.c > @@ -2300,6 +2300,8 @@ iscsit_handle_text_cmd(struct iscsit_conn *conn, st= ruct iscsit_cmd *cmd, > " DataCRC error.\n", hdr->cmdsn); > kfree(text_in); > cmd->text_in_ptr =3D NULL; > + if (hdr->ttt =3D=3D cpu_to_be32(0xFFFFFFFF)) > + iscsit_free_cmd(cmd, false); > return 0; > } > } else { [Severity: Critical] This problem wasn't introduced by this patch, but can an early failure in iscsit_setup_text_cmd() desynchronize the TCP stream [1]? drivers/target/iscsi/iscsi_target.c:iscsit_handle_text_cmd() { ... rc =3D iscsit_setup_text_cmd(conn, cmd, hdr); if (rc < 0) return 0; rx_size =3D payload_length; if (payload_length) { ... } When iscsit_setup_text_cmd() fails on a Text Request carrying a non-zero payload_length (and similarly in iscsit_handle_nop_out() when iscsit_setup_nop_out() fails), the handler returns 0 without reading payload_length bytes from the socket. The RX thread then parses the unread payload as the next iSCSI Basic Header Segment, allowing crafted payload bytes to inject arbitrary PDUs or crash the target. [1] https://sashiko.dev/#/bug/linux-bc9d46c7-9320-42b5-85cc-7b0a1cddfeb4 --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/20261129135303.8081= 2-1-bugs@stellman-greene.com?part=3D1