* [PATCH] scsi: libiscsi_tcp: prevent R2T range check overflow
@ 2026-10-19 21:30 Ratnaker Gautam
2026-10-20 3:38 ` Chris Leech
2026-10-24 2:48 ` Martin K. Petersen
0 siblings, 2 replies; 3+ messages in thread
From: Ratnaker Gautam @ 2026-10-19 21:30 UTC (permalink / raw)
To: linux-scsi@vger.kernel.org
Cc: lduncan@suse.com, Chris Leech, michael.christie@oracle.com,
James Bottomley, mkp@kernel.org
An iSCSI target controls the R2T data offset and length as 32-bit
values. Adding them before comparing the result with the SCSI data
buffer length can wrap. An R2T with offset 1 and length U32_MAX then
passes the check for a 4096-byte write.
The transmit path treats the wrapped range as valid, exhausts the
command scatterlist, and dereferences the NULL next entry in
iscsi_tcp_segment_done().
Check the offset first, then compare the length with the remaining
bytes in the data buffer.
Fixes: a081c13e39b5 ("[SCSI] iscsi_tcp: split module into lib and lld")
Cc: stable@vger.kernel.org
Signed-off-by: Ratnaker Gautam <ratnaker.gautam@kuleuven.be>
---
drivers/scsi/libiscsi_tcp.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/drivers/scsi/libiscsi_tcp.c b/drivers/scsi/libiscsi_tcp.c
index d35f93451ee9b..3c9e736d45e7e 100644
--- a/drivers/scsi/libiscsi_tcp.c
+++ b/drivers/scsi/libiscsi_tcp.c
@@ -601,7 +601,8 @@ static int iscsi_tcp_r2t_rsp(struct iscsi_conn *conn, struct iscsi_hdr *hdr)
data_length, session->max_burst);
data_offset = be32_to_cpu(rhdr->data_offset);
- if (data_offset + data_length > task->sc->sdb.length) {
+ if (data_offset > task->sc->sdb.length ||
+ data_length > task->sc->sdb.length - data_offset) {
iscsi_conn_printk(KERN_ERR, conn,
"invalid R2T with data len %u at offset %u "
"and total length %d\n", data_length,
--
2.43.0
^ permalink raw reply related [flat|nested] 3+ messages in thread* Re: [PATCH] scsi: libiscsi_tcp: prevent R2T range check overflow
2026-10-19 21:30 [PATCH] scsi: libiscsi_tcp: prevent R2T range check overflow Ratnaker Gautam
@ 2026-10-20 3:38 ` Chris Leech
2026-10-24 2:48 ` Martin K. Petersen
1 sibling, 0 replies; 3+ messages in thread
From: Chris Leech @ 2026-10-20 3:38 UTC (permalink / raw)
To: Ratnaker Gautam
Cc: linux-scsi@vger.kernel.org, lduncan@suse.com,
michael.christie@oracle.com, James Bottomley, mkp@kernel.org
On Mon, Oct 19, 2026 at 09:30:33PM +0000, Ratnaker Gautam wrote:
> An iSCSI target controls the R2T data offset and length as 32-bit
> values. Adding them before comparing the result with the SCSI data
> buffer length can wrap. An R2T with offset 1 and length U32_MAX then
> passes the check for a 4096-byte write.
>
> The transmit path treats the wrapped range as valid, exhausts the
> command scatterlist, and dereferences the NULL next entry in
> iscsi_tcp_segment_done().
>
> Check the offset first, then compare the length with the remaining
> bytes in the data buffer.
>
> Fixes: a081c13e39b5 ("[SCSI] iscsi_tcp: split module into lib and lld")
> Cc: stable@vger.kernel.org
> Signed-off-by: Ratnaker Gautam <ratnaker.gautam@kuleuven.be>
> ---
> drivers/scsi/libiscsi_tcp.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/scsi/libiscsi_tcp.c b/drivers/scsi/libiscsi_tcp.c
> index d35f93451ee9b..3c9e736d45e7e 100644
> --- a/drivers/scsi/libiscsi_tcp.c
> +++ b/drivers/scsi/libiscsi_tcp.c
> @@ -601,7 +601,8 @@ static int iscsi_tcp_r2t_rsp(struct iscsi_conn *conn, struct iscsi_hdr *hdr)
> data_length, session->max_burst);
>
> data_offset = be32_to_cpu(rhdr->data_offset);
> - if (data_offset + data_length > task->sc->sdb.length) {
> + if (data_offset > task->sc->sdb.length ||
> + data_length > task->sc->sdb.length - data_offset) {
> iscsi_conn_printk(KERN_ERR, conn,
> "invalid R2T with data len %u at offset %u "
> "and total length %d\n", data_length,
> --
Acked-by: Chris Leech <cleech@redhat.com>
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH] scsi: libiscsi_tcp: prevent R2T range check overflow
2026-10-19 21:30 [PATCH] scsi: libiscsi_tcp: prevent R2T range check overflow Ratnaker Gautam
2026-10-20 3:38 ` Chris Leech
@ 2026-10-24 2:48 ` Martin K. Petersen
1 sibling, 0 replies; 3+ messages in thread
From: Martin K. Petersen @ 2026-10-24 2:48 UTC (permalink / raw)
To: Ratnaker Gautam
Cc: linux-scsi@vger.kernel.org, lduncan@suse.com, Chris Leech,
michael.christie@oracle.com, James Bottomley, mkp@kernel.org
Ratnaker,
> An iSCSI target controls the R2T data offset and length as 32-bit
> values. Adding them before comparing the result with the SCSI data
> buffer length can wrap. An R2T with offset 1 and length U32_MAX then
> passes the check for a 4096-byte write.
Applied to 7.4/scsi-staging, thanks!
--
Martin K. Petersen
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-10-24 2:48 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-10-19 21:30 [PATCH] scsi: libiscsi_tcp: prevent R2T range check overflow Ratnaker Gautam
2026-10-20 3:38 ` Chris Leech
2026-10-24 2:48 ` Martin K. Petersen
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.