Intel-Wired-Lan Archive on lore.kernel.org
 help / color / mirror / Atom feed
* Re: [PATCH v1] i40e: Lock VF cloud filter list operations
       [not found] <20261020025856.519623-1-18983559317@163.com>
@ 2026-10-20 22:11 ` kernel test robot
  2026-10-21  2:59 ` sashiko-bot
  1 sibling, 0 replies; 2+ messages in thread
From: kernel test robot @ 2026-10-20 22:11 UTC (permalink / raw)
  To: Binbin Deng, anthony.l.nguyen, przemyslaw.kitszel, andrew+netdev,
	davem, edumazet, kuba, pabeni
  Cc: llvm, oe-kbuild-all, intel-wired-lan, netdev, linux-kernel,
	Binbin Deng

Hi Binbin,

kernel test robot noticed the following build warnings:

[auto build test WARNING on tnguy-next-queue/dev-queue]
[also build test WARNING on tnguy-net-queue/dev-queue linus/master v7.3 next-20261019]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Binbin-Deng/i40e-Lock-VF-cloud-filter-list-operations/20261020-105856
base:   https://git.kernel.org/pub/scm/linux/kernel/git/tnguy/next-queue.git dev-queue
patch link:    https://lore.kernel.org/r/20261020025856.519623-1-18983559317%40163.com
patch subject: [PATCH v1] i40e: Lock VF cloud filter list operations
config: loongarch-defconfig (https://download.01.org/0day-ci/archive/20261021/202610210619.K13qhCpp-lkp@intel.com/config)
compiler: clang version 24.0.0git (https://github.com/llvm/llvm-project 2c419645e808a6667eee9dbb16c828f77e2fd2f0)
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20261021/202610210619.K13qhCpp-lkp@intel.com/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202610210619.K13qhCpp-lkp@intel.com/

All warnings (new ones prefixed by >>):

>> Warning: drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c:3739 function parameter 'i40e_vf_cloud_filter_lock' not described in 'DEFINE_MUTEX'
>> Warning: drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c:3739 expecting prototype for i40e_del_all_cloud_filters(). Prototype was for DEFINE_MUTEX() instead

--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH v1] i40e: Lock VF cloud filter list operations
       [not found] <20261020025856.519623-1-18983559317@163.com>
  2026-10-20 22:11 ` [PATCH v1] i40e: Lock VF cloud filter list operations kernel test robot
@ 2026-10-21  2:59 ` sashiko-bot
  1 sibling, 0 replies; 2+ messages in thread
From: sashiko-bot @ 2026-10-21  2:59 UTC (permalink / raw)
  To: Binbin Deng; +Cc: intel-wired-lan

Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [High] i40e: TOCTOU race and VSI UAF in i40e_vc_add_cloud_filter() and reset
- [Low] i40e: mutex definition breaks kernel-doc for i40e_del_all_cloud_filters()
--

commit 03ab6f762cec8d24f3f9bbef8a127d3ed4ca9ef7
Author: Binbin Deng <18983559317@163.com>

i40e: Lock VF cloud filter list operations

This commit adds a file-local mutex, i40e_vf_cloud_filter_lock, to serialize
VF cloud filter additions, deletions, and bulk removals across
i40e_vc_add_cloud_filter(), i40e_vc_del_cloud_filter(), and
i40e_del_all_cloud_filters().

> diff --git a/drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c b/drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c
> index c6732a24b6400..d62e59c7ac814 100644
> --- a/drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c
> +++ b/drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c
> @@ -3740,6 +3740,8 @@ static struct i40e_vsi *i40e_find_vsi_from_seid(struct i40e_vf *vf, u16 seid)
>   *
>   * This function deletes all cloud filters
>   **/
> +static DEFINE_MUTEX(i40e_vf_cloud_filter_lock);
> +
>  static void i40e_del_all_cloud_filters(struct i40e_vf *vf)

[Severity: Low]
Will placing DEFINE_MUTEX(i40e_vf_cloud_filter_lock) between the kernel-doc
comment block and i40e_del_all_cloud_filters() cause scripts/kernel-doc to
emit a warning?

 Because DEFINE_MUTEX() sits immediately after the closing **/ of the comment,
kernel-doc parses DEFINE_MUTEX() as the documented prototype instead of
i40e_del_all_cloud_filters().

[ ... ]

> @@ -3856,6 +3860,7 @@ static int i40e_vc_del_cloud_filter(struct i40e_vf *vf, u8 *msg)
>  	}
>  
>  	/* get the vsi to which the tc belongs to */
> +	mutex_lock(&i40e_vf_cloud_filter_lock);
>  	vsi = pf->vsi[vf->ch[vcf->action_meta].vsi_idx];
>  	cfilter.seid = vsi->seid;
>  	cfilter.flags = vcf->field_flags;

[ ... ]

> @@ -4002,6 +4009,7 @@ static int i40e_vc_add_cloud_filter(struct i40e_vf *vf, u8 *msg)
>  	}
>  
>  	/* get the VSI to which the TC belongs to */
> +	mutex_lock(&i40e_vf_cloud_filter_lock);
>  	vsi = pf->vsi[vf->ch[vcf->action_meta].vsi_idx];
>  	cfilter->seid = vsi->seid;
>  	cfilter->flags = vcf->field_flags;

[Severity: High]
Can i40e_vc_add_cloud_filter() and i40e_vc_del_cloud_filter() still race with
i40e_ndo_set_vf_trust() and dereference a NULL or freed struct i40e_vsi, or
install a cloud filter after trust has been revoked?

In both i40e_vc_add_cloud_filter() and i40e_vc_del_cloud_filter(), the checks
for i40e_sync_vf_state(vf, I40E_VF_STATE_ACTIVE), vf->adq_enabled,
i40e_validate_cloud_filter(vf, vcf), and vf->num_cloud_filters run before
acquiring i40e_vf_cloud_filter_lock.

Meanwhile, when host-side trust is revoked, i40e_ndo_set_vf_trust() resets the
VF outside i40e_vf_cloud_filter_lock before calling
i40e_del_all_cloud_filters():

drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c:i40e_ndo_set_vf_trust() {
	...
	if (!setting &&
	    (vf->adq_enabled || vf->num_cloud_filters > 0 ||
	     test_bit(I40E_VF_STATE_UC_PROMISC, &vf->vf_states) ||
	     test_bit(I40E_VF_STATE_MC_PROMISC, &vf->vf_states))) {
		i40e_vc_reset_vf(vf, true);
		i40e_del_all_cloud_filters(vf);
	}
	...
}

During i40e_vc_reset_vf() -> i40e_reset_vf() -> i40e_cleanup_reset_vf() ->
i40e_free_vf_res(), the ADq channel VSIs are released and their indices are
cleared without holding i40e_vf_cloud_filter_lock:

drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c:i40e_free_vf_res() {
	...
	if (vf->adq_enabled && vf->ch[0].vsi_idx) {
		for (j = 0; j < vf->num_tc; j++) {
			if (j)
				i40e_vsi_release(pf->vsi[vf->ch[j].vsi_idx]);
			vf->ch[j].vsi_idx = 0;
			vf->ch[j].vsi_id = 0;
		}
	}
	...
}

If i40e_vc_add_cloud_filter() or i40e_vc_del_cloud_filter() passes the initial
unlocked validation checks and then executes:

	mutex_lock(&i40e_vf_cloud_filter_lock);
	vsi = pf->vsi[vf->ch[vcf->action_meta].vsi_idx];
	cfilter->seid = vsi->seid;

concurrently with i40e_vc_reset_vf(), vsi can be NULL or already freed by
i40e_vsi_release(), or vf->ch[vcf->action_meta].vsi_idx can be zeroed so that
pf->vsi[0] (the PF main VSI) is used instead.

Additionally, if i40e_vc_add_cloud_filter() passes
i40e_validate_cloud_filter() before trust is revoked and acquires
i40e_vf_cloud_filter_lock after both i40e_vc_reset_vf() and
i40e_del_all_cloud_filters() have finished, wouldn't it program the filter into
hardware and append cfilter to vf->cloud_filter_list for an untrusted VF?

[ ... ]

>

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261020025856.519623-1-18983559317@163.com?part=1

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-10-21  3:00 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <20261020025856.519623-1-18983559317@163.com>
2026-10-20 22:11 ` [PATCH v1] i40e: Lock VF cloud filter list operations kernel test robot
2026-10-21  2:59 ` sashiko-bot

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox