From: Chris Leech <cleech@redhat.com>
To: HyeongJun An <sammiee5311@gmail.com>
Cc: Mike Christie <michael.christie@oracle.com>,
Lee Duncan <lduncan@suse.com>,
"Martin K . Petersen" <martin.petersen@oracle.com>,
"James E . J . Bottomley"
<James.Bottomley@hansenpartnership.com>,
open-iscsi@googlegroups.com, linux-scsi@vger.kernel.org,
linux-kernel@vger.kernel.org,
Sashiko AI <sashiko-bot@kernel.org>
Subject: Re: [PATCH] scsi: libiscsi: fix stale-data leak into the SCSI sense buffer
Date: Wed, 15 Jul 2026 23:31:29 -0700 [thread overview]
Message-ID: <20260715-wieldable-expire-2ee53282aed8@redhat.com> (raw)
In-Reply-To: <20260714104934.1404423-1-sammiee5311@gmail.com>
On Tue, Jul 14, 2026 at 07:49:34PM +0900, HyeongJun An wrote:
> iscsi_scsi_cmd_rsp() copies the sense data of a SCSI Response from the
> target-supplied data segment. The segment carries a 2-byte sense length
> followed by the sense bytes, so it must hold 2 + senselen bytes, but the
> bounds check only requires datalen >= senselen:
>
> senselen = get_unaligned_be16(data);
> if (datalen < senselen)
> goto invalid_datalen;
> memcpy(sc->sense_buffer, data + 2,
> min_t(uint16_t, senselen, SCSI_SENSE_BUFFERSIZE));
>
> A target that returns a SCSI Response whose datalen equals senselen (with
> senselen <= SCSI_SENSE_BUFFERSIZE) makes the memcpy() from data + 2 read
> up to two bytes past the received data. Those bytes are stale conn->data
> contents and end up in the command's sense buffer, which is returned to
> userspace.
>
> Account for the 2-byte sense length prefix in the check.
>
> Fixes: 7996a778ff8c ("[SCSI] iscsi: add libiscsi")
> Suggested-by: Sashiko AI <sashiko-bot@kernel.org>
> Assisted-by: Claude:claude-opus-4-8
> Signed-off-by: HyeongJun An <sammiee5311@gmail.com>
> ---
This looks like a good fix to me.
Acked-by: Chris Leech <cleech@redhat.com>
> drivers/scsi/libiscsi.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/scsi/libiscsi.c b/drivers/scsi/libiscsi.c
> index 160f02f2f51d..5cbc51899de0 100644
> --- a/drivers/scsi/libiscsi.c
> +++ b/drivers/scsi/libiscsi.c
> @@ -918,7 +918,7 @@ static void iscsi_scsi_cmd_rsp(struct iscsi_conn *conn, struct iscsi_hdr *hdr,
> }
>
> senselen = get_unaligned_be16(data);
> - if (datalen < senselen)
> + if (datalen < senselen + 2)
> goto invalid_datalen;
>
> memcpy(sc->sense_buffer, data + 2,
> --
> 2.43.0
>
prev parent reply other threads:[~2026-07-16 6:31 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-14 10:49 [PATCH] scsi: libiscsi: fix stale-data leak into the SCSI sense buffer HyeongJun An
2026-07-16 6:31 ` Chris Leech [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=20260715-wieldable-expire-2ee53282aed8@redhat.com \
--to=cleech@redhat.com \
--cc=James.Bottomley@hansenpartnership.com \
--cc=lduncan@suse.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-scsi@vger.kernel.org \
--cc=martin.petersen@oracle.com \
--cc=michael.christie@oracle.com \
--cc=open-iscsi@googlegroups.com \
--cc=sammiee5311@gmail.com \
--cc=sashiko-bot@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.