[dpdk-dev] [PATCH 68/69] net/i40e/base: add missing 0 length checks

Xiaolong Ye xiaolong.ye at intel.com
Mon Dec 2 08:49:34 CET 2019


Other RSS-related opcodes allow 0 as a valid length for the number of
elements in their variable-sized structs, so allow 0 for
VIRTCHNL_OP_CONFIG_RSS_KEY and VIRTCHNL_OP_CONFIG_RSS_LUT, too.

This avoids a situation where a struct with a number of elements of 0
must shrink the size of the default struct in order to pass the
virtchnl_vc_validate_vf_msg() validation.

Signed-off-by: Eric Joyner <eric.joyner at intel.com>
Reviewed-by: Paul M Stillwell Jr <paul.m.stillwell.jr at intel.com>
Reviewed-by: Kirsher Jeffrey T <jeffrey.t.kirsher at intel.com>
Signed-off-by: Xiaolong Ye <xiaolong.ye at intel.com>
---
 drivers/net/i40e/base/virtchnl.h | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/drivers/net/i40e/base/virtchnl.h b/drivers/net/i40e/base/virtchnl.h
index bc9043dde..dabeb79ba 100644
--- a/drivers/net/i40e/base/virtchnl.h
+++ b/drivers/net/i40e/base/virtchnl.h
@@ -1371,6 +1371,12 @@ virtchnl_vc_validate_vf_msg(struct virtchnl_version_info *ver, u32 v_opcode,
 		if (msglen >= valid_len) {
 			struct virtchnl_rss_key *vrk =
 				(struct virtchnl_rss_key *)msg;
+
+			if (vrk->key_len == 0) {
+				/* zero length is allowed as input */
+				break;
+			}
+
 			valid_len += vrk->key_len - 1;
 		}
 		break;
@@ -1379,6 +1385,12 @@ virtchnl_vc_validate_vf_msg(struct virtchnl_version_info *ver, u32 v_opcode,
 		if (msglen >= valid_len) {
 			struct virtchnl_rss_lut *vrl =
 				(struct virtchnl_rss_lut *)msg;
+
+			if (vrl->lut_entries == 0) {
+				/* zero entries is allowed as input */
+				break;
+			}
+
 			valid_len += vrl->lut_entries - 1;
 		}
 		break;
-- 
2.17.1



More information about the dev mailing list