summaryrefslogtreecommitdiffstats
path: root/include/net/tcp.h
diff options
context:
space:
mode:
authorEric Dumazet <edumazet@google.com>2021-11-15 20:02:42 +0100
committerDavid S. Miller <davem@davemloft.net>2021-11-16 14:10:34 +0100
commit0307a0b74b3af6ecb1c8b7f727376130b15bbf44 (patch)
tree31f6f571d6c135b02a5dc6cf9f63dc5b860a36e0 /include/net/tcp.h
parenttcp: add RETPOLINE mitigation to sk_backlog_rcv (diff)
downloadlinux-0307a0b74b3af6ecb1c8b7f727376130b15bbf44.tar.xz
linux-0307a0b74b3af6ecb1c8b7f727376130b15bbf44.zip
tcp: annotate data-races on tp->segs_in and tp->data_segs_in
tcp_segs_in() can be called from BH, while socket spinlock is held but socket owned by user, eventually reading these fields from tcp_get_info() Found by code inspection, no need to backport this patch to older kernels. Signed-off-by: Eric Dumazet <edumazet@google.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'include/net/tcp.h')
-rw-r--r--include/net/tcp.h8
1 files changed, 6 insertions, 2 deletions
diff --git a/include/net/tcp.h b/include/net/tcp.h
index 4da22b41bde6..05c81677aaf7 100644
--- a/include/net/tcp.h
+++ b/include/net/tcp.h
@@ -2172,9 +2172,13 @@ static inline void tcp_segs_in(struct tcp_sock *tp, const struct sk_buff *skb)
u16 segs_in;
segs_in = max_t(u16, 1, skb_shinfo(skb)->gso_segs);
- tp->segs_in += segs_in;
+
+ /* We update these fields while other threads might
+ * read them from tcp_get_info()
+ */
+ WRITE_ONCE(tp->segs_in, tp->segs_in + segs_in);
if (skb->len > tcp_hdrlen(skb))
- tp->data_segs_in += segs_in;
+ WRITE_ONCE(tp->data_segs_in, tp->data_segs_in + segs_in);
}
/*