aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEric Dumazet <edumazet@google.com>2015-10-20 16:17:40 -0400
committerDavid S. Miller <davem@davemloft.net>2015-10-22 09:22:13 -0400
commitdbf650b67bb4db1b95807d2aafe2d7cfafd458da (patch)
tree1fa9fdca8c6f9380fd711cf2aa77fd48483ecd6e
parente2aacd963a06fc558a809ecb62f5833e6c340b28 (diff)
tcp: fastopen: limit max_qlen
Allowing an application to set whatever limit for the list of recently RST fastopen sessions [1] is not wise, as it open ways to deplete kernel memory. Cap the user provided limit by somaxconn sysctl, like listen() backlog. [1] https://tools.ietf.org/html/rfc7413#section-5.1 Signed-off-by: Eric Dumazet <edumazet@google.com> Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r--include/linux/tcp.h3
1 files changed, 2 insertions, 1 deletions
diff --git a/include/linux/tcp.h b/include/linux/tcp.h
index 5dce9705fe84..c906f4534581 100644
--- a/include/linux/tcp.h
+++ b/include/linux/tcp.h
@@ -392,8 +392,9 @@ static inline bool tcp_passive_fastopen(const struct sock *sk)
392static inline void fastopen_queue_tune(struct sock *sk, int backlog) 392static inline void fastopen_queue_tune(struct sock *sk, int backlog)
393{ 393{
394 struct request_sock_queue *queue = &inet_csk(sk)->icsk_accept_queue; 394 struct request_sock_queue *queue = &inet_csk(sk)->icsk_accept_queue;
395 int somaxconn = READ_ONCE(sock_net(sk)->core.sysctl_somaxconn);
395 396
396 queue->fastopenq.max_qlen = backlog; 397 queue->fastopenq.max_qlen = min_t(unsigned int, backlog, somaxconn);
397} 398}
398 399
399static inline void tcp_saved_syn_free(struct tcp_sock *tp) 400static inline void tcp_saved_syn_free(struct tcp_sock *tp)