Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.20]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E604D3905F0 for ; Mon, 1 Jun 2026 09:19:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.20 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780305597; cv=none; b=dILbr83L7d9K/xRiJU6mo7syfeg6lDzKzdNYsrqFkyrMCuTuETkGV1N60jeZhsRpom+PugQO253iKnEeww8Uh/BwleudEAdS8wm2jS+czbmOxy4oTRxPOWBSmCudPjL3OgcLZJoCbStDVZ807NAdDt8vxfndARceik81QjhecF4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780305597; c=relaxed/simple; bh=Icx98AwhzBCEp8Ti51ZHhHCTBbblff8S5UhwQY2RO6g=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=HvQoekKYCMUY8n1XEHabZRRpbAZSc6lsu+g/7+zF01UIvYDve6Y+lKxBVqYaq52242zzq1HuVZdMsWODdVUKKcvKxepaz4u1CywefPdBaZc5QdvI/uPWiM6SBEM9++UaAXG/n3fn5tYV/cQvNT7GU0BYvOXXQwk1tJgVUtT7A3g= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com; spf=pass smtp.mailfrom=intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=O5svpKeV; arc=none smtp.client-ip=198.175.65.20 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="O5svpKeV" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1780305596; x=1811841596; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=Icx98AwhzBCEp8Ti51ZHhHCTBbblff8S5UhwQY2RO6g=; b=O5svpKeVZh5mZgzBCkbd+d9ls5WWeJjUsiMhKj4b3xU+rtbdAxoIlnHw LVjmkmOwiDNnxoDsXQDUjJ1PNFilzy422sB1c3gRwykiaslJ9ZLXnkNtK 7hzj+GPtHTqkAhmMV1okkBvJdxsr7WQZ7JWshaLIkFndF4hU21cr3iz7a bWJOEte6BZtdGvIsiFffYdbPQin7jHEChKlb7fpnrtkj2DHyMLfG4c1a1 kzsi2xAkUVsgCkLFtQjrP6POHGt30J+dbI59L0U+HpcGhrcgvbg3B7jJq P/9s7LwycS+6dH0ItSmHbIlyBgJUm1eBy2/BdCXxNhX6qaw1suRsCh6p9 A==; X-CSE-ConnectionGUID: E4kOikidR+2e4RJhHWOg6g== X-CSE-MsgGUID: fzRwe18ARoO8yD4wt59GDg== X-IronPort-AV: E=McAfee;i="6800,10657,11803"; a="80791628" X-IronPort-AV: E=Sophos;i="6.24,181,1774335600"; d="scan'208";a="80791628" Received: from orviesa004.jf.intel.com ([10.64.159.144]) by orvoesa112.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Jun 2026 02:19:55 -0700 X-CSE-ConnectionGUID: EkOct+TAR6O++KHoK23M2A== X-CSE-MsgGUID: qW9VkmLZRDa2MGEbLvkT8g== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.24,181,1774335600"; d="scan'208";a="247802572" Received: from gnrd8.igk.intel.com (HELO GNRD8) ([10.123.232.137]) by orviesa004.jf.intel.com with ESMTP; 01 Jun 2026 02:19:55 -0700 From: Sergey Temerkhanov To: intel-wired-lan@lists.osuosl.org Cc: netdev@vger.kernel.org Subject: [PATCH iwl-net v3 2/3] ice: Zero out the PTP control PF pointer at ice_adapter cleanup Date: Mon, 1 Jun 2026 09:19:50 +0000 Message-ID: <20260601091951.3017848-3-sergey.temerkhanov@intel.com> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260601091951.3017848-1-sergey.temerkhanov@intel.com> References: <20260601091951.3017848-1-sergey.temerkhanov@intel.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 Tested-by: Frederick Lawler --- 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 348fc73607b5..5f14f58f4343 100644 --- a/drivers/net/ethernet/intel/ice/ice_ptp.c +++ b/drivers/net/ethernet/intel/ice/ice_ptp.c @@ -3107,6 +3107,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; @@ -3386,6 +3398,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) { @@ -3414,6 +3428,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; @@ -3428,6 +3443,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