Netdev List
 help / color / mirror / Atom feed
From: Changyul Lee <lcy8047@gmail.com>
To: Tony Nguyen <anthony.l.nguyen@intel.com>,
	Przemek Kitszel <przemyslaw.kitszel@intel.com>
Cc: Andrew Lunn <andrew+netdev@lunn.ch>,
	"David S. Miller" <davem@davemloft.net>,
	Eric Dumazet <edumazet@kernel.org>,
	Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
	intel-wired-lan@lists.osuosl.org, netdev@vger.kernel.org,
	linux-kernel@vger.kernel.org, Changyul Lee <lcy8047@gmail.com>
Subject: [PATCH iwl-net] i40e: hold mac_filter_hash_lock while validating VF cloud filters
Date: Mon, 16 Nov 2026 22:15:53 -0500	[thread overview]
Message-ID: <20261117031553.1728084-1-lcy8047@gmail.com> (raw)

i40e_validate_cloud_filter() runs in the VF message path, which holds
neither RTNL nor vsi->mac_filter_hash_lock. It looks up the destination
MAC with i40e_find_mac() and walks vsi->mac_filter_hash for the VLAN
without the lock. Meanwhile the host can change the VF MAC or port VLAN
with i40e_ndo_set_vf_mac() or i40e_ndo_set_vf_port_vlan(), which delete
filters under the lock and free them in __i40e_del_filter() or
i40e_sync_vsi_filters(). The lookup and the walk can then read a freed
struct i40e_mac_filter.

Do the lookup and the walk under mac_filter_hash_lock, as
i40e_vc_add_mac_addr_msg() does, and do not use the filter after
dropping the lock.

Fixes: e284fc280473 ("i40e: Add and delete cloud filter")
Signed-off-by: Changyul Lee <lcy8047@gmail.com>
---
Found with a static analysis tool we are developing.

Compile-tested only, with x86_64_defconfig plus PCI_IOV, I40E and W=1.

 drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c b/drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c
index 74b6c0ed8480..da1f1a9c4124 100644
--- a/drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c
+++ b/drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c
@@ -3624,9 +3624,11 @@ static int i40e_validate_cloud_filter(struct i40e_vf *vf,
 	 */
 	if (mask.dst_mac[0] && !mask.dst_ip[0]) {
 		vsi = pf->vsi[vf->lan_vsi_idx];
+		spin_lock_bh(&vsi->mac_filter_hash_lock);
 		f = i40e_find_mac(vsi, data.dst_mac);
 
 		if (!f) {
+			spin_unlock_bh(&vsi->mac_filter_hash_lock);
 			dev_info(&pf->pdev->dev,
 				 "Destination MAC %pM doesn't belong to VF %d\n",
 				 data.dst_mac, vf->vf_id);
@@ -3641,6 +3643,10 @@ static int i40e_validate_cloud_filter(struct i40e_vf *vf,
 					break;
 				}
 			}
+		}
+		spin_unlock_bh(&vsi->mac_filter_hash_lock);
+
+		if (mask.vlan_id) {
 			if (!found) {
 				dev_info(&pf->pdev->dev,
 					 "VF %d doesn't have any VLAN id %u\n",

base-commit: 7475ea8b58616b33c04afb976cf0fbaad9dd63fb
-- 
2.43.0


                 reply	other threads:[~2026-11-17  3:15 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261117031553.1728084-1-lcy8047@gmail.com \
    --to=lcy8047@gmail.com \
    --cc=andrew+netdev@lunn.ch \
    --cc=anthony.l.nguyen@intel.com \
    --cc=davem@davemloft.net \
    --cc=edumazet@kernel.org \
    --cc=intel-wired-lan@lists.osuosl.org \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=przemyslaw.kitszel@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox