Article View: linux.kernel.netdev
Article #8082[PATCH net 2/6] ice: set in_use only after preparing Tx timestamp index
From: Jacob Keller
Date: Wed, 28 Oct 2026 00:05
Date: Wed, 28 Oct 2026 00:05
65 lines
12653 bytes
12653 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 e6442b956aa9..48fde5561668 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;
@@ -2673,11 +2679,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.215.g47fdf2208c5b
Technical Details
Message-ID:
<20261027-reduction-v1-2-81237c67a361@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-352675-linux-kernel-netdev=dewy.ruReferences:
<20261027-reduction-v1-0-81237c67a361@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-352675-linux-kernel-netdev=dewy.ru From: jacob.e.keller@intel.com (Jacob Keller) Newsgroups: linux.kernel.netdev Subject: [PATCH net 2/6] ice: set in_use only after preparing Tx timestamp index Date: Tue, 27 Oct 2026 17:05:38 -0700 Organization: Usenet Network Message-ID: <20261027-reduction-v1-2-81237c67a361@intel.com> References: <20261027-reduction-v1-0-81237c67a361@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Injection-Info: usenet.network; logging-data="1663693"; mail-complaints-to="abuse@usenet.network" Cancel-Lock: sha1:4d7rrWI3Z6AngMqYvhPh6mqXTd8= sha256:dc8Oa4msmQas/Wj9hflDANP3eWBLKY9S98MTuMuDYIg= sha1:ofh6XlJDFBBk80nFww1kCOfs2V4= sha256:uCwnvsBXqn+Taq5ZI7JcoILUEIZdykmku12lXe1CEXs= 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 2FAE9125C2C; Wed, 28 Oct 2026 03:06:39 +0300 (MSK) X-Virus-Scanned: Debian amavisd-new at usenet.network X-Spam-Flag: NO X-Spam-Score: -3.051 X-Spam-Status: No, score=-3.051 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] 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 kJVenCkCRJ-O; Wed, 28 Oct 2026 03:06:35 +0300 (MSK) X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=104.64.211.4; helo=sin.lore.kernel.org; envelope-from=netdev+bounces-352675-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 sin.lore.kernel.org (sin.lore.kernel.org [104.64.211.4]) by mail.dewy.ru (Postfix) with ESMTPS id 2802E125C29; Wed, 28 Oct 2026 03:06:26 +0300 (MSK) X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92]) by sin.lore.kernel.org (Postfix) with ESMTP id 8EEC626915; Wed, 28 Oct 2026 00:06:09 +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=1793145965; b=FCW+Y/V6bGImGDxICBPhsILDEu7HpgQr2CRd4PtP9XeeWqPlwchhxpRPZ4DKQAHnBvxT z9aH1CnHP3407MH60A99xnRT1FegzMdUygj0tGvZxNLjEo0fTaGQLHTWaoZQm4HdDeYJF 1EB26VLzBZ/ckqT2sW7pdVqkExFhc6QuGBOqTXVxy2YGY9FG8exkVs38djHvmGkx4bX9o wxwmKYKhNIB5IgXpLYGNBpefTot7MdFq47g1RD5axJha07MyGDRoZ99vnwaTQ2Dds0Un9 0wuf+428qU8m0SaYTOntjy8jIEj2cCey/s8sSl+iuvLaESsKcfRdFNOBMiyOG8CXSKQ== X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1793145965; 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=7jQHzbWrvHz2Nv1IzFC4deF5ZMvPhXvyXc2GOgIvoHc=; b=LXPzfXbCIYENYZ6Hgd+2nfkzpY639cgIZKZdMxYK2cNyYNkhxOsU/9YB6QMcwL88rAeL FG2FH0rNHew/bZY3a96f9Eamba1kcRMmbgDql8Lrzw9TZeQ50wOQAQSLQcC9H+aaSYdNy 4KaftwCO5Op9XbPDi/kOZSVNbookgCv+He4QWobupmrOiERFCdlNaiL35mwdjutW0he1r 8bclnwNcRQdA/wUj1TcMd5cFJNqYz1jNy7/X/2OTpah8NsGODMYdgg5K0WHGNG/g/Rdzw 7IXqIc83Q2+6S2fUx2nM6aSHk6Ax1wNgjCNOrxuNtFkLqwSjnn5Wd3d68YHMXhu9qCQ== 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=O4BtAo88; 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 BCCA6606A33B; Wed, 28 Oct 2026 00:06:05 +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=O4BtAo88 X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=192.198.163.7 X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1793145964; b=sRwHzamX50yHwAdommGYlFQ2cD3Ubjq6Hs4f0g7BbObiO9W5O7y23bZr7yUf/bK2CUSL KgOiDWaYgRddWwZlh3Q5Uovih9zkzGLAR7OhDcVYMor1pfTRupA3HmWKV/JNkPcMBg6vd hp1nOl4y9xSl8UyQY1J9P6prY1PQRwuWvz1yZPyC9KSKgCGi598KfNAEQO2Q+3Fqbj0N/ RLNKgZkrBic/ItDnlYRemGc9L1QAPXJKATJM6xzGijRpqCh+pHEPk09wpsxg3BKREjkWt z2x8vEl0boEqX9CCC8hLBfL8aFdQ2FVBuorb343GXVz1m2pWjDoUoa6P7laK29pHhHw== X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1793145964; 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=7jQHzbWrvHz2Nv1IzFC4deF5ZMvPhXvyXc2GOgIvoHc=; b=mb2nO5hOa30Vods0uueDur53zOnyb1FSRE/Tc3+w21otEyKJRFbhd/QF5LNuzIgAqxY3 rwAZnW5kH06IswvYd9i3EJDWJQvMrjMcrZ7pUHss8W+zo6eAIzJqwjsV9PdCCMq5Q75aJ YUSKEbvNDD7EkOVsA2biG81vmCnZuVlpFQed/tV+6mFdo7vp/BJ8JuRXfbpfAGSfTxVVX c3hTUGM8F5rf96slw5QO+230vr5NMc1xTiSpJCrzH7KOqsDo6eHQ/8kY5OPet2OSXzWee f8g/49soa2wxZRV6OR5s0hBc6L/UQZzWKDR5xgbkTmmYndVtN6HndyI+lG6JABZyCcg== 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=O4BtAo88; arc=none smtp.remote-ip=192.198.163.7 X-Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.7]) (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 142F0606A321 for <netdev@vger.kernel.org>; Wed, 28 Oct 2026 00:06:03 +0000 (UTC) X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 142F0606A321 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=1793145964; x=1824681964; h=from:date:subject:mime-version:content-transfer-encoding: message-id:references:in-reply-to:to:cc; bh=6xryLsaw93MP+m+iDKJzE2PqKIrqHNlYpTYEzoAmo48=; b=O4BtAo88K/EDViVfC6A6VDDxDt2A9drfeXOTaNLqVj9iCj7tg2SmJq6N KycWc1v2nLsVJ5Vamim/BursBnE14TuJUtXHW5BqErnEPqRLJ7xU5mTVf 9DX6VrCqMrkP5kFF5OdSGJO10Ldesj8Q4x5277J9GlkQyYtclQ4zyVeEm cGj1pGRFcz9ErWUP1vEIRMMNeJ7FEFJl6t2GvuqSskBIeTyQwS2Evb8Nr W51ozJrahx7f/fxBGfoyoW3yWjKlM5jb0Y3jbJMgjBnoB3TxJYwjs3qjN tzlHpsc8lz59I/mUVIZWtxiWpEW8XaQ7PdWW384NQc7DqWF1opXSQ73Gi w==; X-CSE-ConnectionGUID: W9uZ9IsgQvCa9oJpGyOBIw== X-CSE-MsgGUID: pwmCGGWGRFyxSh1WU0Nk7w== X-IronPort-AV: E=McAfee;i="6800,10657,11948"; a="1747207" X-IronPort-AV: E=Sophos;i="6.27,181,1787036400"; d="scan'208";a="1747207" X-Received: from fmviesa003.fm.intel.com ([10.60.135.143]) by fmvoesa101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Oct 2026 17:06:02 -0700 X-CSE-ConnectionGUID: JQ87Qe8RTQ23sPNWnpdbCw== X-CSE-MsgGUID: VfgKxFZ0SvamUwzWTXBYhQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.27,181,1787036400"; d="scan'208";a="4776650" X-Received: from orcnseosdtjek.amr.corp.intel.com ([10.166.28.128]) by smtpauth.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Oct 2026 17:06:01 -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: <20261027-reduction-v1-0-81237c67a361@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=6xryLsaw93MP+m+iDKJzE2PqKIrqHNlYpTYEzoAmo48=; b=owGbwMvMwCWWNS3WLp9f4wXjabUkhqyHNskFim1H3fmNYr9+FxM9MCN9hYIiRxSPU6QR75ao4 0xfbN51lLIwiHExyIopsig4hKy8bjwhTOuNsxzMHFYmkCEMXJwCMBHtKIZ/dt7zbf5KzUo4ad7n 5rpHbOfGsNRpM/LOSelOSKnfO7nmJMN/p1+7599Z0HYhqNs222e1qqrnh7UBH5jm5Lscep6WVs3 ECwA= X-Developer-Key: i=jacob.e.keller@intel.com; a=openpgp; fpr=204054A9D73390562AEC431E6A965D3E6F0F28E8