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 5/6] idpf: fix use-after-free in the PTP auxiliary worker
Date: Sat, 05 Dec 2026 20:47:15 +0000 [thread overview]
Message-ID: <179650363586.3148.10898143589779159807@kernel.org> (raw)
In-Reply-To: <20261204194642.3048406-6-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] 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
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 [this message]
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
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=179650363586.3148.10898143589779159807@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.