From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796503633; b=q3ZrK8V5IhUdJleJdpuNuYDrdfpr1RbMpo9IKXahd4sPMukyfalWt1gSxlXTD0hVi9SS XBYZc55hSmO7T3TR9tFAKZGBzt/lTk/Qwja51caV7pQpI0UDDKctOmXh4YHFlM/bF3ueI OBrcptXAMFVbHIJlBxE1INxJMJBnkpsRwjkJ+guTHipZ0eZlG8/koeS3r0+c8fIjC8Vpp DWa/X95vB3nT6GGFB8UWCfQmXlSB8rTacEWZCzhTtvrbEMGbTw6xjZgZSyWb0jrIVLIfi gq3O9dbPaGg1bzG2eSkRjQo9LsK842Lk4FNk3te5IO/hN9fCDZc2lI9WAK0gRdztUlQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796503633; h=Received:DKIM-Signature:Subject:From:To:Cc:Date:Message-ID: In-Reply-To:References:X-sashiko-severity:Content-Type: Content-Transfer-Encoding:MIME-Version; bh=w2mYcC2EBFsblBEE2/AGUwA6J6wGI7smG8t+A77iG6w=; b=QcVNmz3LtUtnPCIqRDEmjT5KmcVDIDtX9CFl5DwyzLboJFyAbSsicOYRd6a2aStypdnj aS9MQS2Y2lJh8J8FVPzHZp0L+TZp82lth3YGlBnLQM1cbUpx/Yp/upkr7NtOZbDPLip7c 2qSKnBIsgfon9Bs+P7oFmLpUY7jTEKleTZCFmWBrMgoTfjOMSOMvlu7Y2asoOabWx4RSr gcLYjXP1nTTvN2iQsClnUN+xHhr76ZlXiEvJzlbmvdl6k4qb8tC/ALwCPgLxlxNoJyFBg 1kR/zDf6i+dRdVODtKGGa/cOXsdkBW4ITN3VeASQ4/LkF0ZLjjctbI75PzvCMqrMGVg== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=fXhC2Gyt; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 03D1F606A31F; Sat, 5 Dec 2026 20:47:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=fXhC2Gyt Received: by smtp.kernel.org (Postfix) with ESMTPSA id A02DF1F0092B; Sat, 5 Dec 2026 20:47:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796503632; bh=w2mYcC2EBFsblBEE2/AGUwA6J6wGI7smG8t+A77iG6w=; h=Subject:From:To:Cc:Date:In-Reply-To:References; b=fXhC2Gytvbm2KaRxxIWhd+d0COEn3jeTcSIBo7qSXt1zdz+2Wtzi6+FHgYgBqux/y cK9ZKHU5urSUdpGFwb6AdQ5gxiikHDkbfHoP6syyW/srZEJU7j5RavYfs3FHjR1fXT bS/EHE+cMMx2xNzjGLo5RC/I0dzrE+3J2zP6fpI3EX3zJIPL5H7jrEMAW+5pyGK27K HjQzvHczhs1Amv61ETWgDwlw3KafqFEUgzbKxRhy1+KLgmguqVu1L+jd0Ccpt6AnyH b4PRw7qcY0flJeiclKfxKcQVG81/+pwP5D5x7ppFGXYi+yHR/glgARqnmvIOSurgDR smtYSVaoD+EFw== Subject: Re: [PATCH net v2 2/6] idpf: ignore Tx timestamp replies once removal has started 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 Date: Sat, 05 Dec 2026 20:47:11 +0000 Message-ID: <179650363113.3148.2771200929909107480@kernel.org> In-Reply-To: <20261204194642.3048406-3-anthony.l.nguyen@intel.com> References: <20261204194642.3048406-3-anthony.l.nguyen@intel.com> X-sashiko-severity: High Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit X-Mailing-List: stable@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 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/20261204194642.3048406-1-anthony.l.nguyen%40intel.com