]> www.infradead.org Git - nvme.git/commit
nvme-tcp: fix potential memory corruption in nvme_tcp_recv_pdu()
authorMaurizio Lombardi <mlombard@redhat.com>
Wed, 26 Feb 2025 13:42:18 +0000 (14:42 +0100)
committerKeith Busch <kbusch@kernel.org>
Fri, 28 Feb 2025 02:19:08 +0000 (18:19 -0800)
commitad95bab0cd28ed77c2c0d0b6e76e03e031391064
tree3ba360d1fb8d066eb2e1d8b587095d2e7de012cb
parentafb41b08c44e5386f2f52fa859010ac4afd2b66f
nvme-tcp: fix potential memory corruption in nvme_tcp_recv_pdu()

nvme_tcp_recv_pdu() doesn't check the validity of the header length.
When header digests are enabled, a target might send a packet with an
invalid header length (e.g. 255), causing nvme_tcp_verify_hdgst()
to access memory outside the allocated area and cause memory corruptions
by overwriting it with the calculated digest.

Fix this by rejecting packets with an unexpected header length.

Fixes: 3f2304f8c6d6 ("nvme-tcp: add NVMe over TCP host driver")
Signed-off-by: Maurizio Lombardi <mlombard@redhat.com>
Reviewed-by: Sagi Grimberg <sagi@grimberg.me>
Signed-off-by: Keith Busch <kbusch@kernel.org>
drivers/nvme/host/tcp.c