diff mbox series

ice: release the VF reference in the switchdev trust path

Message ID 20261103100530.1309907-1-vulab@iscas.ac.cn
State New
Headers show
Series ice: release the VF reference in the switchdev trust path | expand

Commit Message

Wentao Liang Nov. 3, 2026, 10:05 a.m. UTC
ice_set_vf_trust() takes a reference on the VF with ice_get_vf_by_id()
and then rejects the request when the PF is in switchdev mode without
dropping that reference.

Return through the existing out_put_vf label so the VF reference is
released on this path too.

Fixes: 1281b7459657 ("ice: Forbid trusted VFs in switchdev mode")
Cc: stable@vger.kernel.org
Assisted-by: DeepSeek-V4.1-Flash and OpenAI Codex
Signed-off-by: Wentao Liang <vulab@iscas.ac.cn>
---
 drivers/net/ethernet/intel/ice/ice_sriov.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Comments

Krzysztof Kozlowski Nov. 3, 2026, 10:25 a.m. UTC | #1
On Tue, 03 Nov 2026 10:05:30 +0000, Wentao Liang wrote:
> ice_set_vf_trust() takes a reference on the VF with ice_get_vf_by_id()
> and then rejects the request when the PF is in switchdev mode without
> dropping that reference.
> 
> Return through the existing out_put_vf label so the VF reference is
> released on this path too.
> 
> Fixes: 1281b7459657 ("ice: Forbid trusted VFs in switchdev mode")
> Cc: stable@vger.kernel.org
> Assisted-by: DeepSeek-V4.1-Flash and OpenAI Codex
> Signed-off-by: Wentao Liang <vulab@iscas.ac.cn>
> ---
>  drivers/net/ethernet/intel/ice/ice_sriov.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 



Multiple things here:
1. Your team ignored completely previous feedback. Multiple times.

2. You use multiple identities with this email address, thus I doubt that we
   speak with an actual person.

3. Your bot does not even bother running checkpatch, right?

4. Nothing of this was reproduced nor tested.

5. Finally, the same feedback:
You sent multiple independent patches, to multiple independent
subsystems. The amount of these patches clearly suggest this was
AI generated and most likely not tested.

More importantly, you sent all this work without properly organizing
relevant patches into patchsets. This makes reviewing difficult
and might cause multiple reviewers to address the same issue.
Replying to the entire set is impossible and requires handling each
patch independently, instead of applying or discarding the set.
Maintainers also won't see the bigger picture of your work. Quite
worrying.

This is on the verge of hostile patch: bomb us with so many
contributions, we won't be able to handle them in efficient manner,
like responding ONCE to ask you to slow down.  Considering all this
is untested and LLM generated, I have even more doubts whether this
should be considered for review.

Please read kernel documentation BEFORE posting more work. It will
explain you how to identify subsystems, how to organize your work per
subsystem (so a patchset grouping multiple patches with a short cover
letter), how to document the issue discovery method and what was
or was not tested.

Best regards,
Krzysztof
sashiko-bot@kernel.org Nov. 4, 2026, 10:11 a.m. UTC | #2
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Low] ice: incorrect Fixes tag in commit message for ice_set_vf_trust() leak fix
--

commit 42da2ece24c78562b789e051c2ce4c73f6f2c81d
Author: Wentao Liang <vulab@iscas.ac.cn>

ice: release the VF reference in the switchdev trust path

This commit updates ice_set_vf_trust() to jump to the out_put_vf label so
that the VF reference acquired by ice_get_vf_by_id() is released when
rejecting trust changes in switchdev mode.

>     ice: release the VF reference in the switchdev trust path
>     
>     ice_set_vf_trust() takes a reference on the VF with ice_get_vf_by_id()
>     and then rejects the request when the PF is in switchdev mode without
>     dropping that reference.
>     
>     Return through the existing out_put_vf label so the VF reference is
>     released on this path too.
>     
>     Fixes: 1281b7459657 ("ice: Forbid trusted VFs in switchdev mode")
>     Cc: stable@vger.kernel.org
>     Assisted-by: DeepSeek-V4.1-Flash and OpenAI Codex
>     Signed-off-by: Wentao Liang <vulab@iscas.ac.cn>

[Severity: Low]
In drivers/net/ethernet/intel/ice/ice_sriov.c, commit 1281b7459657 ("ice:
Forbid trusted VFs in switchdev mode") placed the
ice_is_eswitch_mode_switchdev(pf) check at the start of ice_set_vf_trust()
prior to looking up the VF. Even after commit 3d5985a185e6 ("ice: convert VF
storage to hash table with krefs and RCU") introduced ice_get_vf_by_id() and
the out_put_vf label, ice_get_vf_by_id() was still called after the switchdev
mode check.

The VF reference leak when ice_is_eswitch_mode_switchdev(pf) is true was
introduced by commit 83b49e7f63da ("ice: check if VF exists before mode
check"), which moved vf = ice_get_vf_by_id(pf, vf_id) above the
ice_is_eswitch_mode_switchdev(pf) check without updating the return
-EOPNOTSUPP path to jump to out_put_vf. Backporting this patch to stable
trees containing 1281b7459657 or 3d5985a185e6 without 83b49e7f63da would jump
to out_put_vf before vf is initialized.

Should the Fixes tag reference commit 83b49e7f63da ("ice: check if VF exists
before mode check") instead?
netdev-bot+sashiko@kernel.org Nov. 7, 2026, 11:50 a.m. UTC | #3
Thank you for your contribution! Sashiko AI review found 1 potential
issue(s) to consider.

Critical: 0 · High: 0 · Medium: 1 · Low: 0

If you believe none of the issues are legitimate, please reply to each
issue of Medium severity or higher and explain why the AI is wrong.
If any of them are legitimate and you plan to respin, please let patchwork
know by including "pw-bot: cr" as a separate line at the end of your reply
(one such reply per series is enough).

- [Medium] The Fixes: tag in commit "ice: release the VF reference in the
  switchdev trust path" points at the wrong commit.

--

ice: release the VF reference in the switchdev trust path

In ice_set_vf_trust(), the VF reference taken by ice_get_vf_by_id() was
not dropped when the request was rejected because the PF is in switchdev
mode. This patch sends that path through the existing out_put_vf label
so ice_put_vf() is called.

> ice: release the VF reference in the switchdev trust path
>
> ice_set_vf_trust() takes a reference on the VF with ice_get_vf_by_id()
> and then rejects the request when the PF is in switchdev mode without
> dropping that reference.
>
> Return through the existing out_put_vf label so the VF reference is
> released on this path too.
>
> Fixes: 1281b7459657 ("ice: Forbid trusted VFs in switchdev mode")

[Severity: Medium]
Is this the right commit for the Fixes: tag?

When 1281b7459657 added the switchdev check, it was at the very top of
ice_set_vf_trust(), before any VF lookup. VF refcounting (3d5985a185e6)
did not exist yet, so the bare return did not leak anything.

The leak seems to come from 83b49e7f63da ("ice: check if VF exists before
mode check"). That commit moved the lookup above the switchdev check and
did not change the early return:

    +	vf = ice_get_vf_by_id(pf, vf_id);
    +	if (!vf)
    +		return -EINVAL;
    +
     	if (ice_is_eswitch_mode_switchdev(pf)) {
     		dev_info(ice_pf_to_dev(pf), "Trusted VF is forbidden in switchdev mode\n");
     		return -EOPNOTSUPP;
     	}

    -	vf = ice_get_vf_by_id(pf, vf_id);
    -	if (!vf)
    -		return -EINVAL;
    -

With Cc: stable, the current tag would aim at trees that have
1281b7459657 but not 83b49e7f63da. Those trees do not have the leak.
There, ice_get_vf_by_id() still comes after the switchdev check, so a
fuzzed backport would add a goto out_put_vf that runs before vf is
assigned.

Should this be the following instead?

    Fixes: 83b49e7f63da ("ice: check if VF exists before mode check")

The phrase "takes a reference on the VF with ice_get_vf_by_id() and then
rejects the request" also reads as if the check has always leaked. That
has only been true since 83b49e7f63da.

> Cc: stable@vger.kernel.org
> Assisted-by: DeepSeek-V4.1-Flash and OpenAI Codex
> Signed-off-by: Wentao Liang <vulab@iscas.ac.cn>

> diff --git a/drivers/net/ethernet/intel/ice/ice_sriov.c b/drivers/net/ethernet/intel/ice/ice_sriov.c
> index c49f48b5ae38c..90bf1becbc3da 100644
> --- a/drivers/net/ethernet/intel/ice/ice_sriov.c
> +++ b/drivers/net/ethernet/intel/ice/ice_sriov.c
> @@ -1400,7 +1400,8 @@ int ice_set_vf_trust(struct net_device *netdev, int vf_id, bool trusted)
>
>  	if (ice_is_eswitch_mode_switchdev(pf)) {
>  		dev_info(ice_pf_to_dev(pf), "Trusted VF is forbidden in switchdev mode\n");
> -		return -EOPNOTSUPP;
> +		ret = -EOPNOTSUPP;
> +		goto out_put_vf;
>  	}
>
>  	ret = ice_check_vf_ready_for_cfg(vf);
diff mbox series

Patch

diff --git a/drivers/net/ethernet/intel/ice/ice_sriov.c b/drivers/net/ethernet/intel/ice/ice_sriov.c
index c49f48b5ae38..90bf1becbc3d 100644
--- a/drivers/net/ethernet/intel/ice/ice_sriov.c
+++ b/drivers/net/ethernet/intel/ice/ice_sriov.c
@@ -1400,7 +1400,8 @@  int ice_set_vf_trust(struct net_device *netdev, int vf_id, bool trusted)
 
 	if (ice_is_eswitch_mode_switchdev(pf)) {
 		dev_info(ice_pf_to_dev(pf), "Trusted VF is forbidden in switchdev mode\n");
-		return -EOPNOTSUPP;
+		ret = -EOPNOTSUPP;
+		goto out_put_vf;
 	}
 
 	ret = ice_check_vf_ready_for_cfg(vf);