Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp3424050pxf; Mon, 29 Mar 2021 01:39:54 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxiTCun29jTaPun+E4M3pTkwEFYwS34U5ybN3PjOCErBTZS0e+chNasUdy3jD/8o67vNJGL X-Received: by 2002:a05:6402:4309:: with SMTP id m9mr28310568edc.25.1617007194692; Mon, 29 Mar 2021 01:39:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1617007194; cv=none; d=google.com; s=arc-20160816; b=0jXhZDv8kjATDiuN20z7j23gznQ7Rtlk2SeGt1TNJAuN6DfbaFwuvlW1j/vcGXoF19 PR28WJerrvxmIeicOhO47FFflY1nB1RQiJp2ns53vyWyLgNJ6d1xLOCvszzUiPDFbxOG lIY7nAMRLXnhFxTDQREXoe30J8xK+TFvQgOH3VGpsaMNRuWrRsSPtDvN/KJzsxhGbX+9 POdcPuqvN7w3G7EMgRAnqmyHDK87UA/C6ejTUGZyC7OYLtJCgHq3moYU0mf7KfWHJgqV Bu2yj/kTszkKwoz6n0DbWERmVcpYbBbIAcBkHPAI+hLoy1Zk7wR7rr2vHwTQPCtQNJ1w swqQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=vRpjOa9eIcV0gjYfzg6N5S8EGl2PK8GE1jXRtTKWSL8=; b=CGMyE6RwryiN5eeOKMh9ZBaO5N/Cmd/1jx7kU2ydj86cyz2nkrOqAesu0bWt8GCMhA YkGEufvuDOvJjYoOaNuLDMCY6FQ9VclrDJZ5sHY0EcCn1UHxD72u+zl/HRqbEH1q8PhW tU5p/DtRa3NimeGoW0pHp/39p7Amnl2/VwdW2IMvsV6EfmZdW7ji3RTe2KyNQRJ7SGl9 Yi5Z/20InxaIphs/FWMQcKdXBrDJqNfkAgmmwy6z7ZwO/zbbjZgfl/23BffE9vu+SsaH fDyCy1ejleLlIrvKpYJv1uxB8f+gfeugUOs1ryttisv/BQkfp8D5tyZZPtIx0aYJcnCi lJBg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=JEP50Rlk; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id c17si11538612ede.535.2021.03.29.01.39.31; Mon, 29 Mar 2021 01:39:54 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=JEP50Rlk; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234413AbhC2Ifs (ORCPT + 99 others); Mon, 29 Mar 2021 04:35:48 -0400 Received: from mail.kernel.org ([198.145.29.99]:39022 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233599AbhC2IVz (ORCPT ); Mon, 29 Mar 2021 04:21:55 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 56E7B61964; Mon, 29 Mar 2021 08:21:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1617006114; bh=srDLX5F2mVEsfQXfCd1xpY64ZHrErokYKgAW/ncrvuw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=JEP50RlkzW9uGaQmv7bKDr9LK44YpxKfWUf8sJ4Li3YXk7vDQzVR4T+diAvrCUwwE xEcPR7dbjNGsdcsYfgfB2gjpQBUCopUO08i5Ja59/9RNk311JBAowrcjJpQrbf0xqX Y+mMsvTc/fvTXe/9v3J7HElzqLRp0KBKsQNd5WIU= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Alexander Ovechkin , Oleg Senin , Eric Dumazet , "David S. Miller" , Sasha Levin Subject: [PATCH 5.10 123/221] tcp: relookup sock for RST+ACK packets handled by obsolete req sock Date: Mon, 29 Mar 2021 09:57:34 +0200 Message-Id: <20210329075633.320571842@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210329075629.172032742@linuxfoundation.org> References: <20210329075629.172032742@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Alexander Ovechkin [ Upstream commit 7233da86697efef41288f8b713c10c2499cffe85 ] Currently tcp_check_req can be called with obsolete req socket for which big socket have been already created (because of CPU race or early demux assigning req socket to multiple packets in gro batch). Commit e0f9759f530bf789e984 ("tcp: try to keep packet if SYN_RCV race is lost") added retry in case when tcp_check_req is called for PSH|ACK packet. But if client sends RST+ACK immediatly after connection being established (it is performing healthcheck, for example) retry does not occur. In that case tcp_check_req tries to close req socket, leaving big socket active. Fixes: e0f9759f530 ("tcp: try to keep packet if SYN_RCV race is lost") Signed-off-by: Alexander Ovechkin Reported-by: Oleg Senin Reviewed-by: Eric Dumazet Signed-off-by: David S. Miller Signed-off-by: Sasha Levin --- include/net/inet_connection_sock.h | 2 +- net/ipv4/inet_connection_sock.c | 7 +++++-- net/ipv4/tcp_minisocks.c | 7 +++++-- 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/include/net/inet_connection_sock.h b/include/net/inet_connection_sock.h index 111d7771b208..aa92af3dd444 100644 --- a/include/net/inet_connection_sock.h +++ b/include/net/inet_connection_sock.h @@ -284,7 +284,7 @@ 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; } -void inet_csk_reqsk_queue_drop(struct sock *sk, struct request_sock *req); +bool inet_csk_reqsk_queue_drop(struct sock *sk, struct request_sock *req); void inet_csk_reqsk_queue_drop_and_put(struct sock *sk, struct request_sock *req); static inline void inet_csk_prepare_for_destroy_sock(struct sock *sk) diff --git a/net/ipv4/inet_connection_sock.c b/net/ipv4/inet_connection_sock.c index 48d2b615edc2..1dfa561e8f98 100644 --- a/net/ipv4/inet_connection_sock.c +++ b/net/ipv4/inet_connection_sock.c @@ -705,12 +705,15 @@ static bool reqsk_queue_unlink(struct request_sock *req) return found; } -void inet_csk_reqsk_queue_drop(struct sock *sk, struct request_sock *req) +bool inet_csk_reqsk_queue_drop(struct sock *sk, struct request_sock *req) { - if (reqsk_queue_unlink(req)) { + bool unlinked = reqsk_queue_unlink(req); + + if (unlinked) { reqsk_queue_removed(&inet_csk(sk)->icsk_accept_queue, req); reqsk_put(req); } + return unlinked; } EXPORT_SYMBOL(inet_csk_reqsk_queue_drop); diff --git a/net/ipv4/tcp_minisocks.c b/net/ipv4/tcp_minisocks.c index 495dda2449fe..f0f67b25c97a 100644 --- a/net/ipv4/tcp_minisocks.c +++ b/net/ipv4/tcp_minisocks.c @@ -804,8 +804,11 @@ embryonic_reset: tcp_reset(sk); } if (!fastopen) { - inet_csk_reqsk_queue_drop(sk, req); - __NET_INC_STATS(sock_net(sk), LINUX_MIB_EMBRYONICRSTS); + bool unlinked = inet_csk_reqsk_queue_drop(sk, req); + + if (unlinked) + __NET_INC_STATS(sock_net(sk), LINUX_MIB_EMBRYONICRSTS); + *req_stolen = !unlinked; } return NULL; } -- 2.30.1