]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
nvmet-tcp: propagate nvmet_tcp_build_pdu_iovec() errors to its callers
authorMaurizio Lombardi <mlombard@redhat.com>
Mon, 16 Mar 2026 14:39:35 +0000 (15:39 +0100)
committerKeith Busch <kbusch@kernel.org>
Wed, 8 Apr 2026 19:05:00 +0000 (12:05 -0700)
commitea8e356acb165cb1fd75537a52e1f66e5e76c538
treec7ef7bd2d4e142d3c30ab194698ef0d01de3e030
parent23528aa3320a74b028e990b5a939fed32a8afc2f
nvmet-tcp: propagate nvmet_tcp_build_pdu_iovec() errors to its callers

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.

Fixes: 52a0a9854934 ("nvmet-tcp: add bounds checks in nvmet_tcp_build_pdu_iovec")
Reviewed-by: Hannes Reinecke <hare@suse.de>
Reviewed-by: Yunje Shin <ioerts@kookmin.ac.kr>
Reviewed-by: Chaitanya Kulkarni <kch@nvidia.com>
Signed-off-by: Maurizio Lombardi <mlombard@redhat.com>
Signed-off-by: Keith Busch <kbusch@kernel.org>
drivers/nvme/target/tcp.c