Netdev List
 help / color / mirror / Atom feed
From: Jose Ignacio Tornos Martinez <jtornosm@redhat.com>
To: kuba@kernel.org
Cc: aleksandr.loktionov@intel.com, andrew+netdev@lunn.ch,
	anthony.l.nguyen@intel.com, davem@davemloft.net,
	edumazet@google.com, horms@kernel.org, jacob.e.keller@intel.com,
	jtornosm@redhat.com, netdev@vger.kernel.org, pabeni@redhat.com,
	przemyslaw.kitszel@intel.com, rafal.romanowski@intel.com,
	sdf@fomichev.me, stable@vger.kernel.org
Subject: Re: [PATCH net 2/4] i40e: skip unnecessary VF reset when setting trust
Date: Tue, 15 Sep 2026 10:14:36 +0200	[thread overview]
Message-ID: <20260915081436.14176-1-jtornosm@redhat.com> (raw)
In-Reply-To: <20260824190147.2714513-1-kuba@kernel.org>

All the comments below fall into pre-existing issues, concerns already
addressed in previous versions and comments, out-of-scope items, or extreme
edge cases. No code changes are considered necessary for a new version.
Details for each comment:

> [Severity: Medium]
> This helper writes I40E_VIRTCHNL_VF_CAP_PRIVILEGE from the ndo (rtnl)
> context. i40e_alloc_vf_res() derives the same bit from an unsynchronized
> read of vf->trusted.
>
> If that path reads vf->trusted and is preempted before the
> set_bit()/clear_bit(), can i40e_ndo_set_vf_trust() update vf->trusted and
> call i40e_setup_vf_trust() in between, so the stale write lands last? That
> would leave vf->trusted true with the capability bit clear, or vf->trusted
> false with the bit still set.
>
> Before this patch the ndo always followed the vf->trusted update with
> i40e_vc_reset_vf(), so the bit was recomputed from the final value of
> vf->trusted. With the reset skipped, is anything left that reconciles the
> two?

Pre-existing race. The original code writes vf->trusted before calling
i40e_vc_reset_vf() without synchronization against VFLR-initiated resets
from the service task. This patch does not change the synchronization
model and the race window is the same order of magnitude (a few
instructions). The scenario requires a guest-initiated VFLR at the exact
moment of the trust change, extremely difficult to reproduce in practice.

> [Severity: High]
> Does this condition need to consider the MAC and VLAN filters that the VF
> was only allowed to install because it was trusted?
>
> Trust is checked at add time only. Nothing revalidates filters that are
> already installed when the privilege bit is dropped.
>
> Can the __I40E_MACVLAN_SYNC_PENDING work repair this instead? Looking at
> i40e_correct_vf_mac_vlan_filters() it only recomputes the VLAN id of
> existing entries, so no MAC filter is deleted on trust loss.
>
> There is also a functional side effect: mac_add_max drops back to 18 while
> i40e_count_active_filters(vsi) still reflects the trusted-era filters, so
> every later VIRTCHNL_OP_ADD_ETH_ADDR from that VF fails with -EPERM,
> including a re-add of its primary MAC after a guest link down/up.

Same concern addressed in previous comments. Over-limit filters configured
while trusted remain after trust revocation, but this is acceptable because
untrusted VFs can freely delete their own MAC and VLAN filters, there are
no trust checks in i40e_vc_del_mac_addr_msg() or i40e_vc_remove_vlan_msg().
The VF simply cannot add more over-limit filters.

The permission check uses i40e_count_active_filters(vsi) which counts live
filters, deletions reduce the count immediately. The "primary MAC re-add
after link down/up" scenario does not apply: existing filters remain in
place across link events. A guest-initiated VF reset cleans up everything
via i40e_free_vf_res().

> [Severity: Medium]
> Can this sample of VF-controlled state race with the virtchnl handlers that
> write it? i40e_vc_process_vf_msg() is called from
> i40e_clean_adminq_subtask() in service task context without rtnl_lock() and
> without taking __I40E_VIRTCHNL_OP_PENDING, so it does not exclude this ndo.
>
> Does that leave an untrusted VF promiscuous indefinitely? The same ordering
> appears in i40e_vc_add_cloud_filter() and i40e_vc_add_qch_msg().

Same concern addressed in previous comments. This race condition exists in
the original code as well, vf->trusted is set before i40e_vc_reset_vf(),
creating the same window where the VF can install privileged state while
the capability bit is still set. This patch does not introduce this race,
it inherits the same synchronization model. Extremely difficult to
reproduce in practice.

Fixing this requires changing the broader synchronization between ndo
callbacks and virtchnl processing, which is beyond the scope of this patch.

> [Severity: Medium]
> This is a pre-existing issue and not introduced by this patch, but
> i40e_vc_reset_vf() is void and can return having done nothing.
>
> Would calling i40e_setup_vf_trust(vf, setting) unconditionally, before the
> branch, make both artifacts deterministic?

Pre-existing issue not introduced by this patch, as the reviewer correctly
identifies. The current structure keeps the logic clear: the else branch
handles the no-reset case, the if branch delegates everything to the reset
path.

> [Severity: Medium]
> The reset releases the ADQ channel VSIs and i40e_alloc_vf_res() re-creates
> them with newly assigned seids. i40e_del_all_cloud_filters() then looks
> the VSI up by the recorded seid. If the seid changed, the teardown takes
> the error path and the hlist_del(), kfree(cfilter) and
> vf->num_cloud_filters decrement are all skipped. Does this leak the
> struct i40e_cloud_filter allocations?

Pre-existing issue, the same ordering (reset before cloud filter deletion)
existed in the original code. This patch restructures the control flow
but preserves the same sequence.


  reply	other threads:[~2026-09-15  8:14 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-21 20:45 [PATCH net 0/4][pull request] Fix i40e/ice/iavf VF bonding after netdev lock changes Tony Nguyen
2026-08-21 20:45 ` [PATCH net 1/4] iavf: return EBUSY if reset in progress or not ready during MAC change Tony Nguyen
2026-08-24 19:01   ` Jakub Kicinski
2026-09-15  8:12     ` Jose Ignacio Tornos Martinez
2026-09-15 16:24       ` Jakub Kicinski
2026-09-16 10:12         ` Jose Ignacio Tornos Martinez
2026-09-25  7:18         ` Jose Ignacio Tornos Martinez
2026-09-25 19:04           ` Jakub Kicinski
2026-08-21 20:45 ` [PATCH net 2/4] i40e: skip unnecessary VF reset when setting trust Tony Nguyen
2026-08-24 19:01   ` Jakub Kicinski
2026-09-15  8:14     ` Jose Ignacio Tornos Martinez [this message]
2026-08-21 20:45 ` [PATCH net 3/4] iavf: send MAC change request synchronously Tony Nguyen
2026-08-24 19:01   ` Jakub Kicinski
2026-09-15  8:16     ` Jose Ignacio Tornos Martinez
2026-08-21 20:45 ` [PATCH net 4/4] ice: skip unnecessary VF reset when setting trust Tony Nguyen
2026-08-24 19:01   ` Jakub Kicinski
2026-09-15  8:19     ` Jose Ignacio Tornos Martinez

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=20260915081436.14176-1-jtornosm@redhat.com \
    --to=jtornosm@redhat.com \
    --cc=aleksandr.loktionov@intel.com \
    --cc=andrew+netdev@lunn.ch \
    --cc=anthony.l.nguyen@intel.com \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=horms@kernel.org \
    --cc=jacob.e.keller@intel.com \
    --cc=kuba@kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=przemyslaw.kitszel@intel.com \
    --cc=rafal.romanowski@intel.com \
    --cc=sdf@fomichev.me \
    --cc=stable@vger.kernel.org \
    /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