On 11/26/2026 3:40 PM, netd…@kernel.org wrote:
> Thank you for your contribution! Sashiko AI review found 2 potential > issue(s) to consider. > > Critical: 0 · High: 1 · Medium: 0 · Low: 1 > > 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 makes idpf leak the top-level Rx queue group array > every time a vport is stopped, and also on the allocation error path. > - [Low] idpf: inaccurate Fixes trailer citing 1a49cf814fe1 instead of > 494565a74502 > > -- > > idpf: fix use-after-free in the PTP auxiliary worker > > This patch adds a per-vport rxq_grps_lock that serializes changes to > rsrc->rxq_grps against the PTP auxiliary worker. idpf_rxq_group_rel() now > clears the pointer under the lock and passes the array to a new > idpf_rxq_grps_free() helper. idpf_rxq_group_alloc() now builds the array > privately and publishes it at the end. The patch also clears the stale > pointer in the soft reset clone and fixes a NULL check in > idpf_ptp_update_phctime_rxq_grp(). >
>> diff --git a/drivers/net/ethernet/intel/idpf/idpf_txrx.c b/drivers/net/ethernet/intel/idpf/idpf_txrx.c >> index 281b96daa5c1a..968b62f89d873 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)) { >> @@ -1391,14 +1390,37 @@ static void idpf_rxq_group_rel(struct idpf_q_vec_rsrc *rsrc) >> rsrc->rxq_grps = NULL; >> } >> +/** >> + * 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);
> > [Severity: High] > Does this leak the rxq_grps array? > > The last two lines of idpf_rxq_grps_free() are unchanged from the old > idpf_rxq_group_rel(). They still free through rsrc, not through the new > argument: > > drivers/net/ethernet/intel/idpf/idpf_txrx.c:idpf_rxq_grps_free() { > ... > kfree(rsrc->rxq_grps); > rsrc->rxq_grps = NULL; > }
I missed a hunk here when I was resolving a conflict so this correct and I'll need to bring it back.
> By the time the helper runs here, rsrc->rxq_grps has already been set to > NULL under rxq_grps_lock, so this is kfree(NULL). The helper frees the > contents of each group through rxq_grps[i], but the array allocated by > kzalloc_objs() is never freed. > > This path runs on every interface down, every soft reset (channel, ring, > MTU or GRO_HW changes) and every vport dealloc: > > idpf_vport_stop() > idpf_vport_queues_rel() > idpf_vport_queue_grp_rel_all() > idpf_rxq_group_rel() > idpf_rxq_grps_free() > > The error path in idpf_rxq_group_alloc() seems to have the same problem: > > err_alloc: > idpf_rxq_grps_free(rsrc, rxq_grps); > > Here rxq_grps was never published to rsrc->rxq_grps, so again only > kfree(NULL) runs. The err_out path in idpf_vport_queue_grp_alloc_all() > calls idpf_vport_queue_grp_rel_all(), but that does not free it either, > because idpf_rxq_group_rel() returns early when rsrc->rxq_grps is NULL. > > Also, the helper's rsrc->rxq_grps = NULL store writes the protected pointer > without holding rxq_grps_lock. The new @rxq_grps_lock kernel-doc says the > lock serializes every transition of that pointer. > > The same code is still there at the end of the series (73aecc14293f). > > Should idpf_rxq_grps_free() end with kfree(rxq_grps) and leave > rsrc->rxq_grps alone? >
>> +} >> +
> > [ ... ] >
>> diff --git a/drivers/net/ethernet/intel/idpf/idpf_ptp.c b/drivers/net/ethernet/intel/idpf/idpf_ptp.c >> --- 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] > Is the Fixes tag pointing at the right commit? > > As far as I can tell, in 1a49cf814fe1 ("idpf: add Tx timestamp flows") > idpf_ptp_update_cached_phctime() only refreshed > adapter->ptp->cached_phc_time and adapter->ptp->cached_phc_jiffies. It > did not walk the vports and never touched rxq_grps. > > The code this patch fixes seems to come from 494565a74502 ("idpf: add > support for Rx timestamping"). That commit added the > idpf_for_each_vport() loop that reads vport->dflt_qv_rsrc.rxq_grps. > It also added idpf_ptp_update_phctime_rxq_grp(), including the > always-true test on &grp->splitq.rxq_sets[i]->rxq. > > This is going to net and will be picked up for stable. Should the > trailer be the following instead? > > Fixes: 494565a74502 ("idpf: add support for Rx timestamping")
Will update to this Fixes: as well. pw-bot: cr Thanks, Tony
> > As it stands, stable trees that carry 1a49cf814fe1 but not the Rx > timestamping commit would be told they need this fix. They do not > contain the Rx queue walk at all, so the patch would not apply there. >