]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
net: mana: Fix TOCTOU double-fetch of hwc_msg_id from DMA buffer
authorErni Sri Satya Vennela <ernis@linux.microsoft.com>
Thu, 14 May 2026 19:41:51 +0000 (12:41 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 1 Jun 2026 15:54:49 +0000 (17:54 +0200)
commit3c4db56ccd13dd020fbf43afabaee74a40ec75e4
tree332ad66861ae6e3491a8a3acd97b76eaf02df9c4
parente6edebb5ac70890920d410507ad2568f19716788
net: mana: Fix TOCTOU double-fetch of hwc_msg_id from DMA buffer

[ Upstream commit 35f0f0a2536a4d604b4dbad92c85c4a8fdebb870 ]

In mana_hwc_rx_event_handler(), resp->response.hwc_msg_id is read from
DMA-coherent memory and bounds-checked, then mana_hwc_handle_resp()
re-reads the same field from the same DMA buffer for test_bit() and
pointer arithmetic.

DMA-coherent memory is mapped uncacheable on x86 and is shared,
unencrypted, in Confidential VMs (SEV-SNP/TDX), so each load goes
directly to host-visible memory. A H/W can modify the value
between the check and the use, bypassing the bounds validation.

Fix this by reading hwc_msg_id exactly once using READ_ONCE() into a
stack-local variable in mana_hwc_rx_event_handler(), and passing the
validated value as a parameter to mana_hwc_handle_resp().

Fixes: ca9c54d2d6a5 ("net: mana: Add a driver for Microsoft Azure Network Adapter (MANA)")
Signed-off-by: Erni Sri Satya Vennela <ernis@linux.microsoft.com>
Link: https://patch.msgid.link/20260514194156.466823-1-ernis@linux.microsoft.com
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/net/ethernet/microsoft/mana/hw_channel.c