mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-10-03 15:47:36 +00:00
tcp: Protect accesses to .ts_recent_stamp with {READ,WRITE}_ONCE()
[ Upstream commit721c8dafad
] 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 bya0f82f64e2
("syncookies: remove last_synq_overflow from struct tcp_sock"). But unprotected accesses were already there when timestamp was stored in .last_synq_overflow. Fixes:1da177e4c3
("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: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
parent
12f1107bd7
commit
b8a3066895
1 changed files with 3 additions and 3 deletions
|
@ -500,17 +500,17 @@ struct sock *cookie_v4_check(struct sock *sk, struct sk_buff *skb);
|
||||||
*/
|
*/
|
||||||
static inline void tcp_synq_overflow(const struct sock *sk)
|
static inline void tcp_synq_overflow(const struct sock *sk)
|
||||||
{
|
{
|
||||||
unsigned long last_overflow = tcp_sk(sk)->rx_opt.ts_recent_stamp;
|
unsigned long last_overflow = READ_ONCE(tcp_sk(sk)->rx_opt.ts_recent_stamp);
|
||||||
unsigned long now = jiffies;
|
unsigned long now = jiffies;
|
||||||
|
|
||||||
if (!time_between32(now, last_overflow, last_overflow + HZ))
|
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? */
|
/* syncookies: no recent synqueue overflow on this listening socket? */
|
||||||
static inline bool tcp_synq_no_recent_overflow(const struct sock *sk)
|
static inline bool tcp_synq_no_recent_overflow(const struct sock *sk)
|
||||||
{
|
{
|
||||||
unsigned long last_overflow = tcp_sk(sk)->rx_opt.ts_recent_stamp;
|
unsigned long last_overflow = READ_ONCE(tcp_sk(sk)->rx_opt.ts_recent_stamp);
|
||||||
|
|
||||||
/* If last_overflow <= jiffies <= last_overflow + TCP_SYNCOOKIE_VALID,
|
/* If last_overflow <= jiffies <= last_overflow + TCP_SYNCOOKIE_VALID,
|
||||||
* then we're under synflood. However, we have to use
|
* then we're under synflood. However, we have to use
|
||||||
|
|
Loading…
Reference in a new issue