* [PATCH net v2 1/6] idpf: Fix vport IRQ name leak on request failure
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 ` Tony Nguyen
2026-12-04 19:46 ` [PATCH net v2 2/6] idpf: ignore Tx timestamp replies once removal has started Tony Nguyen
` (5 subsequent siblings)
6 siblings, 0 replies; 13+ messages in thread
From: Tony Nguyen @ 2026-12-04 19:46 UTC (permalink / raw)
To: davem, kuba, pabeni, edumazet, andrew+netdev, willemb, netdev
Cc: Yuho Choi, anthony.l.nguyen, tianxun.ng, luckilystar08,
emil.s.tantilov, richardcochran, milena.olech, konstantin.ilichev,
Aleksandr Loktionov, Rafal Romanowski
From: Yuho Choi <oss.patchbox@gmail.com>
idpf_vport_intr_req_irq() allocates a name for each vector IRQ before
calling request_irq(). On success, the name is released later through
kfree(free_irq()), but when request_irq() fails, the error path only
unwinds the previous vectors and the name for the failed one is leaked.
Free the allocated name on the request_irq() failure path, as done for
the mailbox IRQ in commit 9bff30482c10 ("idpf: Fix mailbox IRQ name leak
on request failure"). While at it, fail with -ENOMEM when the name
cannot be allocated instead of requesting the IRQ without a name.
Fixes: d4d558718266 ("idpf: initialize interrupts and enable vport")
Signed-off-by: Yuho Choi <oss.patchbox@gmail.com>
Reviewed-by: Aleksandr Loktionov <aleksandr.loktionov@intel.com>
Tested-by: Rafal Romanowski <rafal.romanowski@intel.com>
Signed-off-by: Tony Nguyen <anthony.l.nguyen@intel.com>
---
drivers/net/ethernet/intel/idpf/idpf_txrx.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/drivers/net/ethernet/intel/idpf/idpf_txrx.c b/drivers/net/ethernet/intel/idpf/idpf_txrx.c
index b346187bbf30..281b96daa5c1 100644
--- a/drivers/net/ethernet/intel/idpf/idpf_txrx.c
+++ b/drivers/net/ethernet/intel/idpf/idpf_txrx.c
@@ -4132,12 +4132,17 @@ static int idpf_vport_intr_req_irq(struct idpf_vport *vport,
name = kasprintf(GFP_KERNEL, "%s-%s-%s-%d", drv_name, if_name,
vec_name, vector);
+ if (!name) {
+ err = -ENOMEM;
+ goto free_q_irqs;
+ }
err = request_irq(irq_num, idpf_vport_intr_clean_queues, 0,
name, q_vector);
if (err) {
netdev_err(vport->netdev,
"Request_irq failed, error: %d\n", err);
+ kfree(name);
goto free_q_irqs;
}
--
2.47.1
^ permalink raw reply related [flat|nested] 13+ messages in thread* [PATCH net v2 2/6] idpf: ignore Tx timestamp replies once removal has started
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 ` 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
` (4 subsequent siblings)
6 siblings, 1 reply; 13+ messages in thread
From: Tony Nguyen @ 2026-12-04 19:46 UTC (permalink / raw)
To: davem, kuba, pabeni, edumazet, andrew+netdev, willemb, netdev
Cc: Tian Xun Ng, anthony.l.nguyen, oss.patchbox, luckilystar08,
emil.s.tantilov, richardcochran, milena.olech, konstantin.ilichev,
stable, Samuel Salin
From: Tian Xun Ng <tianxun.ng@bytedance.com>
On remove, idpf_vc_core_deinit() keeps the virtchnl transaction manager
up until the vports have been torn down, so mbx_task keeps processing
replies while idpf_ptp_release() frees the Tx timestamp trackers. An
async VIRTCHNL2_OP_PTP_GET_VPORT_TX_TSTAMP reply handled in that window
reaches idpf_ptp_get_tx_tstamp_async_handler(), which reads
vport->tx_tstamp_caps and takes its lock after
idpf_ptp_release_vport_tstamp() may already have freed it.
Once IDPF_REMOVE_IN_PROG is set, wait for a mailbox task that may be
running a callback before releasing anything, and make the Tx timestamp
callback return when the bit is set. Matched replies to synchronous
transactions are not affected, so the vport teardown still receives
them; mbx_task is requeued straight away for that.
The last patch of this series sets IDPF_REMOVE_IN_PROG on shutdown too,
which would otherwise expose shutdown to the same window.
Fixes: 1a49cf814fe1 ("idpf: add Tx timestamp flows")
Cc: stable@vger.kernel.org
Signed-off-by: Tian Xun Ng <tianxun.ng@bytedance.com>
Reviewed-by: Emil Tantilov <emil.s.tantilov@intel.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_virtchnl.c | 12 +++++++++++-
drivers/net/ethernet/intel/idpf/idpf_virtchnl_ptp.c | 3 ++-
2 files changed, 13 insertions(+), 2 deletions(-)
diff --git a/drivers/net/ethernet/intel/idpf/idpf_virtchnl.c b/drivers/net/ethernet/intel/idpf/idpf_virtchnl.c
index c89783966bae..348c7875134a 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);
diff --git a/drivers/net/ethernet/intel/idpf/idpf_virtchnl_ptp.c b/drivers/net/ethernet/intel/idpf/idpf_virtchnl_ptp.c
index 14dba40a993f..1422b30d09a3 100644
--- a/drivers/net/ethernet/intel/idpf/idpf_virtchnl_ptp.c
+++ b/drivers/net/ethernet/intel/idpf/idpf_virtchnl_ptp.c
@@ -550,7 +550,8 @@ idpf_ptp_get_tx_tstamp_async_handler(void *ctx, struct kvec *mem, int status)
u16 num_latches;
u32 vport_id;
- if (status)
+ /* The Tx timestamp trackers are released on remove and shutdown */
+ if (status || test_bit(IDPF_REMOVE_IN_PROG, adapter->flags))
return;
recv_tx_tstamp_msg = mem->iov_base;
--
2.47.1
^ permalink raw reply related [flat|nested] 13+ messages in thread* Re: [PATCH net v2 2/6] idpf: ignore Tx timestamp replies once removal has started
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
0 siblings, 0 replies; 13+ messages in thread
From: netdev-bot+sashiko @ 2026-12-05 20:47 UTC (permalink / raw)
To: anthony.l.nguyen
Cc: davem, kuba, pabeni, edumazet, andrew+netdev, willemb, netdev,
tianxun.ng, oss.patchbox, luckilystar08, emil.s.tantilov,
richardcochran, milena.olech, konstantin.ilichev, stable,
Samuel.salin
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
^ permalink raw reply [flat|nested] 13+ messages in thread
* [PATCH net v2 3/6] idpf: ignore link events once removal has started
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-04 19:46 ` 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
` (3 subsequent siblings)
6 siblings, 1 reply; 13+ messages in thread
From: Tony Nguyen @ 2026-12-04 19:46 UTC (permalink / raw)
To: davem, kuba, pabeni, edumazet, andrew+netdev, willemb, netdev
Cc: Tian Xun Ng, anthony.l.nguyen, oss.patchbox, luckilystar08,
emil.s.tantilov, richardcochran, milena.olech, konstantin.ilichev,
stable, Samuel Salin
From: Tian Xun Ng <tianxun.ng@bytedance.com>
mbx_task keeps handling mailbox events while idpf_deinit_task() releases
the vports: it requeues itself, or is queued from the mailbox interrupt,
until idpf_vc_core_deinit() cancels it once the vports are gone. A
VIRTCHNL2_EVENT_LINK_CHANGE event handled in that window looks its vport
up in adapter->vports[] without a lock, and idpf_vport_dealloc()
releases the netdev and frees the vport before it clears that slot, so
idpf_handle_event_link() can follow a NULL netdev pointer or use the
freed vport.
Make idpf_handle_event_link() return once IDPF_REMOVE_IN_PROG is set.
The previous patch waits for a running mbx_task after the bit is set and
before anything is released, so on remove a link event is either handled
before the vports are torn down or ignored. Shutdown has the same window
today; the last patch of this series sets the bit there as well. The
window also remains on a hard reset, which tears the vports down without
setting the bit; that path is not changed here.
Fixes: 02cbfba1add5 ("idpf: add ethtool callbacks")
Cc: stable@vger.kernel.org
Signed-off-by: Tian Xun Ng <tianxun.ng@bytedance.com>
Reviewed-by: Emil Tantilov <emil.s.tantilov@intel.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_virtchnl.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/drivers/net/ethernet/intel/idpf/idpf_virtchnl.c b/drivers/net/ethernet/intel/idpf/idpf_virtchnl.c
index 348c7875134a..854eb1f1ada4 100644
--- a/drivers/net/ethernet/intel/idpf/idpf_virtchnl.c
+++ b/drivers/net/ethernet/intel/idpf/idpf_virtchnl.c
@@ -41,6 +41,10 @@ static void idpf_handle_event_link(struct idpf_adapter *adapter,
struct idpf_netdev_priv *np;
struct idpf_vport *vport;
+ /* The vports are released on remove and shutdown */
+ if (test_bit(IDPF_REMOVE_IN_PROG, adapter->flags))
+ return;
+
vport = idpf_vid_to_vport(adapter, le32_to_cpu(v2e->vport_id));
if (!vport) {
dev_err_ratelimited(&adapter->pdev->dev, "Failed to find vport_id %d for link event\n",
--
2.47.1
^ permalink raw reply related [flat|nested] 13+ messages in thread* Re: [PATCH net v2 3/6] idpf: ignore link events once removal has started
2026-12-04 19:46 ` [PATCH net v2 3/6] idpf: ignore link events " Tony Nguyen
@ 2026-12-05 20:47 ` netdev-bot+sashiko
0 siblings, 0 replies; 13+ messages in thread
From: netdev-bot+sashiko @ 2026-12-05 20:47 UTC (permalink / raw)
To: anthony.l.nguyen
Cc: davem, kuba, pabeni, edumazet, andrew+netdev, willemb, netdev,
tianxun.ng, oss.patchbox, luckilystar08, emil.s.tantilov,
richardcochran, milena.olech, konstantin.ilichev, stable,
Samuel.salin
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] On remove, the fix only works together with the mbx_task drain
added by the previous patch in the series ("idpf: ignore Tx timestamp…
Pre-existing issues:
- [High] This patch did not introduce the problem: the same link-event
use-after-free stays reachable on teardown paths that do not set…
- [High] This patch did not introduce the problem: a link event can see a
vport before its netdev is set.
- [High] This patch did not introduce the problem:
idpf_handle_event_link() can wake the TX queues of a vport whose…
--
idpf: ignore link events once removal has started
This patch makes idpf_handle_event_link() return early once
IDPF_REMOVE_IN_PROG is set. On remove, it relies on the mbx_task drain
added by the previous patch, so a link event is either handled before the
vports are torn down or ignored. The commit message notes that hard reset
still has the window and that shutdown is handled later in the series.
> diff --git a/drivers/net/ethernet/intel/idpf/idpf_virtchnl.c b/drivers/net/ethernet/intel/idpf/idpf_virtchnl.c
> index 348c7875134ad..854eb1f1ada4c 100644
> --- a/drivers/net/ethernet/intel/idpf/idpf_virtchnl.c
> +++ b/drivers/net/ethernet/intel/idpf/idpf_virtchnl.c
> @@ -41,6 +41,10 @@ static void idpf_handle_event_link(struct idpf_adapter *adapter,
> struct idpf_netdev_priv *np;
> struct idpf_vport *vport;
>
> + /* The vports are released on remove and shutdown */
> + if (test_bit(IDPF_REMOVE_IN_PROG, adapter->flags))
> + return;
> +
[Severity: Low]
On remove, this check only closes the window when combined with the
mbx_task drain from the previous patch in the series ("idpf: ignore Tx
timestamp replies once removal has started"). That drain is in
idpf_vc_core_deinit():
} else {
...
cancel_delayed_work_sync(&adapter->mbx_task);
queue_delayed_work(adapter->mbx_wq, &adapter->mbx_task, 0);
}
Without the drain, this test_bit() is check-then-act. Suppose an mbx_task
passed the check before idpf_remove() set IDPF_REMOVE_IN_PROG. It can still
be inside idpf_handle_event_link() when
idpf_deinit_task()->idpf_vport_dealloc() frees the vport.
The previous patch has Fixes: 1a49cf814fe1. This patch has
Fixes: 02cbfba1add5 and a plain Cc: stable, with no note about the
prerequisite. Some stable trees have 02cbfba1add5 but not 1a49cf814fe1
(6.12.y, for example). Those trees would not pick up the previous patch,
and its context (idpf_ptp_release()) does not exist there.
In those trees this statement from the commit message would not hold:
"on remove a link event is either handled before the vports are torn
down or ignored"
The race would only be narrowed.
Could the stable tag get a "# depends on" note? Alternatively, the drain
could be split out with a Fixes tag that covers 02cbfba1add5.
> vport = idpf_vid_to_vport(adapter, le32_to_cpu(v2e->vport_id));
[Severity: High]
This is a pre-existing issue and was not introduced by this patch. The
same use-after-free can still happen on teardown paths that never set
IDPF_REMOVE_IN_PROG.
The commit message already mentions hard reset. idpf_init_hard_reset()
calls idpf_vc_core_deinit() with remove_in_prog false. So mbx_task is not
drained before idpf_deinit_task(), and it is only cancelled afterwards:
idpf_ptp_release(adapter);
idpf_deinit_task(adapter);
...
cancel_delayed_work_sync(&adapter->serv_task);
cancel_delayed_work_sync(&adapter->mbx_task);
The commit message does not mention the unwind_vports error path in
idpf_init_task(), which has the same problem. It frees the vports while
mbx_task is live and cancels mbx_task only afterwards:
unwind_vports:
if (default_vport) {
for (index = 0; index < adapter->max_vports; index++) {
if (adapter->vports[index])
idpf_vport_dealloc(adapter->vports[index]);
}
}
...
if (test_and_clear_bit(IDPF_HR_DRV_LOAD, adapter->flags)) {
cancel_delayed_work_sync(&adapter->serv_task);
cancel_delayed_work_sync(&adapter->mbx_task);
}
libie_ctlq_xn_shutdown() does not stop these events. libie_ctlq_xn_recv()
still passes any message that libie_ctlq_xn_process_recv() does not claim
to params->ctlq_msg_handler. So unsolicited VIRTCHNL2_EVENT_LINK_CHANGE
messages keep arriving.
IDPF_HR_RESET_IN_PROG is set on both paths, so idpf_vport_dealloc() skips
idpf_decfg_netdev(). It then frees the vport before clearing its slot:
idpf_vport_rel(vport); <-- kfree(vport)
adapter->vports[i] = NULL;
Can a concurrent link event get the vport from idpf_vid_to_vport() and
then read vport->netdev and read/write vport->link_up after the kfree()?
This could be triggered by a driver-initiated function reset (for example
after a Tx timeout). It could also be triggered by an idpf_init_task()
failure after at least one vport was allocated.
The shutdown part of this is fixed later in the series by "idpf: keep the
mailbox up while tearing down vports on shutdown". That patch sets
IDPF_REMOVE_IN_PROG at the start of idpf_shutdown().
> if (!vport) {
> dev_err_ratelimited(&adapter->pdev->dev, "Failed to find vport_id %d for link event\n",
[Severity: High]
This is also a pre-existing issue and was not introduced by this patch.
Can a link event see a vport before its netdev has been set?
idpf_vport_alloc() publishes the vport with plain stores:
adapter->vports[idx] = vport;
adapter->vport_ids[idx] = idpf_get_vport_id(vport);
vport->netdev is only assigned later, when idpf_init_task() calls
idpf_cfg_netdev():
if (idpf_cfg_netdev(vport))
goto unwind_vports;
At that point mbx_task is already running and IDPF_REMOVE_IN_PROG is
clear. Suppose a VIRTCHNL2_EVENT_LINK_CHANGE for the new vport_id arrives
in that window. idpf_vid_to_vport() returns a vport whose netdev is still
NULL, and idpf_handle_event_link() then does:
np = netdev_priv(vport->netdev);
np->link_speed_mbps = le32_to_cpu(v2e->link_speed);
Would this write through netdev_priv(NULL) and oops?
The window is open on every probe and after every hard reset. On the first
probe it also includes the sleeping alloc_etherdev_mqs().
[Severity: High]
This is another pre-existing race in this handler and was not introduced
by this patch. Can a link event wake the TX queues of a vport while it is
being stopped?
idpf_handle_event_link() runs without rtnl or vport_ctrl_lock and does:
vport->link_up = v2e->link_status;
if (!test_bit(IDPF_VPORT_UP, np->state))
return;
if (vport->link_up) {
netif_tx_start_all_queues(vport->netdev);
netif_carrier_on(vport->netdev);
idpf_vport_stop() clears IDPF_VPORT_UP only after the queues are freed:
vport->link_up = false;
idpf_vport_intr_deinit(vport, rsrc);
idpf_xdp_rxq_info_deinit_all(rsrc);
idpf_vport_queues_rel(vport, rsrc);
idpf_vport_intr_rel(rsrc);
clear_bit(IDPF_VPORT_UP, np->state);
Consider a link-up event handled between the link_up = false store and the
clear_bit(). It would see link_up change and pass the IDPF_VPORT_UP test.
It would then restart all TX queues and turn the carrier on.
On the soft reset path (ethtool -L/-G or an MTU change on an up
interface), the stack can then call idpf_tx_start(), which does:
tx_q = vport->txqs[skb_get_queue_mapping(skb)];
After idpf_vport_queues_rel() that pointer is NULL. After this memcpy() in
idpf_initiate_soft_reset() it is the stale, freed pointer:
memcpy(vport, new_vport, offsetof(struct idpf_vport, link_up));
It stays that way until idpf_vport_open() reallocates the queues.
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261204194642.3048406-1-anthony.l.nguyen%40intel.com
^ permalink raw reply [flat|nested] 13+ messages in thread
* [PATCH net v2 4/6] idpf: keep the mailbox up while tearing down vports on shutdown
2026-12-04 19:46 [PATCH net v2 0/6][pull request] Intel Wired LAN Driver Updates 2026-11-25 (idpf) Tony Nguyen
` (2 preceding siblings ...)
2026-12-04 19:46 ` [PATCH net v2 3/6] idpf: ignore link events " Tony Nguyen
@ 2026-12-04 19:46 ` 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
` (2 subsequent siblings)
6 siblings, 1 reply; 13+ messages in thread
From: Tony Nguyen @ 2026-12-04 19:46 UTC (permalink / raw)
To: davem, kuba, pabeni, edumazet, andrew+netdev, willemb, netdev
Cc: Tian Xun Ng, anthony.l.nguyen, oss.patchbox, luckilystar08,
emil.s.tantilov, richardcochran, milena.olech, konstantin.ilichev,
stable, Samuel Salin
From: Tian Xun Ng <tianxun.ng@bytedance.com>
Since commit 4c9106f4906a ("idpf: fix adapter NULL pointer dereference
on reboot"), idpf_shutdown() calls idpf_vc_core_deinit() directly instead
of idpf_remove(), so IDPF_REMOVE_IN_PROG is not set on shutdown.
idpf_vc_core_deinit() uses that flag to decide when to shut the virtchnl
transaction manager down. Without it, libie_ctlq_xn_shutdown() runs
before idpf_deinit_task() tears the vports down, so every message sent
during that teardown (disable vport, disable queues, destroy vport)
fails at once, and the device is never told that the vports are gone.
A reset should clear that state, but on the system where this was found
the device kept the queues enabled across a warm reboot. The first queue
reconfiguration in the next kernel (udev setting the MTU) sends
VIRTCHNL2_OP_DEL_QUEUES, and the device then writes SW_MARKER TX
completions to the previous kernel's completion rings. With the IOMMU
translating, those writes fault about 19 s into every such boot:
arm-smmu-v3 arm-smmu-v3.12.auto: event: F_TRANSLATION client: 0006:01:00.0 sid: 0x30100 ssid: 0x0 iova: 0x3ef60840 ipa: 0x0
In IOMMU pass-through mode they corrupt pages the new kernel has reused.
Set IDPF_REMOVE_IN_PROG at the start of idpf_shutdown(), as
idpf_remove() does, so that the event task cannot be requeued and the
vports are destroyed while the mailbox is still up; the first two
patches keep the Tx timestamp callback and the link event handler away
from the state released on the way. So that an unresponsive control
plane does not hold up a reboot for long, cap each transaction sent
during the teardown at 500 ms instead of 60 s, through a new
adapter->vc_xn_timeout_ms, and fail later synchronous ones at once after
the first one times out. If the SW marker of one disabled Tx queue does
not arrive, the remaining queues of that vport do not wait for theirs,
but the mailbox messages that follow are still sent: the device has just
answered DISABLE_QUEUES. A control plane that dies at that point costs
one marker timeout per vport and one mailbox timeout. The statistics
task stops sending once IDPF_REMOVE_IN_PROG is set. A request it already
has waiting, or a reset already running in the event task, keeps its own
timeouts, as bounding those would need support in libie. If the function
has already been reset, for instance a VF whose PF went down first,
idpf_is_reset_detected() fails the messages without waiting.
Tested on two arm64 (64K pages) servers, each with two idpf PFs, with
this series backported to a 6.17 kernel and the IOMMU translating: 20
warm reboots without a fault. Each PF's teardown took about 1.2 s for
six mailbox transactions, with all 64 Tx queue markers received; the
slowest transaction, VIRTCHNL2_OP_DEALLOC_VECTORS, took about 300 ms.
With the first Tx queue marker treated as missing, the other 63 queues
did not wait, all six transactions still completed, the teardown took
about 2 s per PF, and 3 of 3 warm reboots were clean. With the driver
made to skip sending the teardown messages, every reboot faulted again.
Fixes: 4c9106f4906a ("idpf: fix adapter NULL pointer dereference on reboot")
Cc: stable@vger.kernel.org
Signed-off-by: Tian Xun Ng <tianxun.ng@bytedance.com>
Reviewed-by: Emil Tantilov <emil.s.tantilov@intel.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.h | 5 ++-
drivers/net/ethernet/intel/idpf/idpf_lib.c | 3 ++
drivers/net/ethernet/intel/idpf/idpf_main.c | 11 +++++++
.../net/ethernet/intel/idpf/idpf_virtchnl.c | 33 ++++++++++++++++---
.../net/ethernet/intel/idpf/idpf_virtchnl.h | 1 +
5 files changed, 47 insertions(+), 6 deletions(-)
diff --git a/drivers/net/ethernet/intel/idpf/idpf.h b/drivers/net/ethernet/intel/idpf/idpf.h
index f214023095ee..533b069d97f9 100644
--- a/drivers/net/ethernet/intel/idpf/idpf.h
+++ b/drivers/net/ethernet/intel/idpf/idpf.h
@@ -85,7 +85,7 @@ enum idpf_state {
* @IDPF_HR_FUNC_RESET: Hard reset when TxRx timeout
* @IDPF_HR_DRV_LOAD: Set on driver load for a clean HW
* @IDPF_HR_RESET_IN_PROG: Reset in progress
- * @IDPF_REMOVE_IN_PROG: Driver remove in progress
+ * @IDPF_REMOVE_IN_PROG: Driver remove or shutdown in progress
* @IDPF_MB_INTR_MODE: Mailbox in interrupt mode
* @IDPF_VC_CORE_INIT: virtchnl core has been init
* @IDPF_FLAGS_NBITS: Must be last
@@ -635,6 +635,8 @@ struct idpf_edt_caps_ilog2 {
* @asq: Send control queue info
* @arq: Receive control queue info
* @xnm: Xn transaction manager
+ * @vc_xn_timeout_ms: Upper bound for each Xn transaction timeout, shortened
+ * on shutdown and set to 0 once a shortened one timed out
* @num_avail_msix: Available number of MSIX vectors
* @num_msix_entries: Number of entries in MSIX table
* @msix_entries: MSIX table
@@ -695,6 +697,7 @@ struct idpf_adapter {
struct libie_ctlq_info *asq;
struct libie_ctlq_info *arq;
struct libie_ctlq_xn_manager *xnm;
+ u32 vc_xn_timeout_ms;
u16 num_avail_msix;
u16 num_msix_entries;
struct msix_entry *msix_entries;
diff --git a/drivers/net/ethernet/intel/idpf/idpf_lib.c b/drivers/net/ethernet/intel/idpf/idpf_lib.c
index 523c0e0be884..062d2f540254 100644
--- a/drivers/net/ethernet/intel/idpf/idpf_lib.c
+++ b/drivers/net/ethernet/intel/idpf/idpf_lib.c
@@ -1377,6 +1377,9 @@ void idpf_statistics_task(struct work_struct *work)
for (i = 0; i < adapter->max_vports; i++) {
struct idpf_vport *vport = adapter->vports[i];
+ if (test_bit(IDPF_REMOVE_IN_PROG, adapter->flags))
+ return;
+
if (vport && !test_bit(IDPF_HR_RESET_IN_PROG, adapter->flags))
idpf_send_get_stats_msg(netdev_priv(vport->netdev),
&vport->port_stats);
diff --git a/drivers/net/ethernet/intel/idpf/idpf_main.c b/drivers/net/ethernet/intel/idpf/idpf_main.c
index 129bccaa6baa..21be83dc82b1 100644
--- a/drivers/net/ethernet/intel/idpf/idpf_main.c
+++ b/drivers/net/ethernet/intel/idpf/idpf_main.c
@@ -194,8 +194,18 @@ static void idpf_shutdown(struct pci_dev *pdev)
{
struct idpf_adapter *adapter = pci_get_drvdata(pdev);
+ /* As in idpf_remove(): keep the event task from being requeued, and
+ * destroy the vports while the mailbox is still up.
+ */
+ set_bit(IDPF_REMOVE_IN_PROG, adapter->flags);
cancel_delayed_work_sync(&adapter->serv_task);
cancel_delayed_work_sync(&adapter->vc_event_task);
+
+ /* Bound the teardown transactions started from here on, so that an
+ * unresponsive control plane costs a single timeout. A reset or a
+ * transaction that is already running keeps its own timeouts.
+ */
+ WRITE_ONCE(adapter->vc_xn_timeout_ms, IDPF_VC_XN_SHUTDOWN_TIMEOUT_MSEC);
idpf_vc_core_deinit(adapter);
idpf_deinit_dflt_mbx(adapter);
@@ -267,6 +277,7 @@ static int idpf_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
adapter->req_rx_splitq = true;
adapter->pdev = pdev;
+ adapter->vc_xn_timeout_ms = IDPF_VC_XN_DEFAULT_TIMEOUT_MSEC;
err = idpf_dev_init(adapter, ent);
if (err) {
diff --git a/drivers/net/ethernet/intel/idpf/idpf_virtchnl.c b/drivers/net/ethernet/intel/idpf/idpf_virtchnl.c
index 854eb1f1ada4..e7a8ccbc3585 100644
--- a/drivers/net/ethernet/intel/idpf/idpf_virtchnl.c
+++ b/drivers/net/ethernet/intel/idpf/idpf_virtchnl.c
@@ -195,20 +195,32 @@ static void idpf_prepare_ptp_mb_msg(struct idpf_adapter *adapter, u32 op,
* Cleanup the mailbox queue entries of the previously sent message to
* unmap and release the buffer.
*
+ * The transaction timeout is capped at adapter->vc_xn_timeout_ms. Once a
+ * synchronous transaction with a shortened timeout times out, later ones
+ * fail at once instead of waiting again.
+ *
* Return: 0 if the request was successful, -%EBUSY if reset is detected
- * or Tx control queue is full, other negative error code on failure.
+ * or Tx control queue is full, -%ETIMEDOUT if a shortened transaction
+ * already timed out, other negative error code on failure.
*/
int idpf_send_mb_msg(struct idpf_adapter *adapter,
struct libie_ctlq_xn_send_params *xn_params,
void *send_buf, size_t send_buf_size)
{
+ u32 timeout_ms = READ_ONCE(adapter->vc_xn_timeout_ms);
struct libie_ctlq_msg ctlq_msg = {};
+ int err = 0;
- if (idpf_is_reset_detected(adapter)) {
+ if (idpf_is_reset_detected(adapter))
+ err = -EBUSY;
+ else if (!timeout_ms)
+ err = -ETIMEDOUT;
+
+ if (err) {
if (!libie_cp_can_send_onstack(send_buf_size))
kfree(send_buf);
- return -EBUSY;
+ return err;
}
idpf_prepare_ptp_mb_msg(adapter, xn_params->chnl_opcode, &ctlq_msg);
@@ -219,10 +231,15 @@ int idpf_send_mb_msg(struct idpf_adapter *adapter,
xn_params->xnm = adapter->xnm;
xn_params->ctlq = xn_params->ctlq ? xn_params->ctlq : adapter->asq;
xn_params->rel_tx_buf = kfree;
+ xn_params->timeout_ms = min_t(u64, xn_params->timeout_ms, timeout_ms);
idpf_mb_clean(xn_params->ctlq, false);
- return libie_ctlq_xn_send(xn_params);
+ err = libie_ctlq_xn_send(xn_params);
+ if (err == -ETIMEDOUT && timeout_ms < IDPF_VC_XN_DEFAULT_TIMEOUT_MSEC)
+ WRITE_ONCE(adapter->vc_xn_timeout_ms, 0);
+
+ return err;
}
/**
@@ -372,6 +389,11 @@ static int idpf_wait_for_marker_event_set(const struct idpf_queue_set *qs)
struct net_device *netdev;
struct idpf_tx_queue *txq;
bool markers_rcvd = true;
+ bool wait_all;
+
+ /* On shutdown, once one marker is missing, don't wait for the rest */
+ wait_all = READ_ONCE(qs->adapter->vc_xn_timeout_ms) >=
+ IDPF_VC_XN_DEFAULT_TIMEOUT_MSEC;
for (u32 i = 0; i < qs->num; i++) {
switch (qs->qs[i].type) {
@@ -381,7 +403,8 @@ static int idpf_wait_for_marker_event_set(const struct idpf_queue_set *qs)
netdev = txq->netdev;
idpf_queue_set(SW_MARKER, txq);
- idpf_wait_for_sw_marker_completion(txq);
+ if (markers_rcvd || wait_all)
+ idpf_wait_for_sw_marker_completion(txq);
markers_rcvd &= !idpf_queue_has(SW_MARKER, txq);
break;
default:
diff --git a/drivers/net/ethernet/intel/idpf/idpf_virtchnl.h b/drivers/net/ethernet/intel/idpf/idpf_virtchnl.h
index 5d27805ff40f..911a25ad958b 100644
--- a/drivers/net/ethernet/intel/idpf/idpf_virtchnl.h
+++ b/drivers/net/ethernet/intel/idpf/idpf_virtchnl.h
@@ -7,6 +7,7 @@
#include <linux/net/intel/virtchnl2.h>
#define IDPF_VC_XN_DEFAULT_TIMEOUT_MSEC (60 * 1000)
+#define IDPF_VC_XN_SHUTDOWN_TIMEOUT_MSEC 500
struct idpf_adapter;
struct idpf_netdev_priv;
--
2.47.1
^ permalink raw reply related [flat|nested] 13+ messages in thread* Re: [PATCH net v2 4/6] idpf: keep the mailbox up while tearing down vports on shutdown
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
0 siblings, 0 replies; 13+ messages in thread
From: netdev-bot+sashiko @ 2026-12-05 20:47 UTC (permalink / raw)
To: anthony.l.nguyen
Cc: davem, kuba, pabeni, edumazet, andrew+netdev, willemb, netdev,
tianxun.ng, oss.patchbox, luckilystar08, emil.s.tantilov,
richardcochran, milena.olech, konstantin.ilichev, stable,
Samuel.salin
Thank you for your contribution! Sashiko AI review found 2 potential
issue(s) to consider.
Critical: 0 · High: 0 · Medium: 2 (1) · 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).
- [Medium] On shutdown, one slow mailbox reply makes the driver give up
on the rest of the device teardown, which can bring back the bug this…
- [Medium] When the control plane stops answering, shutdown can now hang
for up to 60 s per PF.
Pre-existing issues:
- [Medium] idpf_mac_filter_async_handler() (idpf_virtchnl.c:3892) indexes
adapter->vport_config[] with the vport_id the device assigned…
--
idpf: keep the mailbox up while tearing down vports on shutdown
This commit sets IDPF_REMOVE_IN_PROG at the start of idpf_shutdown(). With
the flag set, idpf_vc_core_deinit() keeps the virtchnl transaction manager
up while the vports are destroyed, so the device is told the vports and
queues are gone before a warm reboot. It also caps each teardown
transaction at 500 ms through a new adapter->vc_xn_timeout_ms, and fails
later synchronous ones at once after the first shortened one times out.
> diff --git a/drivers/net/ethernet/intel/idpf/idpf_main.c b/drivers/net/ethernet/intel/idpf/idpf_main.c
> index 129bccaa6baa8..21be83dc82b1b 100644
> --- a/drivers/net/ethernet/intel/idpf/idpf_main.c
> +++ b/drivers/net/ethernet/intel/idpf/idpf_main.c
> @@ -194,8 +194,18 @@ static void idpf_shutdown(struct pci_dev *pdev)
> {
> struct idpf_adapter *adapter = pci_get_drvdata(pdev);
>
> + /* As in idpf_remove(): keep the event task from being requeued, and
> + * destroy the vports while the mailbox is still up.
> + */
> + set_bit(IDPF_REMOVE_IN_PROG, adapter->flags);
> cancel_delayed_work_sync(&adapter->serv_task);
> cancel_delayed_work_sync(&adapter->vc_event_task);
[Severity: Medium]
Can this make a reboot wait up to 60 s per PF when the control plane has
stopped answering?
With IDPF_REMOVE_IN_PROG set here, idpf_vc_core_deinit() takes the
remove_in_prog branch. That branch runs libie_ctlq_xn_shutdown() only
after idpf_deinit_task(). idpf_shutdown() does not cancel stats_task, and
idpf_deinit_task() waits for it while the transaction manager is still up:
idpf_shutdown()
idpf_vc_core_deinit()
idpf_deinit_task()
cancel_delayed_work_sync(&adapter->stats_task);
Suppose idpf_statistics_task() is already blocked in libie_ctlq_xn_send()
on a GET_STATS that read vc_xn_timeout_ms before the WRITE_ONCE() below.
It then waits in wait_for_completion_timeout() for the full
IDPF_VC_XN_DEFAULT_TIMEOUT_MSEC.
Before this patch, shutdown took the !remove_in_prog branch, so
libie_ctlq_xn_shutdown() ran first. That completes every waiting
transaction, and the stats task returned at once.
If the control plane is unresponsive, the stats task is blocked for most
of each cycle (a 60 s wait plus the 10 s requeue). So it is likely to be
in flight when shutdown starts. idpf_remove() already behaved this way.
The commit message says "A request it already has waiting ... keeps its
own timeouts". Is that meant to apply to shutdown too, given the stated
goal that "an unresponsive control plane does not hold up a reboot for
long"?
> +
> + /* Bound the teardown transactions started from here on, so that an
> + * unresponsive control plane costs a single timeout. A reset or a
> + * transaction that is already running keeps its own timeouts.
> + */
> + WRITE_ONCE(adapter->vc_xn_timeout_ms, IDPF_VC_XN_SHUTDOWN_TIMEOUT_MSEC);
> idpf_vc_core_deinit(adapter);
> idpf_deinit_dflt_mbx(adapter);
[Severity: Medium]
This is a pre-existing issue, not one introduced by this patch. Because
the transaction manager now stays up during the shutdown teardown, async
MAC filter error replies can be handled in a new window.
idpf_vport_dealloc() also calls idpf_del_all_mac_filters() on shutdown
now. In idpf_mac_filter_async_handler(), vport_config is indexed by the
vport_id the device assigned, not by the driver's slot index:
drivers/net/ethernet/intel/idpf/idpf_virtchnl.c:idpf_mac_filter_async_handler() {
...
vport = idpf_vid_to_vport(adapter, le32_to_cpu(ma_list->vport_id));
if (!vport)
goto invalid_payload;
vport_config = adapter->vport_config[le32_to_cpu(ma_list->vport_id)];
...
}
idpf_vid_to_vport() maps vport_id to a slot through adapter->vport_ids[].
Other users of the same list index by slot, for example
idpf_del_all_mac_filters():
vport_config = vport->adapter->vport_config[vport->idx];
What happens if the device assigns a vport_id that differs from the slot
index? The handler could work on the wrong mac_filter_list or hit a NULL
vport_config. If vport_id >= max_vports, it could also read past the end
of vport_config[] and then call list_del() through that pointer.
Should this use vport->idx instead?
[ ... ]
> diff --git a/drivers/net/ethernet/intel/idpf/idpf_virtchnl.c b/drivers/net/ethernet/intel/idpf/idpf_virtchnl.c
> index 854eb1f1ada4c..e7a8ccbc35857 100644
> --- a/drivers/net/ethernet/intel/idpf/idpf_virtchnl.c
> +++ b/drivers/net/ethernet/intel/idpf/idpf_virtchnl.c
[ ... ]
> int idpf_send_mb_msg(struct idpf_adapter *adapter,
> struct libie_ctlq_xn_send_params *xn_params,
> void *send_buf, size_t send_buf_size)
> {
> + u32 timeout_ms = READ_ONCE(adapter->vc_xn_timeout_ms);
> struct libie_ctlq_msg ctlq_msg = {};
> + int err = 0;
>
> - if (idpf_is_reset_detected(adapter)) {
> + if (idpf_is_reset_detected(adapter))
> + err = -EBUSY;
> + else if (!timeout_ms)
> + err = -ETIMEDOUT;
> +
> + if (err) {
> if (!libie_cp_can_send_onstack(send_buf_size))
> kfree(send_buf);
>
> - return -EBUSY;
> + return err;
> }
[ ... ]
> @@ -219,10 +231,15 @@ int idpf_send_mb_msg(struct idpf_adapter *adapter,
> xn_params->xnm = adapter->xnm;
> xn_params->ctlq = xn_params->ctlq ? xn_params->ctlq : adapter->asq;
> xn_params->rel_tx_buf = kfree;
> + xn_params->timeout_ms = min_t(u64, xn_params->timeout_ms, timeout_ms);
>
> idpf_mb_clean(xn_params->ctlq, false);
>
> - return libie_ctlq_xn_send(xn_params);
> + err = libie_ctlq_xn_send(xn_params);
> + if (err == -ETIMEDOUT && timeout_ms < IDPF_VC_XN_DEFAULT_TIMEOUT_MSEC)
> + WRITE_ONCE(adapter->vc_xn_timeout_ms, 0);
[Severity: Medium]
Can one slow reply from a control plane that is still alive cancel the
rest of the shutdown teardown?
idpf_shutdown() sets vc_xn_timeout_ms to IDPF_VC_XN_SHUTDOWN_TIMEOUT_MSEC
(500). The first -ETIMEDOUT under that cap sets it to 0. After that,
every idpf_send_mb_msg() call fails the !timeout_ms check above and
returns -ETIMEDOUT without putting anything on the ASQ. This happens even
though idpf_is_reset_detected() still sees a live ARQ.
DISABLE_VPORT is the first message sent from idpf_vport_stop(). If it
takes longer than 500 ms, the rest of the teardown goes like this:
idpf_shutdown()
idpf_vc_core_deinit()
idpf_deinit_task()
idpf_vport_dealloc()
idpf_vport_stop()
idpf_send_disable_vport_msg() <- times out, cap set to 0
idpf_send_disable_queues_msg() <- not sent
idpf_send_map_unmap_queue_vector_msg() <- not sent
...
idpf_vport_queues_rel() <- rings freed
idpf_vport_rel()
idpf_send_destroy_vport_msg() <- not sent
Every later vport is affected the same way. DEALLOC_VECTORS from
idpf_intr_rel() is not sent either.
idpf_vport_stop() ignores those return values. It frees the Tx, Rx and
completion rings while the device may still have the queues enabled.
Wouldn't that leave the device in the state the commit message
describes, writing SW_MARKER completions into the next kernel's memory
after a warm reboot?
The commit message measured about 300 ms for DEALLOC_VECTORS on an idle
control plane. That is 60% of the 500 ms budget, while the normal
timeout is 60 s.
Would a larger shutdown budget help here? Another option would be to set
the cap to 0 only once the device also looks dead. Either would avoid
dropping the teardown messages when the control plane is only slow.
> +
> + return err;
> }
[ ... ]
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261204194642.3048406-1-anthony.l.nguyen%40intel.com
^ permalink raw reply [flat|nested] 13+ messages in thread
* [PATCH net v2 5/6] idpf: fix use-after-free in the PTP auxiliary worker
2026-12-04 19:46 [PATCH net v2 0/6][pull request] Intel Wired LAN Driver Updates 2026-11-25 (idpf) Tony Nguyen
` (3 preceding siblings ...)
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-04 19:46 ` 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-04 19:53 ` [PATCH net v2 0/6][pull request] Intel Wired LAN Driver Updates 2026-11-25 (idpf) netdev-bot+sinfo
6 siblings, 1 reply; 13+ messages in thread
From: Tony Nguyen @ 2026-12-04 19:46 UTC (permalink / raw)
To: davem, kuba, pabeni, edumazet, andrew+netdev, willemb, netdev
Cc: Emil Tantilov, anthony.l.nguyen, oss.patchbox, tianxun.ng,
luckilystar08, richardcochran, milena.olech, konstantin.ilichev,
Madhu Chittim, Naman Gulati, Samuel Salin
From: Emil Tantilov <emil.s.tantilov@intel.com>
idpf_ptp_update_cached_phctime() runs from the PTP auxiliary worker and
walks the Rx queues of every vport to refresh rxq->cached_phc_time. There
is a small window on down that can result in use-after-free, detected by
KASAN:
BUG: KASAN: slab-use-after-free in idpf_ptp_update_cached_phctime+0x367/0x4a0 [idpf]
Write of size 8 at addr ff11002146c2a4a0 by task ptp3/8084
...
idpf_ptp_update_cached_phctime+0x367/0x4a0 [idpf]
idpf_ptp_do_aux_work+0x37/0x50 [idpf]
ptp_aux_kworker+0x64/0xd0
kthread_worker_fn+0x289/0xa20
...
Allocated by task 8615 on cpu 5 at 812.655509s:
idpf_vport_queues_alloc+0x9e5/0x2580 [idpf]
idpf_vport_open.constprop.0+0x12c/0x10f0 [idpf]
idpf_open+0x1bb/0x230 [idpf]
__dev_open+0x2f5/0x7c0
...
Freed by task 8628 on cpu 10 at 814.925757s:
idpf_rxq_group_rel.part.0+0xef/0x5a0 [idpf]
idpf_vport_queues_rel+0xaf/0x140 [idpf]
idpf_vport_stop+0x49e/0x850 [idpf]
idpf_stop+0x6d/0xc0 [idpf]
__dev_close_many+0x24c/0x650
The existing rxq_grps test does not help. It is evaluated before the
pointer is read again, so the worker can equally run past the kfree() and
dereference a NULL rxq_grps with a stale num_rxq_grp.
Add a per vport rxq_grps_lock and use it to serialize every transition of
rsrc->rxq_grps against the worker:
- Teardown: idpf_rxq_group_rel() sets rsrc->rxq_grps to NULL under the
lock before anything reachable through it is freed. The worker
re-reads the pointer under the same lock, so it either sees a live
array while the release path is still blocked on the lock, or sees
NULL and skips that vport. The frees stay outside the lock.
- Allocation: Build the rxq_grps array privately and publish it to
rsrc->rxq_grps under the lock only once every group is complete. The
freeing of the group contents moves to idpf_rxq_grps_free(), which
takes the array explicitly so the allocation error path can unwind
safely.
- Soft reset: idpf_vport_stop() freed rxq_grps and cleared the live
vport's copy under rxq_grps_lock. Drop the stale pointer in the clone
so the memcpy() below does not republish the freed array to
the PTP aux worker before idpf_vport_open() reallocates it. The lock
sits past the offsetof(struct idpf_vport, link_up) boundary that
idpf_initiate_soft_reset() stops its memcpy() at, next to the wait
queues and mutexes that are already kept out of the copy, so a soft
reset never byte-copies it. The data it guards, dflt_qv_rsrc, is
inside that copied region, which is why the clone has to be cleared
rather than relying on the lock alone.
Also, fix the NULL check in idpf_ptp_update_phctime_rxq_grp(). The split
queue case took the address of a member before testing it, which can never
be NULL, so test the rxq_sets[] entry itself.
Fixes: 494565a74502 ("idpf: add support for Rx timestamping")
Reviewed-by: Madhu Chittim <madhu.chittim@intel.com>
Signed-off-by: Emil Tantilov <emil.s.tantilov@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.h | 5 ++
drivers/net/ethernet/intel/idpf/idpf_lib.c | 6 ++
drivers/net/ethernet/intel/idpf/idpf_ptp.c | 16 +++++-
drivers/net/ethernet/intel/idpf/idpf_txrx.c | 64 +++++++++++++++------
4 files changed, 71 insertions(+), 20 deletions(-)
diff --git a/drivers/net/ethernet/intel/idpf/idpf.h b/drivers/net/ethernet/intel/idpf/idpf.h
index 533b069d97f9..c2631ac35a8b 100644
--- a/drivers/net/ethernet/intel/idpf/idpf.h
+++ b/drivers/net/ethernet/intel/idpf/idpf.h
@@ -373,6 +373,8 @@ struct idpf_q_vec_rsrc {
* @default_vport: Use this vport if one isn't specified
* @crc_enable: Enable CRC insertion offload
* @link_up: True if link is up
+ * @rxq_grps_lock: Serializes every transition of the @dflt_qv_rsrc.rxq_grps
+ * pointer of a vport against the PTP auxiliary worker
* @tx_tstamp_caps: Capabilities negotiated for Tx timestamping
* @tstamp_config: The Tx tstamp config
* @tstamp_task: Tx timestamping task
@@ -406,6 +408,9 @@ struct idpf_vport {
bool crc_enable;
bool link_up;
+ /* Must be past the point idpf_initiate_soft_reset() memcpy()s */
+ spinlock_t rxq_grps_lock;
+
struct idpf_ptp_vport_tx_tstamp_caps *tx_tstamp_caps;
struct kernel_hwtstamp_config tstamp_config;
struct work_struct tstamp_task;
diff --git a/drivers/net/ethernet/intel/idpf/idpf_lib.c b/drivers/net/ethernet/intel/idpf/idpf_lib.c
index 062d2f540254..38cb91beacd0 100644
--- a/drivers/net/ethernet/intel/idpf/idpf_lib.c
+++ b/drivers/net/ethernet/intel/idpf/idpf_lib.c
@@ -1295,6 +1295,7 @@ static struct idpf_vport *idpf_vport_alloc(struct idpf_adapter *adapter,
vport->compln_clean_budget = IDPF_TX_COMPLQ_CLEAN_BUDGET;
vport->default_vport = adapter->num_alloc_vports <
idpf_get_default_vports(adapter);
+ spin_lock_init(&vport->rxq_grps_lock);
rsrc = &vport->dflt_qv_rsrc;
rsrc->dev = &adapter->pdev->dev;
@@ -2097,6 +2098,11 @@ int idpf_initiate_soft_reset(struct idpf_vport *vport,
} else {
set_bit(IDPF_VPORT_DEL_QUEUES, vport->flags);
idpf_vport_stop(vport, false);
+
+ /* Drop the stale pointer in the clone, as rxq_grps was freed
+ * by idpf_vport_stop().
+ */
+ new_rsrc->rxq_grps = NULL;
}
err = idpf_send_add_queues_msg(adapter, vport_config, new_rsrc,
diff --git a/drivers/net/ethernet/intel/idpf/idpf_ptp.c b/drivers/net/ethernet/intel/idpf/idpf_ptp.c
index 71fe8b2a8b4e..9b15973d2f7e 100644
--- a/drivers/net/ethernet/intel/idpf/idpf_ptp.c
+++ b/drivers/net/ethernet/intel/idpf/idpf_ptp.c
@@ -348,9 +348,11 @@ idpf_ptp_update_phctime_rxq_grp(const struct idpf_rxq_group *grp, bool split,
}
} else {
for (i = 0; i < grp->splitq.num_rxq_sets; i++) {
+ if (!grp->splitq.rxq_sets[i])
+ continue;
+
rxq = &grp->splitq.rxq_sets[i]->rxq;
- if (rxq)
- WRITE_ONCE(rxq->cached_phc_time, systime);
+ WRITE_ONCE(rxq->cached_phc_time, systime);
}
}
}
@@ -387,10 +389,17 @@ static int idpf_ptp_update_cached_phctime(struct idpf_adapter *adapter)
struct idpf_q_vec_rsrc *rsrc;
bool split;
- if (!vport || !vport->dflt_qv_rsrc.rxq_grps)
+ if (!vport)
continue;
rsrc = &vport->dflt_qv_rsrc;
+
+ spin_lock(&vport->rxq_grps_lock);
+ if (!rsrc->rxq_grps) {
+ spin_unlock(&vport->rxq_grps_lock);
+ continue;
+ }
+
split = idpf_is_queue_model_split(rsrc->rxq_model);
for (u16 i = 0; i < rsrc->num_rxq_grp; i++) {
@@ -398,6 +407,7 @@ static int idpf_ptp_update_cached_phctime(struct idpf_adapter *adapter)
idpf_ptp_update_phctime_rxq_grp(grp, split, systime);
}
+ spin_unlock(&vport->rxq_grps_lock);
}
return 0;
diff --git a/drivers/net/ethernet/intel/idpf/idpf_txrx.c b/drivers/net/ethernet/intel/idpf/idpf_txrx.c
index 281b96daa5c1..aaa3ed3b744b 100644
--- a/drivers/net/ethernet/intel/idpf/idpf_txrx.c
+++ b/drivers/net/ethernet/intel/idpf/idpf_txrx.c
@@ -1357,16 +1357,15 @@ static void idpf_rxq_sw_queue_rel(struct idpf_rxq_group *rx_qgrp)
}
/**
- * idpf_rxq_group_rel - Release all resources for rxq groups
+ * idpf_rxq_grps_free - Free an Rx queue group array and everything in it
* @rsrc: pointer to queue and vector resources
+ * @rxq_grps: group array to free, not reachable through @rsrc any more
*/
-static void idpf_rxq_group_rel(struct idpf_q_vec_rsrc *rsrc)
+static void idpf_rxq_grps_free(struct idpf_q_vec_rsrc *rsrc,
+ struct idpf_rxq_group *rxq_grps)
{
- if (!rsrc->rxq_grps)
- return;
-
for (unsigned int i = 0; i < rsrc->num_rxq_grp; i++) {
- struct idpf_rxq_group *rx_qgrp = &rsrc->rxq_grps[i];
+ struct idpf_rxq_group *rx_qgrp = &rxq_grps[i];
u16 num_rxq;
if (idpf_is_queue_model_split(rsrc->rxq_model)) {
@@ -1387,18 +1386,40 @@ static void idpf_rxq_group_rel(struct idpf_q_vec_rsrc *rsrc)
}
}
}
- kfree(rsrc->rxq_grps);
+ kfree(rxq_grps);
+}
+
+/**
+ * idpf_rxq_group_rel - Release all resources for rxq groups
+ * @vport: vport the queue groups belong to
+ * @rsrc: pointer to queue and vector resources
+ */
+static void idpf_rxq_group_rel(struct idpf_vport *vport,
+ struct idpf_q_vec_rsrc *rsrc)
+{
+ struct idpf_rxq_group *rxq_grps;
+
+ if (!rsrc->rxq_grps)
+ return;
+
+ spin_lock(&vport->rxq_grps_lock);
+ rxq_grps = rsrc->rxq_grps;
rsrc->rxq_grps = NULL;
+ spin_unlock(&vport->rxq_grps_lock);
+
+ idpf_rxq_grps_free(rsrc, rxq_grps);
}
/**
* idpf_vport_queue_grp_rel_all - Release all queue groups
+ * @vport: vport the queue groups belong to
* @rsrc: pointer to queue and vector resources
*/
-static void idpf_vport_queue_grp_rel_all(struct idpf_q_vec_rsrc *rsrc)
+static void idpf_vport_queue_grp_rel_all(struct idpf_vport *vport,
+ struct idpf_q_vec_rsrc *rsrc)
{
idpf_txq_group_rel(rsrc);
- idpf_rxq_group_rel(rsrc);
+ idpf_rxq_group_rel(vport, rsrc);
}
/**
@@ -1417,7 +1438,7 @@ void idpf_vport_queues_rel(struct idpf_vport *vport,
idpf_rx_desc_rel_all(rsrc);
idpf_xdpsqs_put(vport);
- idpf_vport_queue_grp_rel_all(rsrc);
+ idpf_vport_queue_grp_rel_all(vport, rsrc);
kfree(vport->txqs);
vport->txqs = NULL;
@@ -1802,18 +1823,19 @@ static int idpf_rxq_group_alloc(struct idpf_vport *vport,
u16 num_rxq)
{
struct idpf_adapter *adapter = vport->adapter;
+ struct idpf_rxq_group *rxq_grps;
bool hs, rsc;
- int err = 0;
+ int err;
- rsrc->rxq_grps = kzalloc_objs(struct idpf_rxq_group, rsrc->num_rxq_grp);
- if (!rsrc->rxq_grps)
+ rxq_grps = kzalloc_objs(struct idpf_rxq_group, rsrc->num_rxq_grp);
+ if (!rxq_grps)
return -ENOMEM;
hs = idpf_vport_get_hsplit(vport) == ETHTOOL_TCP_DATA_SPLIT_ENABLED;
rsc = idpf_is_feature_ena(vport, NETIF_F_GRO_HW);
for (unsigned int i = 0; i < rsrc->num_rxq_grp; i++) {
- struct idpf_rxq_group *rx_qgrp = &rsrc->rxq_grps[i];
+ struct idpf_rxq_group *rx_qgrp = &rxq_grps[i];
rx_qgrp->vport = vport;
if (!idpf_is_queue_model_split(rsrc->rxq_model)) {
@@ -1914,9 +1936,17 @@ static int idpf_rxq_group_alloc(struct idpf_vport *vport,
}
}
+ /* Publish only once every group is built, the PTP aux worker reads
+ * the array as soon as it becomes visible.
+ */
+ spin_lock(&vport->rxq_grps_lock);
+ rsrc->rxq_grps = rxq_grps;
+ spin_unlock(&vport->rxq_grps_lock);
+
+ return 0;
+
err_alloc:
- if (err)
- idpf_rxq_group_rel(rsrc);
+ idpf_rxq_grps_free(rsrc, rxq_grps);
return err;
}
@@ -1947,7 +1977,7 @@ static int idpf_vport_queue_grp_alloc_all(struct idpf_vport *vport,
return 0;
err_out:
- idpf_vport_queue_grp_rel_all(rsrc);
+ idpf_vport_queue_grp_rel_all(vport, rsrc);
return err;
}
--
2.47.1
^ permalink raw reply related [flat|nested] 13+ messages in thread* Re: [PATCH net v2 5/6] idpf: fix use-after-free in the PTP auxiliary worker
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
0 siblings, 0 replies; 13+ messages in thread
From: netdev-bot+sashiko @ 2026-12-05 20:47 UTC (permalink / raw)
To: anthony.l.nguyen
Cc: davem, kuba, pabeni, edumazet, andrew+netdev, willemb, netdev,
tianxun.ng, oss.patchbox, luckilystar08, emil.s.tantilov,
richardcochran, milena.olech, konstantin.ilichev, stable,
Samuel.salin
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] The commit message describes the change in
idpf_ptp_update_phctime_rxq_grp()…
- [Low] The patch puts rxq_grps_lock just after link_up in struct
idpf_vport (idpf.h) with the comment "Must be past the point…
Pre-existing issues:
- [High] This problem wasn't introduced by this patch, but the patch only
fixes part of it.
--
idpf: fix use-after-free in the PTP auxiliary worker
This patch adds a per-vport rxq_grps_lock. The lock serializes publishing
and clearing of rsrc->rxq_grps against the PTP auxiliary worker in
idpf_ptp_update_cached_phctime(). The rxq_grps array is now built
privately and published only once it is complete, the soft reset path
clears the stale rxq_grps pointer in the cloned vport, and the split
queue NULL check in idpf_ptp_update_phctime_rxq_grp() is changed.
> diff --git a/drivers/net/ethernet/intel/idpf/idpf.h b/drivers/net/ethernet/intel/idpf/idpf.h
> index 533b069d97f94..c2631ac35a8b4 100644
> --- a/drivers/net/ethernet/intel/idpf/idpf.h
> +++ b/drivers/net/ethernet/intel/idpf/idpf.h
[ ... ]
> @@ -406,6 +408,9 @@ struct idpf_vport {
> bool crc_enable;
> bool link_up;
>
> + /* Must be past the point idpf_initiate_soft_reset() memcpy()s */
> + spinlock_t rxq_grps_lock;
> +
> struct idpf_ptp_vport_tx_tstamp_caps *tx_tstamp_caps;
> struct kernel_hwtstamp_config tstamp_config;
> struct work_struct tstamp_task;
[Severity: Low]
This isn't a bug, but the commit message gives this reason for the
placement:
The lock sits past the offsetof(struct idpf_vport, link_up) boundary
that idpf_initiate_soft_reset() stops its memcpy() at, next to the wait
queues and mutexes that are already kept out of the copy
Are there any wait queues or mutexes past link_up in struct idpf_vport?
After this patch the end of the struct holds rxq_grps_lock,
tx_tstamp_caps, tstamp_config, tstamp_task and tstamp_stats.
The existing comments in idpf_initiate_soft_reset() describe the same
fields:
/* This purposely avoids copying the end of the struct because it
* contains wait_queues and mutexes and other stuff we don't want to
* mess with. ...
and:
/* Avoid copying the wait_queues and mutexes. We do not want to mess
* with those if possible.
*/
rxq_grps_lock is now only correct while it stays past
offsetof(struct idpf_vport, link_up). Could the commit message and these
comments be updated to describe the actual boundary?
> diff --git a/drivers/net/ethernet/intel/idpf/idpf_lib.c b/drivers/net/ethernet/intel/idpf/idpf_lib.c
> index 062d2f540254a..38cb91beacd07 100644
> --- a/drivers/net/ethernet/intel/idpf/idpf_lib.c
> +++ b/drivers/net/ethernet/intel/idpf/idpf_lib.c
[ ... ]
> @@ -2097,6 +2098,11 @@ int idpf_initiate_soft_reset(struct idpf_vport *vport,
> } else {
> set_bit(IDPF_VPORT_DEL_QUEUES, vport->flags);
> idpf_vport_stop(vport, false);
> +
> + /* Drop the stale pointer in the clone, as rxq_grps was freed
> + * by idpf_vport_stop().
> + */
> + new_rsrc->rxq_grps = NULL;
[Severity: High]
This is a pre-existing issue and was not introduced by this patch, but
is clearing only rxq_grps in the clone enough?
idpf_vport_stop() also frees and NULLs rsrc->txq_grps, rsrc->q_vectors
and vport->txqs in the live vport. new_vport still holds the old values
from the first memcpy(), and the later copy writes them back:
memcpy(vport, new_vport, offsetof(struct idpf_vport, link_up));
q_vectors and txq_grps are overwritten at the start of
idpf_vport_intr_alloc() and idpf_txq_group_alloc(). vport->txqs is only
reassigned in idpf_vport_init_fast_path_txqs(), which runs after
idpf_vport_queue_grp_alloc_all():
idpf_vport_queues_alloc() {
err = idpf_vport_queue_grp_alloc_all(vport, rsrc);
if (err)
goto err_out;
err = idpf_vport_init_fast_path_txqs(vport, rsrc);
...
err_out:
idpf_vport_queues_rel(vport, rsrc);
}
Take a soft reset on an up interface, for example from ethtool -L/-G or
an MTU change. If idpf_vport_open()->idpf_vport_queues_alloc()->
idpf_vport_queue_grp_alloc_all() fails with -ENOMEM, does
idpf_vport_queues_rel() then work on the stale vport->txqs?
idpf_vport_queues_rel() {
...
idpf_xdpsqs_put(vport);
idpf_vport_queue_grp_rel_all(vport, rsrc);
kfree(vport->txqs);
vport->txqs = NULL;
}
With an XDP program attached, idpf_xdpsqs_put() would read the freed
vport->txqs[i]. Then kfree(vport->txqs) would free the same pointer a
second time.
Should the clone drop txqs as well, and possibly txq_grps and q_vectors,
in the same way as rxq_grps?
> diff --git a/drivers/net/ethernet/intel/idpf/idpf_ptp.c b/drivers/net/ethernet/intel/idpf/idpf_ptp.c
> index 71fe8b2a8b4e4..9b15973d2f7ec 100644
> --- a/drivers/net/ethernet/intel/idpf/idpf_ptp.c
> +++ b/drivers/net/ethernet/intel/idpf/idpf_ptp.c
> @@ -348,9 +348,11 @@ idpf_ptp_update_phctime_rxq_grp(const struct idpf_rxq_group *grp, bool split,
> }
> } else {
> for (i = 0; i < grp->splitq.num_rxq_sets; i++) {
> + if (!grp->splitq.rxq_sets[i])
> + continue;
> +
> rxq = &grp->splitq.rxq_sets[i]->rxq;
> - if (rxq)
> - WRITE_ONCE(rxq->cached_phc_time, systime);
> + WRITE_ONCE(rxq->cached_phc_time, systime);
[Severity: Low]
The commit message calls this change a fix:
Also, fix the NULL check in idpf_ptp_update_phctime_rxq_grp(). The split
queue case took the address of a member before testing it, which can never
be NULL, so test the rxq_sets[] entry itself.
Is that description accurate? rxq is the first member of struct
idpf_rxq_set:
struct idpf_rxq_set {
struct idpf_rx_queue rxq;
struct idpf_sw_queue *refillq[IDPF_MAX_BUFQS_PER_RXQ_GRP];
};
So &grp->splitq.rxq_sets[i]->rxq has the same value as
grp->splitq.rxq_sets[i]. The kernel builds with
-fno-delete-null-pointer-checks, so the old if (rxq) test did skip NULL
entries.
The new check is a reasonable cleanup. Since the array is now published
only when fully built, the worker should not see a NULL entry anyway.
Could the commit message call this a cleanup rather than a fix, so it
does not suggest there was a separate NULL dereference?
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261204194642.3048406-1-anthony.l.nguyen%40intel.com
^ permalink raw reply [flat|nested] 13+ messages in thread
* [PATCH net v2 6/6] idpf: release PTP before freeing vports on the init task error path
2026-12-04 19:46 [PATCH net v2 0/6][pull request] Intel Wired LAN Driver Updates 2026-11-25 (idpf) Tony Nguyen
` (4 preceding siblings ...)
2026-12-04 19:46 ` [PATCH net v2 5/6] idpf: fix use-after-free in the PTP auxiliary worker Tony Nguyen
@ 2026-12-04 19:46 ` Tony Nguyen
2026-12-05 20:47 ` netdev-bot+sashiko
2026-12-04 19:53 ` [PATCH net v2 0/6][pull request] Intel Wired LAN Driver Updates 2026-11-25 (idpf) netdev-bot+sinfo
6 siblings, 1 reply; 13+ messages in thread
From: Tony Nguyen @ 2026-12-04 19:46 UTC (permalink / raw)
To: davem, kuba, pabeni, edumazet, andrew+netdev, willemb, netdev
Cc: Emil Tantilov, anthony.l.nguyen, oss.patchbox, tianxun.ng,
luckilystar08, richardcochran, milena.olech, konstantin.ilichev,
Madhu Chittim, Naman Gulati, Samuel Salin
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
^ permalink raw reply related [flat|nested] 13+ messages in thread* Re: [PATCH net v2 6/6] idpf: release PTP before freeing vports on the init task error path
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
0 siblings, 0 replies; 13+ messages in thread
From: netdev-bot+sashiko @ 2026-12-05 20:47 UTC (permalink / raw)
To: anthony.l.nguyen
Cc: davem, kuba, pabeni, edumazet, andrew+netdev, willemb, netdev,
tianxun.ng, oss.patchbox, luckilystar08, emil.s.tantilov,
richardcochran, milena.olech, konstantin.ilichev, stable,
Samuel.salin
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
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH net v2 0/6][pull request] Intel Wired LAN Driver Updates 2026-11-25 (idpf)
2026-12-04 19:46 [PATCH net v2 0/6][pull request] Intel Wired LAN Driver Updates 2026-11-25 (idpf) Tony Nguyen
` (5 preceding siblings ...)
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-04 19:53 ` netdev-bot+sinfo
6 siblings, 0 replies; 13+ messages in thread
From: netdev-bot+sinfo @ 2026-12-04 19:53 UTC (permalink / raw)
To: Tony Nguyen
Cc: davem, kuba, pabeni, edumazet, andrew+netdev, willemb, netdev,
oss.patchbox, tianxun.ng, luckilystar08, emil.s.tantilov,
richardcochran, milena.olech, konstantin.ilichev
Hi!
This is an automated message. This series looks like a fix, but its
commit messages seem to be missing some information:
- How the issue was discovered, e.g. hit in production, hit during
development, syzbot report, manual code inspection, LLM or static
analysis tool scan.
- Whether the issue was actually triggered, or is only theoretical
(e.g. found by LLM and not proven at runtime). If it was triggered
please include the symptoms, like the stack trace or kernel messages.
Please do not repost the series just to address the above. Instead,
reply to this email with the missing information, so that reviewers
can take it into account.
*IMPORTANT*: If you do repost (for other reasons) - please include
the relevant info in the cover letter or commit messages.
--
The evaluation is done by an LLM so it may be wrong, if you think
that is the case please reply and explain.
^ permalink raw reply [flat|nested] 13+ messages in thread