[PATCH v3 8/8] net/zxdh: check msg id before indexing the seqid table

Junlong Wang wang.junlong1 at zte.com.cn
Mon Nov 16 12:31:00 CET 2026


zxdh_bar_msg_ack_async_msg_proc() indexes the 256-entry
g_seqid_ring.reps_info_tbl[] with the 16-bit msg_id taken straight
from the message header a VF writes into the PF/VF window. Nothing on
the receive path compares it with ZXDH_BAR_SEQID_NUM_MAX, so a forged
asynchronous ack with an out-of-range msg_id makes the PF read, and
under some conditions write, up to 1 MiB past the table, crashing the
process that drives the PF.

Reject msg_id >= ZXDH_BAR_SEQID_NUM_MAX before the slot pointer is
formed: the id is logged as invalid and the message dropped, like an
id that is already released. The driver only ever allocates ids below
256, so a well-formed peer is unaffected.

Apply the same comparison in zxdh_bar_chan_sync_msg_reps_get(), which
indexes the same table with the msg_id of a reply; that path is not
reachable from a VF today, the check is hardening.

Fixes: 3630ac8bd81f ("net/zxdh: configure interrupt")
Cc: stable at dpdk.org

Signed-off-by: Junlong Wang <wang.junlong1 at zte.com.cn>
---
 drivers/net/zxdh/zxdh_msg.c | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)

diff --git a/drivers/net/zxdh/zxdh_msg.c b/drivers/net/zxdh/zxdh_msg.c
index 77b8df2f12..4d79d50ab6 100644
--- a/drivers/net/zxdh/zxdh_msg.c
+++ b/drivers/net/zxdh/zxdh_msg.c
@@ -703,6 +703,11 @@ zxdh_bar_chan_sync_msg_reps_get(uint64_t subchan_addr,
 
 	zxdh_bar_chan_msg_header_get(subchan_addr, &msg_header);
 	msg_id = msg_header.msg_id;
+	if (msg_id >= ZXDH_BAR_SEQID_NUM_MAX) {
+		PMD_MSG_LOG(ERR, "msg_id %u is invalid", msg_id);
+		return ZXDH_BAR_MSG_ERR_REPLY;
+	}
+
 	struct zxdh_seqid_item *reps_info = &g_seqid_ring.reps_info_tbl[msg_id];
 
 	if (reps_info->flag != ZXDH_REPS_INFO_FLAG_USED) {
@@ -886,7 +891,13 @@ static void
 zxdh_bar_msg_ack_async_msg_proc(struct zxdh_bar_msg_header *msg_header,
 		uint8_t *receiver_buff)
 {
-	struct zxdh_seqid_item *reps_info = &g_seqid_ring.reps_info_tbl[msg_header->msg_id];
+	struct zxdh_seqid_item *reps_info;
+
+	if (msg_header->msg_id >= ZXDH_BAR_SEQID_NUM_MAX) {
+		PMD_MSG_LOG(ERR, "msg_id: %u is invalid", msg_header->msg_id);
+		return;
+	}
+	reps_info = &g_seqid_ring.reps_info_tbl[msg_header->msg_id];
 
 	if (reps_info->flag != ZXDH_REPS_INFO_FLAG_USED) {
 		PMD_MSG_LOG(ERR, "msg_id: %u is released", msg_header->msg_id);
-- 
2.27.0
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mails.dpdk.org/archives/dev/attachments/20261116/3839dfa4/attachment.htm>


More information about the dev mailing list