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 B589F1C3BFC; Wed, 20 May 2026 17:43:55 +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=1779299036; cv=none; b=CSXKdUNz/6lbs9iQAE16Mp8Av9hZzZJHW1V1/q7/T0bgDYqXdPZSTwRzkIEZin+eHcTdmBuof/hMOwuiWiCnD47d/Qvv/zDCu5J2aEvT6+iqt+tI/pZz5TMSEzSH1R2/3i/obQ+HvkH0nxfKX/oMXuM6n+dJ7trJWE+7u59QjA0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779299036; c=relaxed/simple; bh=Oq/y3Dpyil6z5RxD6GLCQYobb8apcP78zQY0kHlDS+E=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=MGZOwtnu3xzsL7Esl46VTFk36dTm7kgz9cec6nqo9q5INOpHHdfVYIb+o+Hq5qjaIffDVWfp/Ui4Am/SOFFDE04Wk/hGpY43aNRhWBw23GtNALa48GcydyCm5xCV2Rn6Hc4iKUMUvHfs4+2O8T+/I6NNuqn5cx0lIGaS5GUjdl8= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=xiSKVuzv; 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="xiSKVuzv" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 27E1A1F000E9; Wed, 20 May 2026 17:43:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1779299035; bh=6toqiAzL0Iy81xdDWkqn/P5wih2toMkWA7xR26brI8w=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=xiSKVuzvaCIpBLWaBHbLjAjDn95dMpAfS4/LyymI28qfr3xo23YKYJ6x6rAsBHun9 YoeMk3u8BkzemXn2iJDbDd3OY08lqwkJGNzfx9Ki43PmGxxa3JvLJFQjJ653+/ka3o faJAkR0bwm3Ai+r7zg+5U0xfAl8BQ4jJw0sX37Go= 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 6.18 638/957] tcp: annotate data-races around tp->bytes_retrans Date: Wed, 20 May 2026 18:18:41 +0200 Message-ID: <20260520162148.365288984@linuxfoundation.org> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260520162134.554764788@linuxfoundation.org> References: <20260520162134.554764788@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 6.18-stable review patch. If anyone has any objections, please let me know. ------------------ From: Eric Dumazet [ Upstream commit 5efc7b9f7cbd43401f1af81d3d7f2be00f93390d ] tcp_get_timestamping_opt_stats() intentionally runs lockless, we must add READ_ONCE() and WRITE_ONCE() annotations to keep KCSAN happy. Fixes: fb31c9b9f6c8 ("tcp: add data bytes retransmitted stats") Signed-off-by: Eric Dumazet Link: https://patch.msgid.link/20260416200319.3608680-9-edumazet@google.com Signed-off-by: Jakub Kicinski Signed-off-by: Sasha Levin --- net/ipv4/tcp.c | 4 ++-- net/ipv4/tcp_output.c | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c index 7d45a2aab18dd..35c444caab8a8 100644 --- a/net/ipv4/tcp.c +++ b/net/ipv4/tcp.c @@ -4415,8 +4415,8 @@ struct sk_buff *tcp_get_timestamping_opt_stats(const struct sock *sk, 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); + nla_put_u64_64bit(stats, TCP_NLA_BYTES_RETRANS, + READ_ONCE(tp->bytes_retrans), TCP_NLA_PAD); nla_put_u32(stats, TCP_NLA_DSACK_DUPS, tp->dsack_dups); nla_put_u32(stats, TCP_NLA_REORD_SEEN, tp->reord_seen); nla_put_u32(stats, TCP_NLA_SRTT, tp->srtt_us >> 3); diff --git a/net/ipv4/tcp_output.c b/net/ipv4/tcp_output.c index c2492f4be2151..5a443fb14a973 100644 --- a/net/ipv4/tcp_output.c +++ b/net/ipv4/tcp_output.c @@ -3559,7 +3559,7 @@ int __tcp_retransmit_skb(struct sock *sk, struct sk_buff *skb, int segs) if (TCP_SKB_CB(skb)->tcp_flags & TCPHDR_SYN) __NET_INC_STATS(sock_net(sk), LINUX_MIB_TCPSYNRETRANS); WRITE_ONCE(tp->total_retrans, tp->total_retrans + segs); - tp->bytes_retrans += skb->len; + WRITE_ONCE(tp->bytes_retrans, tp->bytes_retrans + skb->len); /* make sure skb->data is aligned on arches that require it * and check if ack-trimming & collapsing extended the headroom -- 2.53.0