The PF handler for a VF's ZXDH_VLAN_FILTER_ADD/DEL message passes the<br />16-bit vlan_id from the message body to zxdh_vlan_filter_table_set()<br />without a range check. An id above 4095 becomes a row index outside<br />the VLAN filter groups the PF sets up for the function, and the NP<br />layer below only checks it against the end of the whole ERAM, so one<br />request from a guest reads, modifies and writes back unrelated table<br />rows.<br /> <br />Reject ids above RTE_ETHER_MAX_VLAN_ID where the value is taken out of<br />the message. Valid ids behave as before.<br /> <br />Fixes: b4f996b7fcf6 ("net/zxdh: optimize VLAN filter and offload")<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 4b01daf37a..f0f0522817 100644<br />--- a/drivers/net/zxdh/zxdh_msg.c<br />+++ b/drivers/net/zxdh/zxdh_msg.c<br />@@ -1552,7 +1552,12 @@ zxdh_vf_vlan_filter_table_process(struct zxdh_hw *hw, uint16_t vport,<br />     void *reply_data_addr = ZXDH_ADDR_OF(msg_reply_body, res_info, reply_data);<br />     int ret = 0;<br />  <br />-    ret = zxdh_vlan_filter_table_set(hw, vport, vlan_id, enable);<br />+    if (vlan_id > RTE_ETHER_MAX_VLAN_ID) {<br />+        PMD_DRV_LOG(ERR, "vlan id %d is invalid", vlan_id);<br />+        ret = -EINVAL;<br />+    } else {<br />+        ret = zxdh_vlan_filter_table_set(hw, vport, vlan_id, enable);<br />+    }<br />     if (ret)<br />         sprintf(str, "vlan filter op-code[%d] vlan id:%d failed, code:%d\n",<br />             enable, vlan_id, ret);<br />--  <br />2.27.0<br />