Article View: linux.kernel.netdev
Article #6204[PATCH net v5 04/13] ice: set in_use only after preparing Tx timestamp index
From: Jacob Keller
Date: Wed, 21 Oct 2026 22:12
Date: Wed, 21 Oct 2026 22:12
65 lines
12794 bytes
12794 bytes
The ice_ptp_request_ts() function is used to request a timestamp index for
use with a packet. When reserving an index, it sets the start time and
saves a pointer to the skb into the appropriate index. The function marks
the in_use bit first before doing any of these steps. The IRQ handler which
clears the timestamps reads the in_use bits uses a lockless flow for
reading the in_use bits to determine which ones are in-use. This is
necessary as actually processing a complete timestamp must be able to sleep
so we cannot hold the timestamp tracker lock over the entire sequence.
Additionally, blocking the Tx hotpath with such a lock indefinitely would
be problematic.
However, the existing flow now has a very narrow window where the IRQ
handler could see a timestamp as in-use but read a stale value for its
"start" time.
Fix this by ordering the sequence to mark the in_use bit last, and add a
memory barrier to prevent re-ordering of the previous writes to setup the
index.
This was found and reported by Sashiko while reviewing an unrelated change.
Closes: https://sashiko.dev/#/patchset/20260821-jk-e825c-minimized-fixes-v1-0-9d0731eb4858%40intel.com?part=7
Fixes: ea9b847cda64 ("ice: enable transmit timestamps for E810 devices")
Signed-off-by: Jacob Keller <jacob.e.keller@intel.com>
---
drivers/net/ethernet/intel/ice/ice_ptp.c | 12 ++++++++++--
1 file changed, 10 insertions(+), 2 deletions(-)
diff --git a/drivers/net/ethernet/intel/ice/ice_ptp.c b/drivers/net/ethernet/intel/ice/ice_ptp.c
index 7a1deb3ea212..1e6ba6bbf6c2 100644
--- a/drivers/net/ethernet/intel/ice/ice_ptp.c
+++ b/drivers/net/ethernet/intel/ice/ice_ptp.c
@@ -592,6 +592,12 @@ static void ice_ptp_process_tx_tstamp(struct ice_ptp_tx *tx)
bool drop_ts = !link_up;
struct sk_buff *skb;
+ /* Paired with smp_mb__before_atomic() in ice_ptp_request_ts()
+ * to ensure ordering the in_use bitmap and the indexed fields
+ * in the tstamps array.
+ */
+ smp_rmb();
+
/* Drop packets which have waited for more than 2 seconds */
if (time_is_before_jiffies(tx->tstamps[idx].start + 2 * HZ)) {
drop_ts = true;
@@ -2670,11 +2676,13 @@ s8 ice_ptp_request_ts(struct ice_ptp_tx *tx, struct sk_buff *skb)
* a reference to the skb and the start time to allow discarding old
* requests.
*/
- set_bit(idx, tx->in_use);
- clear_bit(idx, tx->stale);
tx->tstamps[idx].start = jiffies;
tx->tstamps[idx].skb = skb_get(skb);
skb_shinfo(skb)->tx_flags |= SKBTX_IN_PROGRESS;
+ clear_bit(idx, tx->stale);
+ /* Ensure index is setup before marking it as used */
+ smp_mb__before_atomic();
+ set_bit(idx, tx->in_use);
ice_trace(tx_tstamp_request, skb, idx);
}
--
2.56.0.212.g129ede20d986
Technical Details
Message-ID:
<20261021-jk-e825c-timestamp-processing-logic-fixes-srcu-v5-4-72289a4ac8eb@intel.com>Path:
mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-350269-linux-kernel-netdev=dewy.ruReferences:
<20261021-jk-e825c-timestamp-processing-logic-fixes-srcu-v5-0-72289a4ac8eb@intel.com>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-350269-linux-kernel-netdev=dewy.ru From: jacob.e.keller@intel.com (Jacob Keller) Newsgroups: linux.kernel.netdev Subject: [PATCH net v5 04/13] ice: set in_use only after preparing Tx timestamp index Date: Wed, 21 Oct 2026 15:12:49 -0700 Organization: Usenet Network Message-ID: <20261021-jk-e825c-timestamp-processing-logic-fixes-srcu-v5-4-72289a4ac8eb@intel.com> References: <20261021-jk-e825c-timestamp-processing-logic-fixes-srcu-v5-0-72289a4ac8eb@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Injection-Info: usenet.network; logging-data="75634"; mail-complaints-to="abuse@usenet.network" Cancel-Lock: sha1:DfezD+pQIS9PI7f4+nUgdESHoPU= sha256:N19ij7QgphdYR8kvhpiFiPsF9dExSR+W0/yRpl7YOuU= sha1:0XzWI0n0O8PHsA6ujkcoJ5lAmic= sha256:GG+nfF2xaFc9ol5HV0MpLoJMd2joPhiXrlt2a1AOtmk= List-ID: <netdev.vger.kernel.org> X-Mailpost-Empty-Hdrs: X-Spam-Level X-Received: from localhost (localhost [127.0.0.1]) by mail.dewy.ru (Postfix) with ESMTP id 904BC11113C; Thu, 22 Oct 2026 01:15:56 +0300 (MSK) X-Virus-Scanned: Debian amavisd-new at usenet.network X-Spam-Flag: NO X-Spam-Score: -3.05 X-Spam-Status: No, score=-3.05 tagged_above=-9999 required=6.31 tests=[DCC_REPUT_70_89=0.1, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, HEADER_FROM_DIFFERENT_DOMAINS=0.25, MAILING_LIST_MULTI=-1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, URIBL_BLOCKED=0.001] autolearn=ham autolearn_force=no X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (2048-bit key) header.d=intel.com X-Received: from mail.dewy.ru ([127.0.0.1]) by localhost (mail.dewy.ru [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id JyBkyaLhlt5y; Thu, 22 Oct 2026 01:15:53 +0300 (MSK) X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=netdev+bounces-350269-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> X-Authentication-Results: OpenDMARC; dmarc=fail (p=none dis=none) header.from=intel.com X-Received: from sea.lore.kernel.org (sea.lore.kernel.org [172.234.253.10]) by mail.dewy.ru (Postfix) with ESMTPS id 3ABD81110F9; Thu, 22 Oct 2026 01:15:45 +0300 (MSK) X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92]) by sea.lore.kernel.org (Postfix) with ESMTP id CB2673F2AF; Wed, 21 Oct 2026 22:13:25 +0000 (UTC) X-Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1 X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass; t=1792620805; b=IDb4MGbOUwxCMEcdFK53DNOxSk4YqtkEvILRfFMuLN71SabkW69gzDczGig+rMsctc2Y /QSqWqPtxBUCQw0N9fVRIvkIXuwIrp825GKmB8M7nFFvUyMs4rKz+FF/UFUb78r8PaKZ8 Q4nCCufeC0cL7qNCd2284A+Hvufe7x8jtB5/5Jxbwfm7X/IDhOL+0zscQ90ufQGc/GBKU 92Os4aG7piVhEX6b4so4DGjtILTWrExvgS/7/mCjr5EMFpJQW7ESOvAYLSXAKXhVuoxBb ipwDQzq57SFfLNRjLCESI5rM6OhdJ52daRZpXyUqr1jdEX3hpEBHy1gjtWJ15/BiytA== X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1792620805; h=X-Original-To:Received:DMARC-Filter:DKIM-Signature: X-CSE-ConnectionGUID:X-CSE-MsgGUID:X-IronPort-AV:X-IronPort-AV: Received:X-CSE-ConnectionGUID:X-CSE-MsgGUID:X-ExtLoop1:X-IronPort-AV: Received:From:Date:Subject:X-Mailing-List:List-Id:List-Post:List-Help: List-Subscribe:List-Unsubscribe:List-Owner:Precedence:MIME-Version: Content-Type:Content-Transfer-Encoding:Message-Id:References: In-Reply-To:To:Cc:X-Mailer:X-Developer-Signature:X-Developer-Key; bh=sX1Q2gW/j3CRYdAcj8pkc2j0bb8JZF+UmyYr8waVAVo=; b=u29Aq2jrzv3ztGoC6FJhMOObQNsw7KqRS12Hb8jeWX/3jQY03/eXMEp7G5ieKPL/iVAH 4l3nJNBFD99baZeqBuAdvwj25U+SN9XWeHC1rTl6fqZuH3icwK35tduPTdBKoAQhsprCo oPf5kzYLD12DWsUpRxK+9IwlEH6b/uD1CC72AFyiCKI50iKxber9tx+2XnMQ+V7rp+02Q 3WEg/GYw6J5kFwxjVqI2EtJNiugH8PCjLn9SAvjA3wsdthd14ZKCjcsBRFjagoZ47xbdF 3mMkQKO5vod1gDb7cTAalV6d865kIY4/bTcweINa7NKxQslMEHerpt8ZHGBHimQvNcA== X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dkim=pass header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=QdIrmbiC; dmarc=pass header.from=intel.com; spf=pass smtp.mailfrom=intel.com; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1 X-Received: from localhost.localdomain (localhost [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id A01D8606A321; Wed, 21 Oct 2026 22:13:25 +0000 (UTC) X-Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key, unprotected) header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=QdIrmbiC X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=198.175.65.15 X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1792620804; b=33gxC05jBArstqNP9tRAM2e4K6smY+gsB9zn6oUKdBmOGpsT8HeI5KZ1wLUiGIw2bNoJ VMl/t+Uii31mBEAvi/yJY5M6fteSUUSJntK7OQ+/TYDVr6ALheVry1a8H/XQdTh7JK87D cjbN7xafE4pqPW1swk6GWoe482Is/crU6qrabtW9Gn+SVHpP8YZ1XfzRV3VS0ruiOOMBP tsWzr4fkXP9V3sjDIGI0cgJ9CHqYYLwYXV0Okb5p5PuGT60JKXG8fmumukzz1Op0OAGtt /9pYcoc4N2k82EAALSFqjFMjvQhR2xr1Y6ygcO6l+TQJJpgHi5sqlahiXgzOkkoBgTg== X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1792620804; h=DMARC-Filter:DKIM-Signature:X-CSE-ConnectionGUID:X-CSE-MsgGUID: X-IronPort-AV:X-IronPort-AV:Received:X-CSE-ConnectionGUID: X-CSE-MsgGUID:X-ExtLoop1:X-IronPort-AV:Received:From:Date:Subject: MIME-Version:Content-Type:Content-Transfer-Encoding:Message-Id: References:In-Reply-To:To:Cc:X-Mailer:X-Developer-Signature: X-Developer-Key; bh=sX1Q2gW/j3CRYdAcj8pkc2j0bb8JZF+UmyYr8waVAVo=; b=TWX3cwxFDtRYBpVhDpfdJlPByjpdgZ6Zx6RQkGBqokj9qSH6QpHO69qtn1uC0I1bd4iI Z1GfChd8vrbzkRD1PpUU3CGUO8fRYhlKfslMUcRhZ2+unfMuOuEd+R8WMnna1J+/mj4eq FWrY+2hY7WSewRI8ourMCukUeV1mXjp9zIHFXKfs6fNygu1TjYNQm2u4DztUToJ7jIspF HlVGpgD+18qtsEwHSonVYb2iSjgzBTIN6s7M7fQKtws+8ODwnxiN5HfCkpP90cOBcQLK8 zPrCHlTFAXrwzkB2wrv2nfpbrwwryxzpFIiybQJTgzHRzdg2fFTiRtpc82aGde0PZsg== X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=intel.com; spf=pass smtp.mailfrom=intel.com; dkim=pass header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=QdIrmbiC; arc=none smtp.remote-ip=198.175.65.15 X-Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.15]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 618B6606A327 for <netdev@vger.kernel.org>; Wed, 21 Oct 2026 22:13:23 +0000 (UTC) X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 618B6606A327 X-Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com X-Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1792620804; x=1824156804; h=from:date:subject:mime-version:content-transfer-encoding: message-id:references:in-reply-to:to:cc; bh=uNafFL4sSCShhKbmP4aPVrpJQzFPp7OUizg2wWDQI3w=; b=QdIrmbiCjVu0yBUyWCFPOC5hPze3r7uMN8x9vR+nPdpL+KTxoIP10wxn jpLrSP57hGHVQfX+5BOuBCgaxe+Skv3Aqp91e8fiKHXyIUv6V+j5+7hC6 8TsYEu/r4xXkyXaKuy1kFDH4iC4MfJHD3Xq5x1LCI9bEel252j6D/PER6 wJVtDasDxgPqKXryFU5v/QrhDxs2+UO9D8YTZTFSXxfmRGtkYJD1pZ5MA CvZ8UBVDMwqX2Gw22iCpQRpytaj369ijBxI2+JImiDbH9G3r5cQ7PyFGe 5R44KXCGiONzOGfjH6bNTvt0nYVwZGMESHRsXU0GcHa0i89Ye2W/uBtaD A==; X-CSE-ConnectionGUID: efRhM4Q0RveAaMZBrp7ZDg== X-CSE-MsgGUID: AIrYwBSXT4yJ3gBbEFRFxw== X-IronPort-AV: E=McAfee;i="6800,10657,11942"; a="1363181" X-IronPort-AV: E=Sophos;i="6.27,171,1787036400"; d="scan'208";a="1363181" X-Received: from fmviesa003.fm.intel.com ([10.60.135.143]) by orvoesa107.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 21 Oct 2026 15:13:11 -0700 X-CSE-ConnectionGUID: jlHTXGD9T8G8+9hQrFGkOA== X-CSE-MsgGUID: tBKErq9jRqSZoXfuSdYiTA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.27,171,1787036400"; d="scan'208";a="3275467" X-Received: from orcnseosdtnuc.amr.corp.intel.com ([10.166.241.20]) by smtpauth.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 21 Oct 2026 15:13:10 -0700 X-Mailing-List: netdev@vger.kernel.org X-List-Post: <mailto:netdev@vger.kernel.org> X-List-Help: <mailto:netdev+help@vger.kernel.org> X-List-Subscribe: <mailto:netdev+subscribe@vger.kernel.org> X-List-Unsubscribe: <mailto:netdev+unsubscribe@vger.kernel.org> X-List-Owner: <mailto:netdev+owner@vger.kernel.org> X-Precedence: list X-In-Reply-To: <20261021-jk-e825c-timestamp-processing-logic-fixes-srcu-v5-0-72289a4ac8eb@intel.com> X-Cc: Grzegorz Nitka <grzegorz.nitka@intel.com>, Aleksandr Loktionov <aleksandr.loktionov@intel.com>, Alexander Nowlin <alexander.nowlin@intel.com>, Tony Nguyen <anthony.l.nguyen@intel.com>, jacob.e.keller@intel.com, maciej.machnikowski@intel.com, przemyslaw.korba@intel.com, sergey.temerkhanov@intel.com, arkadiusz.kubalewski@intel.com, richardcochran@gmail.com, horms@kernel.org X-Mailer: b4 0.17-dev-67df5 X-Developer-Signature: v=1; a=openpgp-sha256; l=2771; i=jacob.e.keller@intel.com; h=from:subject:message-id; bh=uNafFL4sSCShhKbmP4aPVrpJQzFPp7OUizg2wWDQI3w=; b=owGbwMvMwCWWNS3WLp9f4wXjabUkhqybFu+lbb+f3RK2e0bDzLMvdxY5T8hf86fv9brNf5coR c/YqvRnS0cpC4MYF4OsmCKLgkPIyuvGE8K03jjLwcxhZQIZwsDFKQAT+VPA8If/V++8Aw5Lz0w7 GqvVu/FDT+nO7X3mj0PDZ5evqXM4f+osw//kyh519sO6HZdKlmXXFO6a7vTNOM93UmSl853lT9e t9+EBAA== X-Developer-Key: i=jacob.e.keller@intel.com; a=openpgp; fpr=204054A9D73390562AEC431E6A965D3E6F0F28E8