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

i40e: Fix virtchnl_queue_select bitmap validation

Currently in i40e_vc_disable_queues_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_VF_QUEUES, but the problem is that
these bitmaps can have a value greater than I40E_MAX_VF_QUEUES.
Fix this by comparing the bitmaps against BIT(I40E_MAX_VF_QUEUES).

Also, add the function i40e_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.

Suggested-by: Arkady Gilinksky <arkady.gilinsky@harmonicinc.com>
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
d9d6a9ae 9546a0b7

+18 -4
+18 -4
drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c
··· 2322 2322 } 2323 2323 2324 2324 /** 2325 + * i40e_vc_validate_vqs_bitmaps - validate Rx/Tx queue bitmaps from VIRTHCHNL 2326 + * @vqs: virtchnl_queue_select structure containing bitmaps to validate 2327 + * 2328 + * Returns true if validation was successful, else false. 2329 + */ 2330 + static bool i40e_vc_validate_vqs_bitmaps(struct virtchnl_queue_select *vqs) 2331 + { 2332 + if ((!vqs->rx_queues && !vqs->tx_queues) || 2333 + vqs->rx_queues >= BIT(I40E_MAX_VF_QUEUES) || 2334 + vqs->tx_queues >= BIT(I40E_MAX_VF_QUEUES)) 2335 + return false; 2336 + 2337 + return true; 2338 + } 2339 + 2340 + /** 2325 2341 * i40e_vc_enable_queues_msg 2326 2342 * @vf: pointer to the VF info 2327 2343 * @msg: pointer to the msg buffer ··· 2362 2346 goto error_param; 2363 2347 } 2364 2348 2365 - if ((0 == vqs->rx_queues) && (0 == vqs->tx_queues)) { 2349 + if (i40e_vc_validate_vqs_bitmaps(vqs)) { 2366 2350 aq_ret = I40E_ERR_PARAM; 2367 2351 goto error_param; 2368 2352 } ··· 2424 2408 goto error_param; 2425 2409 } 2426 2410 2427 - if ((vqs->rx_queues == 0 && vqs->tx_queues == 0) || 2428 - vqs->rx_queues > I40E_MAX_VF_QUEUES || 2429 - vqs->tx_queues > I40E_MAX_VF_QUEUES) { 2411 + if (i40e_vc_validate_vqs_bitmaps(vqs)) { 2430 2412 aq_ret = I40E_ERR_PARAM; 2431 2413 goto error_param; 2432 2414 }