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=1796503637; b=uWvhNupai7oROOIbLCcHL7qj/gdQZYHH8g+5uUclEvH/POXGHV5mTngf9UBskSHxmS63 P6ucdtBSnudX+Efe01dZBvM1F7FRZBUVlAP83B/anHQQK6qogz8/GB2FN6nAuAGF7vj4A +nu2ujxcu3Od9CFUxFOc3EFuol6p4o5H+dBBn4uK/lNa/uCcmNgn6T+8ZoMKSlH/+k339 1xl6zd+I68fPTO1FxOIWVCajwevNTHSWQ4JMApnz+S6TG5Xok5YB717E7sfyqmYjPd9eP X9vDbGM1yQYbLFH3Gj5k6SFslrLmOkV3et4Z1iObwYkd3RyncjAlqobLo0yG4kTpKsA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796503637; 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=Xh82V5s1TsdGEHY0Wt8/3iT093xFdUDoRxApbKyDXCY=; b=FBzIad2u+UL8SHCDJ/A1j03bEHCecUpWLNhRsMxau1jRKWGE+5VGVTlw+wd6TJ7LyMfT nxtf/JQMHMtxZR2oAPWucEwq2tR+9B4Vu5G1nIWZR+Q6S6QPB5L548d4TK8V1r3l1mvxI oujqyf9rRKJhZYBguuJ5lzgcXk9gVKifjz3BkzD/zHhXrfqhpf+Dxkj0WauhQSMGygUNG tuq3FeaytbNbcrVyF73h8xivrekQAOO0B6T/dnu19qKy02v4/J07X/MGBjS/VJkRRr12q RvgRsCRqlJkanIaSPSE9tqoEzbdWyTI0nlU3eg4HfLS9iUI5DmHNHrCu922flXpwmyw== 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=FfZ9zN0+; 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 59019606A330; Sat, 5 Dec 2026 20:47:17 +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=FfZ9zN0+ Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4E0621F00A07; Sat, 5 Dec 2026 20:47:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796503637; bh=Xh82V5s1TsdGEHY0Wt8/3iT093xFdUDoRxApbKyDXCY=; h=Subject:From:To:Cc:Date:In-Reply-To:References; b=FfZ9zN0+777kXCHriVrBKWtMseMQX0BX40jIXVpQHpRiagAuWfOdY1ku2zMgQ8LMk 36b+A7mkbWRDzGUxkw+FmxurtqiU14rOUBh35ITFsnr2wG7MqdDFRAriNwZH2DQwFz +bKlHCscQlb39QXmnLZhZjnXy7Yta7yzDXNabgIBTnsD2YgTaSEhjsxGN7FCzDDYW3 zo5Lo1EdVoKLlmN96w2R1nxxg14/LxHhoaHeHqPK12+Dnf0U+8f9vWbZErL9YpbIx5 6IEj0zxvKY75fT/c4m+qniXasxKCSF9UBeABhGSWVFO6hvGE9vC90AUwN8ULMY3ojh 2bRSvaKpbbgjg== Subject: Re: [PATCH net v2 5/6] idpf: fix use-after-free in the PTP auxiliary worker 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:15 +0000 Message-ID: <179650363586.3148.10898143589779159807@kernel.org> In-Reply-To: <20261204194642.3048406-6-anthony.l.nguyen@intel.com> References: <20261204194642.3048406-6-anthony.l.nguyen@intel.com> X-sashiko-severity: Low Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit X-Mailing-List: netdev@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 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