Skip to content

Commit dbf650b

Browse files
Eric Dumazetdavem330
authored andcommitted
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>
1 parent e2aacd9 commit dbf650b

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

include/linux/tcp.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -392,8 +392,9 @@ static inline bool tcp_passive_fastopen(const struct sock *sk)
392392
static inline void fastopen_queue_tune(struct sock *sk, int backlog)
393393
{
394394
struct request_sock_queue *queue = &inet_csk(sk)->icsk_accept_queue;
395+
int somaxconn = READ_ONCE(sock_net(sk)->core.sysctl_somaxconn);
395396

396-
queue->fastopenq.max_qlen = backlog;
397+
queue->fastopenq.max_qlen = min_t(unsigned int, backlog, somaxconn);
397398
}
398399

399400
static inline void tcp_saved_syn_free(struct tcp_sock *tp)

0 commit comments

Comments
 (0)