From: yong liu <pkfxxxing@gmail.com>
To: "Martin K. Petersen" <mkp@kernel.org>
Cc: linux-scsi@vger.kernel.org, target-devel@vger.kernel.org,
linux-kernel@vger.kernel.org, security@kernel.org
Subject: [PATCH v2] scsi: target: Disable protection processing for zero-block commands
Date: Wed, 11 Nov 2026 11:05:43 +0800 [thread overview]
Message-ID: <20261111030544.1216434-1-pkfxxxing@gmail.com> (raw)
In-Reply-To: <20261109092744.822646-2-pkfxxxing@gmail.com>
A READ(10) with its TRANSFER LENGTH field set to zero on a PI-enabled
LUN can select TARGET_PROT_DIN_STRIP while leaving cmd->prot_length at
zero. transport_generic_new_cmd() then allocates an empty protection
scatterlist, causing a target-side Oops, which can also lead to
use-after-free during subsequent iSCSI connection cleanup. A logged-in
iSCSI initiator can trigger this on a FILEIO LUN with protection
information enabled.
After validating PROTECT, reset the protection operation, type and
checks for zero-block commands in sbc_check_prot(). This avoids the
empty allocation and prevents backends and fabrics from selecting PI
processing without a protection payload. Preserve the existing
data-length adjustment for commands carrying PI over the wire.
The issue was discovered and fixed by Qihoo 360's Tulongfeng multi-agent
system.
Fixes: 5835812f13e5 ("target: ensure se_cmd->t_prot_sg is allocated when required")
Cc: stable@vger.kernel.org
Signed-off-by: yong liu <pkfxxxing@gmail.com>
---
Changes in v2 (addressing sashiko-bot's protection-state review):
- Replace the allocation-only guard with a zero-block protection state fix
in sbc_check_prot(), so backends and fabrics do not select PI processing
without a protection payload.
- Preserve PROTECT validation and the existing data-length adjustment.
Developed against f66469d9905b39d2c260a15d7d6db450f4db67c1 (7.4-rc1).
drivers/target/target_core_sbc.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/drivers/target/target_core_sbc.c b/drivers/target/target_core_sbc.c
index 21f5cb86d7..560e62cef7 100644
--- a/drivers/target/target_core_sbc.c
+++ b/drivers/target/target_core_sbc.c
@@ -721,6 +721,12 @@ sbc_check_prot(struct se_device *dev, struct se_cmd *cmd, unsigned char protect,
if (sbc_set_prot_op_checks(protect, fabric_prot, pi_prot_type, is_write, cmd))
return TCM_INVALID_CDB_FIELD;
+ if (!sectors) {
+ cmd->prot_op = TARGET_PROT_NORMAL;
+ cmd->prot_checks = 0;
+ pi_prot_type = TARGET_DIF_TYPE0_PROT;
+ }
+
cmd->prot_type = pi_prot_type;
cmd->prot_length = dev->prot_length * sectors;
--
2.43.0
prev parent reply other threads:[~2026-11-11 3:06 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-09 9:27 [PATCH 0/1] scsi: target: Fix zero-length protection SG allocation liuyong
2026-11-09 9:27 ` [PATCH 1/1] scsi: target: Skip " liuyong
2026-11-11 3:05 ` yong liu [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=20261111030544.1216434-1-pkfxxxing@gmail.com \
--to=pkfxxxing@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-scsi@vger.kernel.org \
--cc=mkp@kernel.org \
--cc=security@kernel.org \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®