]> git.kernelconcepts.de Git - karo-tx-linux.git/commitdiff
tcp: fastopen: limit max_qlen
authorEric Dumazet <edumazet@google.com>
Tue, 20 Oct 2015 20:17:40 +0000 (13:17 -0700)
committerDavid S. Miller <davem@davemloft.net>
Thu, 22 Oct 2015 13:22:13 +0000 (06:22 -0700)
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>
include/linux/tcp.h

index 5dce9705fe8415e31561ee2c1d52ef17aaeb7495..c906f453458119324414f984ee60056194093988 100644 (file)
@@ -392,8 +392,9 @@ static inline bool tcp_passive_fastopen(const struct sock *sk)
 static inline void fastopen_queue_tune(struct sock *sk, int backlog)
 {
        struct request_sock_queue *queue = &inet_csk(sk)->icsk_accept_queue;
+       int somaxconn = READ_ONCE(sock_net(sk)->core.sysctl_somaxconn);
 
-       queue->fastopenq.max_qlen = backlog;
+       queue->fastopenq.max_qlen = min_t(unsigned int, backlog, somaxconn);
 }
 
 static inline void tcp_saved_syn_free(struct tcp_sock *tp)