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=1796503639; b=jcyRNeTjEfBB9I20PK+g5kv7SX+pkx4PNA+tJTL6d/HIgGzlwIIKSlfEjKuvPFTY5y8n 4cAIhYVUM4S0xoftwwvZ38kLWO/2N2pnrEFDRCekuxl1C8gaX4Ljjc8n8fYq8NNTFzqNO +kf1ZqL+IFSVPoC/uPG4gRL4oX6a3UP/gDThFbudcquIbf/r+EMsdPA3ITJATA9oiYpoA ealo9chXnKz4n8PlkPgba4XIidYrcJBEu/TIJYz27osfNse0wsyG3swst1hm5PKrQMvTq vlEMCruR59lAyh7uAaKzBi13jOZ/nzEzREWiOdq44/6/VrEMeYmNSs9f6BqUsHKPMIg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796503639; 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=qz38PMY2FyD0I5PTOK3Ziu+04vxAORd+o70CRnBpMDk=; b=HwoOVCcivmXHTH69wiRknvnntkJ+6NvjqAbkaZ8/eHnBpZV+yBStZzABT8lSP0D3eOIr YyG4Hi1+ty4Ll1N3BhrC8mkP4g5rEI4BsTBmUuzv8U31bN6jgtfXylC50/8hfMaNFmLMh H7kXRHU7UxX8lqFpwoFQkeBvTlHK3kExSmXGxiyvntz26nh9ujFjq5KaqO6xZOkl/Acst e7+FFw05DNWrbLdvogu4Nv6XvAyJitIc4I2b7uGYvinG2nnBT94dfloZH7LV8gMOWVakS iZHx3JmGEe4fHg9SY8rSzWcg4KjWuyRyWfSJYM/a1ko+YbqS2LCYP6Z6ysA1wodTHQw== 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=PdlpSK5s; 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 27EC2606A322; Sat, 5 Dec 2026 20:47:18 +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=PdlpSK5s Received: by smtp.kernel.org (Postfix) with ESMTPSA id CC1601F00A07; Sat, 5 Dec 2026 20:47:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796503638; bh=qz38PMY2FyD0I5PTOK3Ziu+04vxAORd+o70CRnBpMDk=; h=Subject:From:To:Cc:Date:In-Reply-To:References; b=PdlpSK5sF15NCSYVLQ2lQE6/Sdc2FhxiDCkuaNlW4b0+m2xmpo6RSyP2M9c5asjWF l6elsHXiuq3duSTrBAIVedrwcXAoboyctqabCcRs3bVhX7tTeHNupxjoiaDXPrsMWG 7rIYR1/HBtN4s6hsfQHgeuYJDDwCRGxu5Y8xq701Q2wINzxOX+xvRHxIxnMAxSyDIE NealizNpSLP8q9wIRlvRoU5n1pM7OKLBjdbMIajnmvFcs/7rhnyuWJfYVeHBOMHqgH 0cTKMkGEByzWJNPNA8agmtBKFa0u3xIu2d6YeMEW9b/Wi/XUcIkKH3Oe8eKoNWte2g ZemhC1DmlsX3Q== Subject: Re: [PATCH net v2 6/6] idpf: release PTP before freeing vports on the init task error path 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:17 +0000 Message-ID: <179650363738.3148.8011419031325451022@kernel.org> In-Reply-To: <20261204194642.3048406-7-anthony.l.nguyen@intel.com> References: <20261204194642.3048406-7-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] 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