aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGuillaume Nault <gnault@redhat.com>2019-12-06 12:38:49 +0100
committerPaul Gortmaker <paul.gortmaker@windriver.com>2020-01-31 16:51:12 -0500
commit8477c46262fa44c04a3efd591b571eae094f6433 (patch)
treed523a59cf4c51e3de73a676cc84044b3ce2abfc1
parentd46e87f84fd43ec325ad710d6ecdcb370f3e5b1a (diff)
downloadlinux-yocto-8477c46262fa44c04a3efd591b571eae094f6433.tar.gz
linux-yocto-8477c46262fa44c04a3efd591b571eae094f6433.tar.bz2
linux-yocto-8477c46262fa44c04a3efd591b571eae094f6433.zip
tcp: Protect accesses to .ts_recent_stamp with {READ,WRITE}_ONCE()
commit 721c8dafad26ccfa90ff659ee19755e3377b829d upstream. Syncookies borrow the ->rx_opt.ts_recent_stamp field to store the timestamp of the last synflood. Protect them with READ_ONCE() and WRITE_ONCE() since reads and writes aren't serialised. Use of .rx_opt.ts_recent_stamp for storing the synflood timestamp was introduced by a0f82f64e269 ("syncookies: remove last_synq_overflow from struct tcp_sock"). But unprotected accesses were already there when timestamp was stored in .last_synq_overflow. Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2") Signed-off-by: Guillaume Nault <gnault@redhat.com> Signed-off-by: Eric Dumazet <edumazet@google.com> Signed-off-by: David S. Miller <davem@davemloft.net> Signed-off-by: Paul Gortmaker <paul.gortmaker@windriver.com>
-rw-r--r--include/net/tcp.h6
1 files changed, 3 insertions, 3 deletions
diff --git a/include/net/tcp.h b/include/net/tcp.h
index a720a2a7cb1c..b6e69e6c81fd 100644
--- a/include/net/tcp.h
+++ b/include/net/tcp.h
@@ -490,9 +490,9 @@ static inline void tcp_synq_overflow(const struct sock *sk)
}
}
- last_overflow = tcp_sk(sk)->rx_opt.ts_recent_stamp;
+ last_overflow = READ_ONCE(tcp_sk(sk)->rx_opt.ts_recent_stamp);
if (!time_between32(now, last_overflow, last_overflow + HZ))
- tcp_sk(sk)->rx_opt.ts_recent_stamp = now;
+ WRITE_ONCE(tcp_sk(sk)->rx_opt.ts_recent_stamp, now);
}
/* syncookies: no recent synqueue overflow on this listening socket? */
@@ -513,7 +513,7 @@ static inline bool tcp_synq_no_recent_overflow(const struct sock *sk)
}
}
- last_overflow = tcp_sk(sk)->rx_opt.ts_recent_stamp;
+ last_overflow = READ_ONCE(tcp_sk(sk)->rx_opt.ts_recent_stamp);
/* If last_overflow <= jiffies <= last_overflow + TCP_SYNCOOKIE_VALID,
* then we're under synflood. However, we have to use