mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2026-09-22 09:34:56 +02:00
net: mana: validate rx_req_idx to prevent out-of-bounds array access
[ Upstream commitb809d04099] In mana_hwc_rx_event_handler(), rx_req_idx is derived from sge->address in DMA-coherent memory. In Confidential VMs (SEV-SNP/TDX), this memory is shared unencrypted and HW can modify WQE contents at any time. No bounds check exists on rx_req_idx, which can lead to an out-of-bounds access into reqs[]. Add bounds check on rx_req_idx in mana_hwc_rx_event_handler() before using it to index the reqs[] array. Fixes:ca9c54d2d6("net: mana: Add a driver for Microsoft Azure Network Adapter (MANA)") Signed-off-by: Aditya Garg <gargaditya@linux.microsoft.com> Reviewed-by: Haiyang Zhang <haiyangz@microsoft.com> Link: https://patch.msgid.link/20260520051553.857120-1-gargaditya@linux.microsoft.com Signed-off-by: Jakub Kicinski <kuba@kernel.org> Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:
committed by
Greg Kroah-Hartman
parent
3dee2fe0c8
commit
01f7f893d5
@@ -232,6 +232,12 @@ static void mana_hwc_rx_event_handler(void *ctx, u32 gdma_rxq_id,
|
||||
rq_base_addr = hwc_rxq->msg_buf->mem_info.dma_handle;
|
||||
rx_req_idx = (sge->address - rq_base_addr) / hwc->max_req_msg_size;
|
||||
|
||||
if (rx_req_idx >= hwc_rxq->msg_buf->num_reqs) {
|
||||
dev_err(hwc->dev, "HWC RX: wrong rx_req_idx=%llu, num_reqs=%u\n",
|
||||
rx_req_idx, hwc_rxq->msg_buf->num_reqs);
|
||||
return;
|
||||
}
|
||||
|
||||
rx_req = &hwc_rxq->msg_buf->reqs[rx_req_idx];
|
||||
resp = (struct gdma_resp_hdr *)rx_req->buf_va;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user