Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider. Critical: 0 · High: 1 · Medium: 0 · 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). - [High] This patch closes only one of the paths that use the Tx timestamp trackers after they are freed on remove (and, once the later… -- idpf: ignore Tx timestamp replies once removal has started When IDPF_REMOVE_IN_PROG is set, this patch makes idpf_vc_core_deinit() wait for mbx_task to finish before releasing the PTP state. It then queues mbx_task again right away, so replies to synchronous transactions are still handled during vport teardown. It also makes idpf_ptp_get_tx_tstamp_async_handler() return early once IDPF_REMOVE_IN_PROG is set.
> diff --git a/drivers/net/ethernet/intel/idpf/idpf_virtchnl.c b/drivers/net/ethernet/intel/idpf/idpf_virtchnl.c > index c89783966bae3..348c7875134ad 100644 > --- a/drivers/net/ethernet/intel/idpf/idpf_virtchnl.c > +++ b/drivers/net/ethernet/intel/idpf/idpf_virtchnl.c > @@ -3262,8 +3262,18 @@ void idpf_vc_core_deinit(struct idpf_adapter *adapter) > > /* Avoid transaction timeouts when called during reset */ > remove_in_prog = test_bit(IDPF_REMOVE_IN_PROG, adapter->flags); > - if (!remove_in_prog) > + if (!remove_in_prog) { > libie_ctlq_xn_shutdown(adapter->xnm); > + } else { > + /* The transaction manager stays up for the teardown below, so > + * async replies can still arrive. Wait for a mailbox task that > + * may be running an async callback; callbacks that run later > + * see IDPF_REMOVE_IN_PROG and leave the state released below > + * alone. > + */ > + cancel_delayed_work_sync(&adapter->mbx_task); > + queue_delayed_work(adapter->mbx_wq, &adapter->mbx_task, 0); > + } > > idpf_ptp_release(adapter); > idpf_deinit_task(adapter);
[Severity: High] The mailbox async handler is gated now. Are other users of the Tx timestamp trackers still live at this point? idpf_ptp_release() still runs before idpf_deinit_task(). NAPI and xmit for the vports are stopped only later, in: idpf_deinit_task()->idpf_vport_dealloc()->idpf_vport_stop() Neither idpf_remove() nor idpf_shutdown() closes or detaches the netdevs before this. So the datapath can still be running while idpf_ptp_release_vport_tstamp() does this: cancel_work_sync(&vport->tstamp_task); ... kfree(vport->tx_tstamp_caps); vport->tx_tstamp_caps = NULL; Only the vport pointer is cleared. Each txq->cached_tstamp_caps, set in idpf_vport_init_fast_path_txqs(), still points at the freed object. On xmit, idpf_tx_tstamp()->idpf_ptp_get_txq_tstamp_capability() reads txq->cached_tstamp_caps->access. idpf_ptp_request_ts() then does: spin_lock(&tx_q->cached_tstamp_caps->latches_lock); head = &tx_q->cached_tstamp_caps->latches_free; ... Can this take the lock and move list entries in freed memory? On Tx completion, idpf_tx_clean_bufs() calls idpf_tx_read_tstamp() for an skb that has SKBTX_IN_PROGRESS set: tx_tstamp_caps = txq->cached_tstamp_caps; spin_lock_bh(&tx_tstamp_caps->status_lock); ... tx_tstamp_status->skb = skb; tx_tstamp_status->state = IDPF_PTP_REQUEST; ... queue_work(system_dfl_wq, txq->tstamp_task); Doesn't this write into the freed tracker? It also queues tstamp_task again after the only cancel_work_sync(). If tstamp_task runs again, idpf_tstamp_task()->idpf_ptp_get_tx_tstamp() has no NULL or IDPF_REMOVE_IN_PROG check: tx_tstamp_caps = vport->tx_tstamp_caps; head = &tx_tstamp_caps->latches_in_use; size = struct_size(send_tx_tstamp_msg, tstamp_latches, tx_tstamp_caps->num_entries); Would this oops on the NULL tx_tstamp_caps? Nothing cancels tstamp_task again before idpf_vport_dealloc()->idpf_vport_rel() frees the vport. Could a late run also reach the freed vport through container_of()? The commit message describes the bug as code that "reads vport->tx_tstamp_caps and takes its lock after idpf_ptp_release_vport_tstamp() may already have freed it". The new comment says later callbacks "leave the state released below alone". The xmit, Tx completion and tstamp_task paths reach the same object in the same window. The later patch in this series sets IDPF_REMOVE_IN_PROG on shutdown, so shutdown would be exposed to these paths too. This code is also unchanged at the end of the series. The order is still idpf_ptp_release() and then idpf_deinit_task(), cached_tstamp_caps is never cleared, and idpf_ptp_get_tx_tstamp() has no check. To trigger this, HW Tx timestamping has to be enabled (SIOCSHWTSTAMP) and SO_TIMESTAMPING traffic has to be flowing when the device is removed or shut down. Would it work better to quiesce Tx first, or to release the trackers only after idpf_deinit_task() has stopped the vports?
-- Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/2026…%40intel.com