Checks
Context | Check | Description |
---|---|---|
ci/checkpatch | success | coding style OK |
ci/Intel-compilation | success | Compilation OK |
Commit Message
Xiaolong Ye
Dec. 2, 2019, 7:49 a.m. UTC
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@intel.com> Reviewed-by: Paul M Stillwell Jr <paul.m.stillwell.jr@intel.com> Reviewed-by: Kirsher Jeffrey T <jeffrey.t.kirsher@intel.com> Signed-off-by: Xiaolong Ye <xiaolong.ye@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;