Intel-Wired-Lan Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Ayush Yaduvanshi" <ayush37735@gmail.com>
Cc: intel-wired-lan@lists.osuosl.org
Subject: Re: [PATCH] net: intel: ice: Modernize ice_vsi_free() with scope-based guard(mutex)
Date: Thu, 15 Oct 2026 11:06:35 +0000	[thread overview]
Message-ID: <sashiko-outbox-172717@kernel.org> (raw)
In-Reply-To: <20261014110552.56976-1-ayush37735@gmail.com>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] net: ice: TOCTOU race in ice_vsi_free() leads to UAF and double-free
--

commit e281bf0eed51082082d6b00b9ef0752bccc1ae10
Author: Ayush Yaduvanshi <ayush37735@gmail.com>

net: intel: ice: Modernize ice_vsi_free() with scope-based guard(mutex)

This commit updates ice_vsi_free() to use a scope-based guard for
pf->sw_mutex instead of explicit mutex_lock() and mutex_unlock() calls.

> diff --git a/drivers/net/ethernet/intel/ice/ice_lib.c b/drivers/net/ethernet/intel/ice/ice_lib.c
> index 9e08db376d3d0..c695df4428223 100644
> --- a/drivers/net/ethernet/intel/ice/ice_lib.c
> +++ b/drivers/net/ethernet/intel/ice/ice_lib.c
> @@ -457,7 +457,7 @@ void ice_vsi_free(struct ice_vsi *vsi)
>  		return;
>  	}
>  
> -	mutex_lock(&pf->sw_mutex);
> +	guard(mutex)(&pf->sw_mutex);

[Severity: High]
Can this sequence lead to a use-after-free and double-free?

The validity check just before this lock is performed outside the mutex:

    if (!pf->vsi[vsi->idx] || pf->vsi[vsi->idx] != vsi) {
        ...
        return;
    }

Does this create a race condition where two threads can bypass the check
concurrently, serialize on pf->sw_mutex, and cause the second thread to
dereference and double-free the VSI after the first thread clears it?

>  	/* updates the PF for this cleared VSI */
>  
>  	pf->vsi[vsi->idx] = NULL;

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261014110552.56976-1-ayush37735@gmail.com?part=1

      parent reply	other threads:[~2026-10-15 11:06 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-14 11:05 [PATCH] net: intel: ice: Modernize ice_vsi_free() with scope-based guard(mutex) Ayush Yaduvanshi
2026-10-14 16:36 ` Kohei Enju
2026-10-14 20:22   ` Andrew Lunn
2026-10-15 11:06 ` sashiko-bot [this message]

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=sashiko-outbox-172717@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=ayush37735@gmail.com \
    --cc=intel-wired-lan@lists.osuosl.org \
    --cc=sashiko-reviews@lists.linux.dev \
    /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