From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (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 6D9FF3BE165; Wed, 20 May 2026 17:01:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779296512; cv=none; b=B6x3dJolqayEzk5P/aLqW8cuOQHS+qLiR1RLfuntff3+XTb8jVBRZEwQrRypt2fYCljN+e+RMq9Faw4ZktWqt8oG9F2+r4JdQWI17177wFB9bO4a2/2QwYOEpHbbZFZPeymzSBHfUnzwmBmjCy0WuaEFG6W4JcYxn+X5PgpEfq0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779296512; c=relaxed/simple; bh=UNXaLttS8NBF0c1u43hTQT0TPifK6eh6vrHy//sl0ws=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ighgOhas5WenKNlv8qpHtHgzf7j4U7iu73yo/VqNirlRSxCrBJErBr36gh4nYgjriv7eVziMVr5ZTuXQdW/G9oKxz74Xq6giRBpxrJtyCU950Hvu/ifSWLJkaKjR44Qj7F6wUX21nkWlQFNv1WjTPQDIBidJQG+2QddPJeeqt0o= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=A2ZcnJvF; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="A2ZcnJvF" Received: by smtp.kernel.org (Postfix) with ESMTPSA id D3B2A1F00893; Wed, 20 May 2026 17:01:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1779296511; bh=25h74wbg1wuAlQrXitY+ypmEo2QvPjfJvxnuPKvDdZs=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=A2ZcnJvFvOELMc2AzD2AHKwUcQSo6E6V1+UzjvLMI46txEr9AWjpbuc15zmWWOE06 JnZBh2VvBEgDopE2IpuqG/FxPVmGPuEI/75n70mnofNgVNH9FYOvVx5/rCGL0+IYs2 HlggZkOrlyLVFqOywNK0lsSruaIxzkbvfA78nAOM= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Eric Dumazet , Jakub Kicinski , Sasha Levin Subject: [PATCH 7.0 0786/1146] tcp: annotate data-races around tp->bytes_sent Date: Wed, 20 May 2026 18:17:16 +0200 Message-ID: <20260520162206.009034811@linuxfoundation.org> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260520162148.390695140@linuxfoundation.org> References: <20260520162148.390695140@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 7.0-stable review patch. If anyone has any objections, please let me know. ------------------ From: Eric Dumazet [ Upstream commit ee43e957ce2ec77b2ec47fef28f3c0df6ab01a31 ] tcp_get_timestamping_opt_stats() intentionally runs lockless, we must add READ_ONCE() and WRITE_ONCE() annotations to keep KCSAN happy. Fixes: ba113c3aa79a ("tcp: add data bytes sent stats") Signed-off-by: Eric Dumazet Link: https://patch.msgid.link/20260416200319.3608680-8-edumazet@google.com Signed-off-by: Jakub Kicinski Signed-off-by: Sasha Levin --- net/ipv4/tcp.c | 2 +- net/ipv4/tcp_output.c | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c index 75164510b4232..10c36a68de4b1 100644 --- a/net/ipv4/tcp.c +++ b/net/ipv4/tcp.c @@ -4495,7 +4495,7 @@ struct sk_buff *tcp_get_timestamping_opt_stats(const struct sock *sk, READ_ONCE(tp->write_seq) - READ_ONCE(tp->snd_una))); nla_put_u8(stats, TCP_NLA_CA_STATE, inet_csk(sk)->icsk_ca_state); - nla_put_u64_64bit(stats, TCP_NLA_BYTES_SENT, tp->bytes_sent, + nla_put_u64_64bit(stats, TCP_NLA_BYTES_SENT, READ_ONCE(tp->bytes_sent), TCP_NLA_PAD); nla_put_u64_64bit(stats, TCP_NLA_BYTES_RETRANS, tp->bytes_retrans, TCP_NLA_PAD); diff --git a/net/ipv4/tcp_output.c b/net/ipv4/tcp_output.c index 1bb46aafe4049..2c9ca89aa9e50 100644 --- a/net/ipv4/tcp_output.c +++ b/net/ipv4/tcp_output.c @@ -1670,7 +1670,8 @@ static int __tcp_transmit_skb(struct sock *sk, struct sk_buff *skb, tcp_event_data_sent(tp, sk); WRITE_ONCE(tp->data_segs_out, tp->data_segs_out + tcp_skb_pcount(skb)); - tp->bytes_sent += skb->len - tcp_header_size; + WRITE_ONCE(tp->bytes_sent, + tp->bytes_sent + skb->len - tcp_header_size); } if (after(tcb->end_seq, tp->snd_nxt) || tcb->seq == tcb->end_seq) -- 2.53.0