From: sashiko-bot@kernel.org
To: "Henry Martin" <bsdhenrymartin@gmail.com>
Cc: linux-scsi@vger.kernel.org
Subject: Re: [PATCH] scsi: qedi: fix OOB read in login/text response completion
Date: Tue, 27 Oct 2026 15:23:02 +0000 [thread overview]
Message-ID: <sashiko-outbox-186828@kernel.org> (raw)
In-Reply-To: <20261027150752.951217-1-bsdhenrymartin@gmail.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] scsi: qedi: unclamped dlength in qedi_process_text_resp() and login_resp()
--
commit b81ce3a14651452d3f551e4635d2337a8b305729
Author: Henry Martin <bsdhenrymartin@gmail.com>
scsi: qedi: fix OOB read in login/text response completion
This commit clamps the payload length extracted from the CQE in
qedi_process_text_resp() and qedi_process_login_resp() to
qedi_conn->gen_pdu.resp_buf_size before advancing resp_wr_ptr, preventing
an out-of-bounds read when completing the PDU to userspace.
> diff --git a/drivers/scsi/qedi/qedi_fw.c b/drivers/scsi/qedi/qedi_fw.c
> index c8af10c326532..5e20716043aee 100644
> --- a/drivers/scsi/qedi/qedi_fw.c
> +++ b/drivers/scsi/qedi/qedi_fw.c
> @@ -115,6 +115,8 @@ static void qedi_process_text_resp(struct qedi_ctx *qedi,
>
> pld_len = cqe_text_response->hdr_second_dword &
> ISCSI_TEXT_RESPONSE_HDR_DATA_SEG_LEN_MASK;
> + if (pld_len > qedi_conn->gen_pdu.resp_buf_size)
> + pld_len = qedi_conn->gen_pdu.resp_buf_size;
> qedi_conn->gen_pdu.resp_wr_ptr = qedi_conn->gen_pdu.resp_buf + pld_len;
>
> memset(task_ctx, '\0', sizeof(*task_ctx));
> @@ -294,6 +296,8 @@ static void qedi_process_login_resp(struct qedi_ctx *qedi,
> resp_hdr_ptr->status_detail = cqe_login_response->status_detail;
> pld_len = cqe_login_response->hdr_second_dword &
> ISCSI_LOGIN_RESPONSE_HDR_DATA_SEG_LEN_MASK;
> + if (pld_len > qedi_conn->gen_pdu.resp_buf_size)
> + pld_len = qedi_conn->gen_pdu.resp_buf_size;
> qedi_conn->gen_pdu.resp_wr_ptr = qedi_conn->gen_pdu.resp_buf + pld_len;
[Severity: Medium]
Should resp_hdr_ptr->dlength also be populated from the clamped pld_len in
both qedi_process_text_resp() and qedi_process_login_resp()?
Earlier in both functions, resp_hdr_ptr->dlength is written using the raw
unclamped 24-bit CQE value before pld_len is clamped to
qedi_conn->gen_pdu.resp_buf_size:
drivers/scsi/qedi/qedi_fw.c:qedi_process_text_resp() {
...
hton24(resp_hdr_ptr->dlength,
(cqe_text_response->hdr_second_dword &
ISCSI_TEXT_RESPONSE_HDR_DATA_SEG_LEN_MASK));
...
pld_len = cqe_text_response->hdr_second_dword &
ISCSI_TEXT_RESPONSE_HDR_DATA_SEG_LEN_MASK;
if (pld_len > qedi_conn->gen_pdu.resp_buf_size)
pld_len = qedi_conn->gen_pdu.resp_buf_size;
qedi_conn->gen_pdu.resp_wr_ptr = qedi_conn->gen_pdu.resp_buf + pld_len;
and similarly in qedi_process_login_resp():
drivers/scsi/qedi/qedi_fw.c:qedi_process_login_resp() {
...
hton24(resp_hdr_ptr->dlength,
(cqe_login_response->hdr_second_dword &
ISCSI_LOGIN_RESPONSE_HDR_DATA_SEG_LEN_MASK));
...
pld_len = cqe_login_response->hdr_second_dword &
ISCSI_LOGIN_RESPONSE_HDR_DATA_SEG_LEN_MASK;
if (pld_len > qedi_conn->gen_pdu.resp_buf_size)
pld_len = qedi_conn->gen_pdu.resp_buf_size;
qedi_conn->gen_pdu.resp_wr_ptr = qedi_conn->gen_pdu.resp_buf + pld_len;
When __iscsi_complete_pdu() calls iscsi_recv_pdu(), the netlink message is
allocated and populated with only data_size (the clamped pld_len) bytes of
payload following the header:
drivers/scsi/scsi_transport_iscsi.c:iscsi_recv_pdu() {
int len = nlmsg_total_size(sizeof(*ev) + sizeof(struct iscsi_hdr) +
data_size);
...
pdu = (char*)ev + sizeof(*ev);
memcpy(pdu, hdr, sizeof(struct iscsi_hdr));
memcpy(pdu + sizeof(struct iscsi_hdr), data, data_size);
If the CQE data segment length exceeds resp_buf_size, won't this leave
resp_hdr_ptr->dlength advertising the larger unclamped length in the
embedded struct iscsi_hdr while only resp_buf_size bytes of payload are
actually present in the netlink message sent to userspace?
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261027150752.951217-1-bsdhenrymartin@gmail.com?part=1
next prev parent reply other threads:[~2026-10-27 15:23 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-27 15:07 [PATCH] scsi: qedi: fix OOB read in login/text response completion Henry Martin
2026-10-27 15:23 ` sashiko-bot [this message]
2026-10-27 15:44 ` henry martin
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=sashiko-outbox-186828@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=bsdhenrymartin@gmail.com \
--cc=linux-scsi@vger.kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
/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.