From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from smtp1.osuosl.org (smtp1.osuosl.org [140.211.166.138]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 80A8DCD3430 for ; Mon, 4 May 2026 11:01:05 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp1.osuosl.org (Postfix) with ESMTP id 49EB78451C; Mon, 4 May 2026 11:01:05 +0000 (UTC) X-Virus-Scanned: amavis at osuosl.org Received: from smtp1.osuosl.org ([127.0.0.1]) by localhost (smtp1.osuosl.org [127.0.0.1]) (amavis, port 10024) with ESMTP id ZR1-oFEqDnDQ; Mon, 4 May 2026 11:01:04 +0000 (UTC) X-Comment: SPF check N/A for local connections - client-ip=140.211.166.142; helo=lists1.osuosl.org; envelope-from=intel-wired-lan-bounces@osuosl.org; receiver= DKIM-Filter: OpenDKIM Filter v2.11.0 smtp1.osuosl.org 961768451D DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=osuosl.org; s=default; t=1777892464; bh=INriOp2xI/MeFcW23xGddT0du5qeLVJlXRDIucelsrk=; h=From:To:Date:In-Reply-To:References:Subject:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=4bUYzyBtz+w8w+OIcnnv2haWyn4bmLi0C5TN8/hzahWRwfmk5NZMuhmMCaYeheJv+ zaehgyzis3V5/e37HGtTPZS3bfWoE4ZZVoF9DAoxVSKdKa3FPUHgvhcyHUr36lmx7c GrLx2oVzgljBg4IGZnj57IaRmnyQbdWwsYYhG/S/gHbzUQ6sJspumiSAboLHib8ZEU GxRykgFWw7Tj7v85AxnaJGVwiI4aRigkHNZMieX9//frICsJWJ/+5SojMvnWAGSnVb 09xcg7xkjNXmYQ5+VXKiuaHGsQ349A2iST3xNMIbjsC1axu+o4VNsEVBhxZpiyUhyv a7ZvbHQae5CKA== Received: from lists1.osuosl.org (lists1.osuosl.org [140.211.166.142]) by smtp1.osuosl.org (Postfix) with ESMTP id 961768451D; Mon, 4 May 2026 11:01:04 +0000 (UTC) Received: from smtp4.osuosl.org (smtp4.osuosl.org [IPv6:2605:bc80:3010::137]) by lists1.osuosl.org (Postfix) with ESMTP id 565F225D for ; Mon, 4 May 2026 11:01:03 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp4.osuosl.org (Postfix) with ESMTP id 38F8C41A4A for ; Mon, 4 May 2026 11:01:03 +0000 (UTC) X-Virus-Scanned: amavis at osuosl.org Received: from smtp4.osuosl.org ([127.0.0.1]) by localhost (smtp4.osuosl.org [127.0.0.1]) (amavis, port 10024) with ESMTP id PjnzYJ6mqZhk for ; Mon, 4 May 2026 11:01:02 +0000 (UTC) Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=198.175.65.16; helo=mgamail.intel.com; envelope-from=sergey.temerkhanov@intel.com; receiver= DMARC-Filter: OpenDMARC Filter v1.4.2 smtp4.osuosl.org 21DA741A48 DKIM-Filter: OpenDKIM Filter v2.11.0 smtp4.osuosl.org 21DA741A48 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.16]) by smtp4.osuosl.org (Postfix) with ESMTPS id 21DA741A48 for ; Mon, 4 May 2026 11:01:01 +0000 (UTC) X-CSE-ConnectionGUID: ELUsJV77TYaUmuIIjVl5Cw== X-CSE-MsgGUID: Qb5L/ZihQ0mpwTj06UDh0A== X-IronPort-AV: E=McAfee;i="6800,10657,11775"; a="78939689" X-IronPort-AV: E=Sophos;i="6.23,215,1770624000"; d="scan'208";a="78939689" Received: from orviesa004.jf.intel.com ([10.64.159.144]) by orvoesa108.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 04 May 2026 04:01:02 -0700 X-CSE-ConnectionGUID: v2JZYHBpQj60zBsH0LCR6g== X-CSE-MsgGUID: F8ybxhVbSwmJjkTR2ZoW4w== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.23,215,1770624000"; d="scan'208";a="239792123" Received: from gnrd8.igk.intel.com (HELO GNRD8) ([10.123.232.137]) by orviesa004.jf.intel.com with ESMTP; 04 May 2026 04:01:01 -0700 From: Sergey Temerkhanov To: intel-wired-lan@lists.osuosl.org Date: Mon, 4 May 2026 11:00:57 +0000 Message-ID: <20260504110058.2373236-3-sergey.temerkhanov@intel.com> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260504110058.2373236-1-sergey.temerkhanov@intel.com> References: <20260504110058.2373236-1-sergey.temerkhanov@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Mailman-Original-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1777892463; x=1809428463; h=from:to:subject:date:message-id:in-reply-to:references: mime-version:content-transfer-encoding; bh=sxjykjgBCLVR0+8qf0+QS7+ogMK1l6RLYYcd7zzzzpk=; b=nQernlpLsD69s3D25WTreIre9bQzWmHfeTSFKufoyM+1MnCkB8A02DBO iKV3Dbq5Ke3lh36tLSA+L4cfS4oZSD/D6qkWC1fyyJqLyUY0GlC+1x/+f oR0ed4QEXvhiH80L6G0b+yPD78quig+yMak9uM+gFJktvVSTIGH57f0e0 XKnUeiL1PskR03Pc/HeWChUmZwxt3qlLKo8zg3MXNzXIisVzOLR463A9w iJeyeLfQ5gO1xRP3FR2uBw55l4mZaGMw98Vr/hUuP8VRzddgILx9bB95b MEdR0vOMdGAbPnsXxEpP8tL/OVYP8c0zWQ2CaqQym437fTw8RwtGg9PqC Q==; X-Mailman-Original-Authentication-Results: smtp4.osuosl.org; dmarc=pass (p=none dis=none) header.from=intel.com X-Mailman-Original-Authentication-Results: smtp4.osuosl.org; dkim=pass (2048-bit key, unprotected) header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=nQernlpL Subject: [Intel-wired-lan] [PATCH iwl-net v1 2/3] ice: Zero out the PTP control PF pointer at ice_adapter cleanup X-BeenThere: intel-wired-lan@osuosl.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Intel Wired Ethernet Linux Kernel Driver Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: intel-wired-lan-bounces@osuosl.org Sender: "Intel-wired-lan" Zero out the ctrl_pf pointer in ice_adapter when the control PF is removed. This prevents potential dangling pointer dereference when accessing PTP-related structures from other PFs of the same adapter. Fixes: e800654e85b5b ("ice: Use ice_adapter for PTP shared data instead of auxdev") Signed-off-by: Sergey Temerkhanov Reported-by: Frederick Lawler Closes: https://lkml.indiana.edu/2507.3/01388.html Reviewed-by: Aleksandr Loktionov Reviewed-by: Arkadiusz Kubalewski --- drivers/net/ethernet/intel/ice/ice_ptp.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/drivers/net/ethernet/intel/ice/ice_ptp.c b/drivers/net/ethernet/intel/ice/ice_ptp.c index 1114a862c27b..68e87e267825 100644 --- a/drivers/net/ethernet/intel/ice/ice_ptp.c +++ b/drivers/net/ethernet/intel/ice/ice_ptp.c @@ -3104,6 +3104,18 @@ static void ice_ptp_setup_adapter(struct ice_pf *pf) rcu_assign_pointer(pf->adapter->ctrl_pf, pf); } +static void ice_ptp_cleanup_adapter(struct ice_pf *pf) +{ + /* Zero out adapter->ctrl_pf pointer when the ctrl_pf itself + * is being removed to prevent any secondary PFs from accessing + * it after it is deleted. + */ + if (cmpxchg(&pf->adapter->ctrl_pf, + (struct ice_pf __rcu *)pf, NULL) == + (struct ice_pf __rcu *)pf) + synchronize_rcu(); +} + static int ice_ptp_setup_pf(struct ice_pf *pf) { struct ice_ptp *ptp = &pf->ptp; @@ -3384,6 +3396,8 @@ void ice_ptp_init(struct ice_pf *pf) err_clean_pf: mutex_destroy(&ptp->port.ps_lock); ice_ptp_cleanup_pf(pf); + + ice_ptp_cleanup_adapter(pf); err_exit: /* If we registered a PTP clock, release it */ if (pf->ptp.clock) { @@ -3412,6 +3426,7 @@ void ice_ptp_release(struct ice_pf *pf) if (pf->ptp.state != ICE_PTP_READY) { mutex_destroy(&pf->ptp.port.ps_lock); ice_ptp_cleanup_pf(pf); + ice_ptp_cleanup_adapter(pf); if (pf->ptp.clock) { ptp_clock_unregister(pf->ptp.clock); pf->ptp.clock = NULL; @@ -3426,6 +3441,8 @@ void ice_ptp_release(struct ice_pf *pf) ice_ptp_cleanup_pf(pf); + ice_ptp_cleanup_adapter(pf); + ice_ptp_release_tx_tracker(pf, &pf->ptp.port.tx); ice_ptp_disable_all_extts(pf); -- 2.53.0