Received: by 2002:ac0:bc90:0:0:0:0:0 with SMTP id a16csp3969348img; Mon, 25 Mar 2019 23:47:35 -0700 (PDT) X-Google-Smtp-Source: APXvYqxEH70J91V+3A2K1M0eevLaW5jTjEZqY4IqRphDbplDy9MyiSLyz4zhA8FdnczQMFhALlxb X-Received: by 2002:a63:6605:: with SMTP id a5mr27451304pgc.372.1553582854968; Mon, 25 Mar 2019 23:47:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553582854; cv=none; d=google.com; s=arc-20160816; b=ZUmPd+zgHwt8fDPqbUgj+azrROP0L1IkapQzyXSvkiYWvr20XGzs25QjBMNmtP9OLG lG1wBbxAVwpXAPlQ3ykLUsqbT30980cPuMdo7Q1HMzDwsTibCAkYAKsehfVH6TqwO2J/ I/CO6ZFeTsPCDbV4x2YwO58zw/DlXlEL/+lbFG059bWs2vYOGjw/KeSDyL7msInHTeYI Fn4BKE8b9yOQx3ERba3lNH3ZHrF/R/af2jcJDDAsQpBPG3JTrxPqDjHq6ax9Tt78Hf7w eTgXOEsylERrpoK5Ve2zjYZSTGOZl7ZRagYDNXKwhbdRXOgKg5thqgyKLX/uTSGUEQ+P ZjYQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=j9oroVv7EVn3O2o2Ii9ugpVnzISUmFCPBW8PZD6X1Og=; b=I5JlojGNj1h7G11nS+Ur+UROt9gQ1zcGmyAYooo+PxIy/ZwtHLWuvTZpnPToHO2mh4 59xLEg4R4e9jhf5XZWxxwRKZ3LLOQeB9VhAVDa3yHD8HWN7OFWR/kT4kY0ZxEOuRg1g9 Lj8eLOnH2v1PZHHqie/ayBNek9v/RyxELVuCNPDPrJeJkGCw3qsG+vJ81IRnmyeVmW19 /OLFfxssKkTD8bFwt/W00/q5a+ZVH4CRUFYAtYD1zP4/mqTdMJa2rAhxaYTzCZ/ZozXi yhLSteVTC32L2xxDhj7LwbaAajEMS1GS77zyJC4+VZeiu8YcJdYdhBgVJF4V/rSZHpHx n2UA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=DHp3htAb; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id r63si7303784pfc.183.2019.03.25.23.47.20; Mon, 25 Mar 2019 23:47:34 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=DHp3htAb; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731493AbfCZGco (ORCPT + 99 others); Tue, 26 Mar 2019 02:32:44 -0400 Received: from mail.kernel.org ([198.145.29.99]:42106 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731477AbfCZGcm (ORCPT ); Tue, 26 Mar 2019 02:32:42 -0400 Received: from localhost (unknown [104.132.152.111]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 958A820856; Tue, 26 Mar 2019 06:32:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1553581961; bh=yTH7VZ46a8LcmLsaDFjMi1fVibm1vd5pU9a5gsZIYK8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=DHp3htAb14yu5vJwWhBsXpQ1gI8OQbJDA8v8Urcf9HLO8xjMDgVA2aP+ymI4SBvs5 S4bX0ujeR0R7s0/dukYd2qTEJZa7353YvNEor7/1El7P3MYUBlIi40TDpguKleb+yZ RaCbjqeyrbQ76BMsLkicv3hKuVMRbNAnLG3Z7QOs= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Eric Dumazet , Neal Cardwell , Yuchung Cheng , "David S. Miller" , Arnd Bergmann Subject: [PATCH 4.9 19/30] tcp/dccp: drop SYN packets if accept queue is full Date: Tue, 26 Mar 2019 15:29:58 +0900 Message-Id: <20190326042608.219111978@linuxfoundation.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190326042607.558087893@linuxfoundation.org> References: <20190326042607.558087893@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review X-Patchwork-Hint: ignore MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.9-stable review patch. If anyone has any objections, please let me know. ------------------ From: Eric Dumazet commit 5ea8ea2cb7f1d0db15762c9b0bb9e7330425a071 upstream. Per listen(fd, backlog) rules, there is really no point accepting a SYN, sending a SYNACK, and dropping the following ACK packet if accept queue is full, because application is not draining accept queue fast enough. This behavior is fooling TCP clients that believe they established a flow, while there is nothing at server side. They might then send about 10 MSS (if using IW10) that will be dropped anyway while server is under stress. Signed-off-by: Eric Dumazet Acked-by: Neal Cardwell Acked-by: Yuchung Cheng Signed-off-by: David S. Miller Signed-off-by: Arnd Bergmann Signed-off-by: Greg Kroah-Hartman --- include/net/inet_connection_sock.h | 5 ----- net/dccp/ipv4.c | 8 +------- net/dccp/ipv6.c | 2 +- net/ipv4/tcp_input.c | 8 +------- 4 files changed, 3 insertions(+), 20 deletions(-) --- a/include/net/inet_connection_sock.h +++ b/include/net/inet_connection_sock.h @@ -289,11 +289,6 @@ static inline int inet_csk_reqsk_queue_l return reqsk_queue_len(&inet_csk(sk)->icsk_accept_queue); } -static inline int inet_csk_reqsk_queue_young(const struct sock *sk) -{ - return reqsk_queue_len_young(&inet_csk(sk)->icsk_accept_queue); -} - static inline int inet_csk_reqsk_queue_is_full(const struct sock *sk) { return inet_csk_reqsk_queue_len(sk) >= sk->sk_max_ack_backlog; --- a/net/dccp/ipv4.c +++ b/net/dccp/ipv4.c @@ -596,13 +596,7 @@ int dccp_v4_conn_request(struct sock *sk if (inet_csk_reqsk_queue_is_full(sk)) goto drop; - /* - * Accept backlog is full. If we have already queued enough - * of warm entries in syn queue, drop request. It is better than - * clogging syn queue with openreqs with exponentially increasing - * timeout. - */ - if (sk_acceptq_is_full(sk) && inet_csk_reqsk_queue_young(sk) > 1) + if (sk_acceptq_is_full(sk)) goto drop; req = inet_reqsk_alloc(&dccp_request_sock_ops, sk, true); --- a/net/dccp/ipv6.c +++ b/net/dccp/ipv6.c @@ -328,7 +328,7 @@ static int dccp_v6_conn_request(struct s if (inet_csk_reqsk_queue_is_full(sk)) goto drop; - if (sk_acceptq_is_full(sk) && inet_csk_reqsk_queue_young(sk) > 1) + if (sk_acceptq_is_full(sk)) goto drop; req = inet_reqsk_alloc(&dccp6_request_sock_ops, sk, true); --- a/net/ipv4/tcp_input.c +++ b/net/ipv4/tcp_input.c @@ -6374,13 +6374,7 @@ int tcp_conn_request(struct request_sock goto drop; } - - /* Accept backlog is full. If we have already queued enough - * of warm entries in syn queue, drop request. It is better than - * clogging syn queue with openreqs with exponentially increasing - * timeout. - */ - if (sk_acceptq_is_full(sk) && inet_csk_reqsk_queue_young(sk) > 1) { + if (sk_acceptq_is_full(sk)) { NET_INC_STATS(sock_net(sk), LINUX_MIB_LISTENOVERFLOWS); goto drop; }