From: sashiko-bot@kernel.org
To: "Emil Tantilov" <emil.s.tantilov@intel.com>
Cc: intel-wired-lan@lists.osuosl.org
Subject: Re: [PATCH iwl-net 2/2] idpf: release PTP before freeing vports on the init task error path
Date: Fri, 09 Oct 2026 21:56:54 +0000 [thread overview]
Message-ID: <sashiko-outbox-166100@kernel.org> (raw)
In-Reply-To: <20261009212537.3996-3-emil.s.tantilov@intel.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] idpf: double free of adapter->ptp due to concurrent idpf_ptp_release()
--
commit 140d271eb2e765967ee1a351714e7ad1ecc7d8f6
Author: Emil Tantilov <emil.s.tantilov@intel.com>
idpf: release PTP before freeing vports on the init task error path
Release PTP, which cancels the aux worker, before the unwind frees the
vports, matching the idpf_vc_core_deinit() order. Previously it was
possible for idpf_ptp_update_cached_phctime() which runs via the PTP
auxiliary worker to read a non-NULL but already freed slot, pass its NULL
check, and dereference the freed vport.
> diff --git a/drivers/net/ethernet/intel/idpf/idpf_lib.c b/drivers/net/ethernet/intel/idpf/idpf_lib.c
> index a1c739cdd5406..9c541dd6ed4d4 100644
> --- a/drivers/net/ethernet/intel/idpf/idpf_lib.c
> +++ b/drivers/net/ethernet/intel/idpf/idpf_lib.c
> @@ -1747,6 +1747,8 @@ void idpf_init_task(struct work_struct *work)
> return;
>
> unwind_vports:
> + idpf_ptp_release(adapter);
> +
[Severity: High]
Does this create a race condition that can result in a double free of
adapter->ptp?
If idpf_remove() or a hard reset is triggered, it invokes idpf_vc_core_deinit().
idpf_vc_core_deinit() calls idpf_ptp_release() before it calls
idpf_deinit_task(), which is what cancels this init_task:
drivers/net/ethernet/intel/idpf/idpf_virtchnl.c:idpf_vc_core_deinit() {
...
idpf_ptp_release(adapter);
idpf_deinit_task(adapter);
...
}
Concurrently, if this asynchronous idpf_init_task() fails during
initialization, its error path (unwind_vports) also calls idpf_ptp_release()
without locking or serialization against concurrent teardown.
idpf_ptp_release() performs an unlocked check-and-free:
drivers/net/ethernet/intel/idpf/idpf_ptp.c:idpf_ptp_release() {
struct idpf_ptp *ptp = adapter->ptp;
if (!ptp)
return;
...
kfree(ptp);
adapter->ptp = NULL;
}
If both threads execute this concurrently, could both read the non-NULL pointer,
leading to concurrent executions of ptp_clock_unregister() and a double free
via kfree(ptp)?
> if (default_vport) {
> for (index = 0; index < adapter->max_vports; index++) {
> if (adapter->vports[index])
[ ... ]
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261009212537.3996-1-emil.s.tantilov@intel.com?part=2
next prev parent reply other threads:[~2026-10-09 21:57 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-09 21:25 [PATCH iwl-net 0/2] idpf: fix use-after-free in PTP auxiliary worker Emil Tantilov
2026-10-09 21:25 ` [PATCH iwl-net 1/2] idpf: fix use-after-free in the " Emil Tantilov
2026-10-09 21:25 ` [PATCH iwl-net 2/2] idpf: release PTP before freeing vports on the init task error path Emil Tantilov
2026-10-09 21:56 ` sashiko-bot [this message]
2026-10-13 16:41 ` Tantilov, Emil S
2026-10-13 17:15 ` Tantilov, Emil S
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-166100@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=emil.s.tantilov@intel.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