From: netdev-bot+sashiko@kernel.org
To: anthony.l.nguyen@intel.com
Cc: davem@davemloft.net, kuba@kernel.org, pabeni@redhat.com,
edumazet@kernel.org, andrew+netdev@lunn.ch, willemb@google.com,
netdev@vger.kernel.org, tianxun.ng@bytedance.com,
oss.patchbox@gmail.com, luckilystar08@gmail.com,
emil.s.tantilov@intel.com, richardcochran@gmail.com,
milena.olech@intel.com, konstantin.ilichev@intel.com,
stable@vger.kernel.org, Samuel.salin@intel.com
Subject: Re: [PATCH net v2 6/6] idpf: release PTP before freeing vports on the init task error path
Date: Sat, 05 Dec 2026 20:47:17 +0000 [thread overview]
Message-ID: <179650363738.3148.8011419031325451022@kernel.org> (raw)
In-Reply-To: <20261204194642.3048406-7-anthony.l.nguyen@intel.com>
Thank you for your contribution! Sashiko AI review found more severe
issue(s) in other patches of this series. This mail is only an FYI, in case
you want to address the nit picks below when you respin.
Low priority / nit picks for your consideration:
- [Low] idpf: Fixes tag cites 1a49cf814fe1 instead of 494565a74502
Pre-existing issues:
- [High] This problem wasn't introduced by this patch, but the patch only
closes the PTP aux worker case.
--
idpf: release PTP before freeing vports on the init task error path
This moves idpf_ptp_release() to the start of the unwind_vports error
path in idpf_init_task(), so the PTP aux worker is cancelled before the
vports are freed. That matches the order in idpf_vc_core_deinit(). It
fixes a slab-use-after-free in idpf_ptp_update_cached_phctime().
> diff --git a/drivers/net/ethernet/intel/idpf/idpf_lib.c b/drivers/net/ethernet/intel/idpf/idpf_lib.c
> index 38cb91beacd07..bf59d63bb7ec8 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])
[Severity: Low]
Is the Fixes tag pointing at the right commit?
The trailer cites 1a49cf814fe1 ("idpf: add Tx timestamp flows"). That
commit added idpf_ptp_do_aux_work(), the ptp_schedule_worker() call and
idpf_ptp_update_cached_phctime(). But its version of
idpf_ptp_update_cached_phctime() only updated
adapter->ptp->cached_phc_time and adapter->ptp->cached_phc_jiffies. It
never walked adapter->vports[] or dereferenced a struct idpf_vport.
The idpf_for_each_vport(adapter, vport) loop that reads the freed slot
in the KASAN splat appears to have arrived with 494565a74502 ("idpf: add
support for Rx timestamping"). That is also the commit the preceding
patch in this series cites for a related problem.
There is also a case for 4d792219fe6f ("idpf: fix error handling in the
init_task on load"). That commit put the idpf_ptp_release() call at the
bottom of unwind_vports, after the idpf_vport_dealloc() loop. That is
the placement this patch corrects.
This only affects commit metadata, not the code. Still, the Fixes tag
drives stable backport selection. 1a49cf814fe1 would pull this into
trees where the aux worker never touches vports.
Could you check which commit you consider the root cause? Then update
the trailer to 494565a74502, add 4d792219fe6f, or both.
[ ... ]
> @@ -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);
> }
[Severity: High]
This is a pre-existing issue and was not introduced by this patch. Does
mbx_task still have the same window that this patch closes for the PTP
aux worker?
On this unwind path, mbx_task is cancelled only after the
idpf_vport_dealloc() loop has run, and only when IDPF_HR_DRV_LOAD is set.
idpf_vc_core_deinit() uses a similar order: idpf_deinit_task() frees all
vports before mbx_task is cancelled.
While mbx_task is still running, it can reach:
mbx_task
libie_ctlq_xn_recv()
idpf_recv_event_msg()
idpf_handle_event_link()
The only guard in idpf_handle_event_link() is IDPF_REMOVE_IN_PROG. That
flag is not set on the init task unwind (driver load or after a reset).
It is also not set on a function reset that goes through
idpf_init_hard_reset()->idpf_vc_core_deinit()->idpf_deinit_task(). The
handler then does:
drivers/net/ethernet/intel/idpf/idpf_virtchnl.c:idpf_handle_event_link() {
...
vport = idpf_vid_to_vport(adapter, le32_to_cpu(v2e->vport_id));
...
np = netdev_priv(vport->netdev);
...
vport->link_up = v2e->link_status;
...
}
idpf_vid_to_vport() matches on adapter->vport_ids[], which is not cleared
on dealloc. It returns adapter->vports[i] without holding a lock or using
RCU.
Meanwhile, idpf_vport_dealloc() frees the vport before it clears the
slot:
drivers/net/ethernet/intel/idpf/idpf_lib.c:idpf_vport_dealloc() {
...
idpf_vport_rel(vport); /* ends with kfree(vport) */
adapter->vports[i] = NULL;
...
}
If a VIRTCHNL2_EVENT_LINK_CHANGE is handled while a vport is being freed,
can idpf_handle_event_link() read vport->netdev and write vport->link_up
on the freed idpf_vport?
This is the same pattern the commit message describes for
idpf_ptp_update_cached_phctime(), but through a different worker.
idpf_mac_filter_async_handler() only NULL-checks the returned vport and
does not appear to be affected.
> - idpf_ptp_release(adapter);
>
> clear_bit(IDPF_HR_RESET_IN_PROG, adapter->flags);
> }
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261204194642.3048406-1-anthony.l.nguyen%40intel.com
next prev parent reply other threads:[~2026-12-05 20:47 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-04 19:46 [PATCH net v2 0/6][pull request] Intel Wired LAN Driver Updates 2026-11-25 (idpf) Tony Nguyen
2026-12-04 19:46 ` [PATCH net v2 1/6] idpf: Fix vport IRQ name leak on request failure Tony Nguyen
2026-12-04 19:46 ` [PATCH net v2 2/6] idpf: ignore Tx timestamp replies once removal has started Tony Nguyen
2026-12-05 20:47 ` netdev-bot+sashiko
2026-12-04 19:46 ` [PATCH net v2 3/6] idpf: ignore link events " Tony Nguyen
2026-12-05 20:47 ` netdev-bot+sashiko
2026-12-04 19:46 ` [PATCH net v2 4/6] idpf: keep the mailbox up while tearing down vports on shutdown Tony Nguyen
2026-12-05 20:47 ` netdev-bot+sashiko
2026-12-04 19:46 ` [PATCH net v2 5/6] idpf: fix use-after-free in the PTP auxiliary worker Tony Nguyen
2026-12-05 20:47 ` netdev-bot+sashiko
2026-12-04 19:46 ` [PATCH net v2 6/6] idpf: release PTP before freeing vports on the init task error path Tony Nguyen
2026-12-05 20:47 ` netdev-bot+sashiko [this message]
2026-12-04 19:53 ` [PATCH net v2 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=179650363738.3148.8011419031325451022@kernel.org \
--to=netdev-bot+sashiko@kernel.org \
--cc=Samuel.salin@intel.com \
--cc=andrew+netdev@lunn.ch \
--cc=anthony.l.nguyen@intel.com \
--cc=davem@davemloft.net \
--cc=edumazet@kernel.org \
--cc=emil.s.tantilov@intel.com \
--cc=konstantin.ilichev@intel.com \
--cc=kuba@kernel.org \
--cc=luckilystar08@gmail.com \
--cc=milena.olech@intel.com \
--cc=netdev@vger.kernel.org \
--cc=oss.patchbox@gmail.com \
--cc=pabeni@redhat.com \
--cc=richardcochran@gmail.com \
--cc=stable@vger.kernel.org \
--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