zxdh_bar_irq_recv() allocates the request buffer with<br />rte_malloc(NULL, msg_header.len, 0), where len is written by the<br />sender into the shared window and is only checked against the 2036<br />byte maximum. pf_recv_bar_msg() then casts the buffer to a full<br />struct zxdh_msg_info and dispatches it through zxdh_proc_cb[] without<br />passing the length on, so no handler can check it.<br /> <br />A short request therefore reads past the allocation, and a<br />ZXDH_FLOW_HW_GET request with len = 180 writes the 16-byte result<br />field at offset 180 entirely outside the 180-byte buffer, corrupting<br />the EAL heap. The dispatcher itself already over-reads for len < 7.<br /> <br />Allocate the maximum payload size, zeroed, and still copy in only<br />len bytes: ZXDH_BAR_MSG_PAYLOAD_MAX_LEN equals<br />sizeof(struct zxdh_msg_info), which the header check already<br />guarantees len does not exceed, so every handler access stays inside<br />the buffer and a short head decodes as zeroed instead of reading past<br />the end. The reply path already allocates the maximum for its buffer.<br /> <br />Fixes: 3630ac8bd81f ("net/zxdh: configure interrupt")<br />Cc: stable@dpdk.org<br /> <br />Signed-off-by: Junlong Wang <wang.junlong1@zte.com.cn> <br />---<br /> drivers/net/zxdh/zxdh_msg.c | 7 ++++++-<br /> 1 file changed, 6 insertions(+), 1 deletion(-)<br /> <br />diff --git a/drivers/net/zxdh/zxdh_msg.c b/drivers/net/zxdh/zxdh_msg.c<br />index c7a3281987..95b2f5a60b 100644<br />--- a/drivers/net/zxdh/zxdh_msg.c<br />+++ b/drivers/net/zxdh/zxdh_msg.c<br />@@ -1009,7 +1009,12 @@ zxdh_bar_irq_recv(uint8_t src, uint8_t dst, uint64_t virt_addr, void *dev)<br />         return -1;<br />     }<br />  <br />-    recved_msg = rte_malloc(NULL, msg_header.len, 0);<br />+    /*<br />+     * The sender chooses the length, but the receive callbacks access the<br />+     * payload as a full struct zxdh_msg_info: always give them a zeroed<br />+     * buffer of the maximum payload size.<br />+     */<br />+    recved_msg = rte_zmalloc(NULL, ZXDH_BAR_MSG_PAYLOAD_MAX_LEN, 0);<br />     if (recved_msg == NULL) {<br />         PMD_MSG_LOG(ERR, "malloc temp buff failed");<br />         return -1;<br />--  <br />2.27.0<br />