From: Tony Nguyen <anthony.l.nguyen@intel.com>
To: davem@davemloft.net, kuba@kernel.org, pabeni@redhat.com,
edumazet@kernel.org, andrew+netdev@lunn.ch, willemb@google.com,
netdev@vger.kernel.org
Cc: Emil Tantilov <emil.s.tantilov@intel.com>,
anthony.l.nguyen@intel.com, oss.patchbox@gmail.com,
tianxun.ng@bytedance.com, richardcochran@gmail.com,
milena.olech@intel.com, konstantin.ilichev@intel.com,
Madhu Chittim <madhu.chittim@intel.com>,
Naman Gulati <namangulati@google.com>,
Samuel Salin <Samuel.salin@intel.com>
Subject: [PATCH net 6/6] idpf: release PTP before freeing vports on the init task error path
Date: Wed, 25 Nov 2026 14:51:43 -0800 [thread overview]
Message-ID: <20261125225145.4126333-7-anthony.l.nguyen@intel.com> (raw)
In-Reply-To: <20261125225145.4126333-1-anthony.l.nguyen@intel.com>
From: Emil Tantilov <emil.s.tantilov@intel.com>
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. This can happen on driver load,
where any vport past the first fails to initialize:
BUG: KASAN: slab-use-after-free in idpf_ptp_update_cached_phctime+0x4ad/0x4d0 [idpf]
Read of size 8 at addr ff11002129215050 by task ptp3/10120
...
idpf_ptp_update_cached_phctime+0x4ad/0x4d0 [idpf]
idpf_ptp_do_aux_work+0x37/0x50 [idpf]
ptp_aux_kworker+0x64/0xd0
kthread_worker_fn+0x289/0xa20
...
Allocated by task 8820 on cpu 32 at 2113.761375s:
idpf_init_task+0x321/0x21c0 [idpf]a
process_one_work+0x917/0x1940
worker_thread+0x5a5/0xfe0
...
Freed by task 8820 on cpu 32 at 2113.809014s:
idpf_vport_dealloc+0x8cf/0x16b0 [idpf]
idpf_init_task+0x245/0x21c0 [idpf]
process_one_work+0x917/0x1940
worker_thread+0x5a5/0xfe0
The aux worker is armed in idpf_vc_core_init() before idpf_init_task() is
queued, so it is live throughout a failing init, leading to the scenario
above.
Fixes: 1a49cf814fe1 ("idpf: add Tx timestamp flows")
Reviewed-by: Madhu Chittim <madhu.chittim@intel.com>
Signed-off-by: Emil Tantilov <emil.s.tantilov@intel.com>
Reported-by: Konstantin Ilichev <konstantin.ilichev@intel.com>
Reviewed-by: Naman Gulati <namangulati@google.com>
Tested-by: Samuel Salin <Samuel.salin@intel.com>
Signed-off-by: Tony Nguyen <anthony.l.nguyen@intel.com>
---
drivers/net/ethernet/intel/idpf/idpf_lib.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/drivers/net/ethernet/intel/idpf/idpf_lib.c b/drivers/net/ethernet/intel/idpf/idpf_lib.c
index 38cb91beacd0..bf59d63bb7ec 100644
--- a/drivers/net/ethernet/intel/idpf/idpf_lib.c
+++ b/drivers/net/ethernet/intel/idpf/idpf_lib.c
@@ -1769,6 +1769,8 @@ void idpf_init_task(struct work_struct *work)
return;
unwind_vports:
+ idpf_ptp_release(adapter);
+
if (default_vport) {
for (index = 0; index < adapter->max_vports; index++) {
if (adapter->vports[index])
@@ -1782,7 +1784,6 @@ void idpf_init_task(struct work_struct *work)
cancel_delayed_work_sync(&adapter->serv_task);
cancel_delayed_work_sync(&adapter->mbx_task);
}
- idpf_ptp_release(adapter);
clear_bit(IDPF_HR_RESET_IN_PROG, adapter->flags);
}
--
2.47.1
next prev parent reply other threads:[~2026-11-25 22:52 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-25 22:51 [PATCH net 0/6][pull request] Intel Wired LAN Driver Updates 2026-11-25 (idpf) Tony Nguyen
2026-11-25 22:51 ` [PATCH net 1/6] idpf: Fix vport IRQ name leak on request failure Tony Nguyen
2026-11-25 22:51 ` [PATCH net 2/6] idpf: ignore Tx timestamp replies once removal has started Tony Nguyen
2026-11-25 22:51 ` [PATCH net 3/6] idpf: ignore link events " Tony Nguyen
2026-11-25 22:51 ` [PATCH net 4/6] idpf: keep the mailbox up while tearing down vports on shutdown Tony Nguyen
2026-11-25 22:51 ` [PATCH net 5/6] idpf: fix use-after-free in the PTP auxiliary worker Tony Nguyen
2026-11-25 22:51 ` Tony Nguyen [this message]
2026-11-25 22:58 ` [PATCH net 0/6][pull request] Intel Wired LAN Driver Updates 2026-11-25 (idpf) netdev-bot+sinfo
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=20261125225145.4126333-7-anthony.l.nguyen@intel.com \
--to=anthony.l.nguyen@intel.com \
--cc=Samuel.salin@intel.com \
--cc=andrew+netdev@lunn.ch \
--cc=davem@davemloft.net \
--cc=edumazet@kernel.org \
--cc=emil.s.tantilov@intel.com \
--cc=konstantin.ilichev@intel.com \
--cc=kuba@kernel.org \
--cc=madhu.chittim@intel.com \
--cc=milena.olech@intel.com \
--cc=namangulati@google.com \
--cc=netdev@vger.kernel.org \
--cc=oss.patchbox@gmail.com \
--cc=pabeni@redhat.com \
--cc=richardcochran@gmail.com \
--cc=tianxun.ng@bytedance.com \
--cc=willemb@google.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