Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

ice: Fix virtchnl_queue_select bitmap validation

Currently in ice_vc_ena_qs_msg() we are incorrectly validating the
virtchnl queue select bitmaps. The virtchnl_queue_select rx_queues and
tx_queue bitmap is being compared against ICE_MAX_BASE_QS_PER_VF, but
the problem is that these bitmaps can have a value greater than
ICE_MAX_BASE_QS_PER_VF. Fix this by comparing the bitmaps against
BIT(ICE_MAX_BASE_QS_PER_VF).

Also, add the function ice_vc_validate_vqs_bitmaps() that checks to see
if both virtchnl_queue_select bitmaps are empty along with checking that
the bitmaps only have valid bits set. This function can then be used in
both the queue enable and disable flows.

Arkady Gilinksky's patch on the intel-wired-lan mailing list
("i40e/iavf: Fix msg interface between VF and PF") made me
aware of this issue.

Signed-off-by: Brett Creeley <brett.creeley@intel.com>
Tested-by: Andrew Bowers <andrewx.bowers@intel.com>
Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com>

authored by

Brett Creeley and committed by
Jeff Kirsher
24e2e2a0 e1fe6926

+18 -8
+18 -8
drivers/net/ethernet/intel/ice/ice_virtchnl_pf.c
··· 2071 2071 } 2072 2072 2073 2073 /** 2074 + * ice_vc_validate_vqs_bitmaps - validate Rx/Tx queue bitmaps from VIRTCHNL 2075 + * @vqs: virtchnl_queue_select structure containing bitmaps to validate 2076 + * 2077 + * Return true on successful validation, else false 2078 + */ 2079 + static bool ice_vc_validate_vqs_bitmaps(struct virtchnl_queue_select *vqs) 2080 + { 2081 + if ((!vqs->rx_queues && !vqs->tx_queues) || 2082 + vqs->rx_queues >= BIT(ICE_MAX_BASE_QS_PER_VF) || 2083 + vqs->tx_queues >= BIT(ICE_MAX_BASE_QS_PER_VF)) 2084 + return false; 2085 + 2086 + return true; 2087 + } 2088 + 2089 + /** 2074 2090 * ice_vc_ena_qs_msg 2075 2091 * @vf: pointer to the VF info 2076 2092 * @msg: pointer to the msg buffer ··· 2113 2097 goto error_param; 2114 2098 } 2115 2099 2116 - if (!vqs->rx_queues && !vqs->tx_queues) { 2117 - v_ret = VIRTCHNL_STATUS_ERR_PARAM; 2118 - goto error_param; 2119 - } 2120 - 2121 - if (vqs->rx_queues > ICE_MAX_BASE_QS_PER_VF || 2122 - vqs->tx_queues > ICE_MAX_BASE_QS_PER_VF) { 2100 + if (!ice_vc_validate_vqs_bitmaps(vqs)) { 2123 2101 v_ret = VIRTCHNL_STATUS_ERR_PARAM; 2124 2102 goto error_param; 2125 2103 } ··· 2203 2193 goto error_param; 2204 2194 } 2205 2195 2206 - if (!vqs->rx_queues && !vqs->tx_queues) { 2196 + if (!ice_vc_validate_vqs_bitmaps(vqs)) { 2207 2197 v_ret = VIRTCHNL_STATUS_ERR_PARAM; 2208 2198 goto error_param; 2209 2199 }