From: Keith Busch <kbusch@kernel.org>
To: Maurizio Lombardi <mlombard@redhat.com>
Cc: linux-nvme@lists.infradead.org, dwagner@suse.de,
yjshin0438@gmail.com, hare@suse.de, sagi@grimberg.me,
chaitanyak@nvidia.com, mlombard@arkamax.eu
Subject: Re: [PATCH 1/2] nvmet-tcp: propagate nvmet_tcp_build_pdu_iovec() errors to its callers
Date: Wed, 11 Mar 2026 14:20:31 -0600 [thread overview]
Message-ID: <abHOjxsH3uZlWNEu@kbusch-mbp> (raw)
In-Reply-To: <20260311160920.465209-2-mlombard@redhat.com>
On Wed, Mar 11, 2026 at 05:09:19PM +0100, Maurizio Lombardi wrote:
> Currently, when nvmet_tcp_build_pdu_iovec() detects an out-of-bounds
> PDU length or offset, it triggers nvmet_tcp_fatal_error(cmd->queue)
> and returns early. However, because the function returns void, the
> callers are entirely unaware that a fatal error has occurred and
> that the cmd->recv_msg.msg_iter was left uninitialized.
>
> Callers such as nvmet_tcp_handle_h2c_data_pdu() proceed to blindly
> overwrite the queue state with queue->rcv_state = NVMET_TCP_RECV_DATA
> Consequently, the socket receiving loop may attempt to read incoming
> network data into the uninitialized iterator.
>
> Fix this by shifting the error handling responsibility to the callers.
This looks good to me. Just some minor comments below.
> + ret = nvmet_tcp_build_pdu_iovec(cmd);
> + if (unlikely(ret)) {
> + pr_err("queue %d: failed to build PDU iovec", queue->idx);
Missing the '\n' in this print.
> @@ -1092,7 +1098,12 @@ static int nvmet_tcp_done_recv_pdu(struct nvmet_tcp_queue *queue)
> if (nvmet_tcp_need_data_in(queue->cmd)) {
> if (nvmet_tcp_has_inline_data(queue->cmd)) {
> queue->rcv_state = NVMET_TCP_RECV_DATA;
> - nvmet_tcp_build_pdu_iovec(queue->cmd);
> + ret = nvmet_tcp_build_pdu_iovec(queue->cmd);
> + if (unlikely(ret)) {
> + pr_err("queue %d: failed to build PDU iovec\n",
> + queue->idx);
> + return ret;
> + }
> return 0;
Minor nit here, you can squash the two rets into a single 'return ret;'.
next prev parent reply other threads:[~2026-03-11 20:20 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-11 16:09 [PATCH 0/2] nvmet-tcp: fix receive path error handling and state machine Maurizio Lombardi
2026-03-11 16:09 ` [PATCH 1/2] nvmet-tcp: propagate nvmet_tcp_build_pdu_iovec() errors to its callers Maurizio Lombardi
2026-03-11 20:20 ` Keith Busch [this message]
2026-03-11 16:09 ` [PATCH 2/2] nvmet-tcp: remove redundant calls to nvmet_tcp_fatal_error() Maurizio Lombardi
2026-03-11 20:23 ` Keith Busch
2026-03-13 5:58 ` [PATCH 0/2] nvmet-tcp: fix receive path error handling and state machine yunje shin
2026-03-13 11:17 ` Maurizio Lombardi
2026-03-13 12:16 ` Maurizio Lombardi
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=abHOjxsH3uZlWNEu@kbusch-mbp \
--to=kbusch@kernel.org \
--cc=chaitanyak@nvidia.com \
--cc=dwagner@suse.de \
--cc=hare@suse.de \
--cc=linux-nvme@lists.infradead.org \
--cc=mlombard@arkamax.eu \
--cc=mlombard@redhat.com \
--cc=sagi@grimberg.me \
--cc=yjshin0438@gmail.com \
/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