Received: by 2002:a05:6358:e9c4:b0:b2:91dc:71ab with SMTP id hc4csp1363369rwb; Fri, 5 Aug 2022 00:00:34 -0700 (PDT) X-Google-Smtp-Source: AA6agR7VW+byrpsofA5JwIdYHWaUZHzZJE4Rg25xqGzSNzY111pn8Ei3LNnRGrcrx8RrnbSFtaOL X-Received: by 2002:a05:6402:3206:b0:43d:4e0e:b693 with SMTP id g6-20020a056402320600b0043d4e0eb693mr5163885eda.316.1659682834746; Fri, 05 Aug 2022 00:00:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1659682834; cv=none; d=google.com; s=arc-20160816; b=AQ7KS7waZY/WzBy5TYITHJsSIctUpakutjo7ZCHnzAnTLrLd2AfpdNYZW3hKGmgqyK CcOerOiDIWNP09Brnr1giEy5TRO4Jd66CFHB4k5xRRI6J+d5zOEdMfWl7R5iCbc06Jgb Uge11jVQclb9kh94JmQZo8YhY6UrGyqn3Xavc7spXkxxi3z+vLgY4XQLJ+r6uGKez133 ul6sboVSjJDVr1tpuX2gfwjwNx8vLF/qFwXV82t/ysSQlGPY6pRfa9i8vkNSJEn6CeCw fD4EgL0oZpjSL959pCwWhJJujGgUKUwW2hIGQn9x5n4+rR7jffVLG0aqdnBZjLx2MxhH 4DQQ== 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 :message-id:date:subject:cc:to:from; bh=2P4+PFE1SV41KxhPyG/xAqchVHs5KP20TG5QUr9gbQ4=; b=xVbl5z8O9iFSAargn7ztHWLLzAzXtAHofWx9d412HF4oQt0GUKJKXUQDN609nK/iU8 7xCKg21mDl6+3/LZs9IkcCF2BwgRnBo007IZuGjndL0VcePclHecJcYVf83SssUexYKZ EVKwnW/74tP0Aaiv3ul7mZnQDfRf/8SVQx6akDP8Cg/9yW/YKqujj2v4ILyYrPA32XbW Nrw8a7O+W68gct77jo1QlTahNGy2jKsvfyBN1P2No1NI9+6nPX/7pSywnhB3lGVPpw0v p9swWvoiap9JKmTh2ET2Ee47+gc9+d0Zr8jZHB9I0BLz3oplvSt7o+xw6fZceCapiBok 9yhA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id y22-20020aa7c256000000b0043dd2989916si422344edo.608.2022.08.05.00.00.09; Fri, 05 Aug 2022 00:00:34 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235406AbiHEGl0 (ORCPT + 99 others); Fri, 5 Aug 2022 02:41:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51338 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235930AbiHEGlZ (ORCPT ); Fri, 5 Aug 2022 02:41:25 -0400 X-Greylist: delayed 1369 seconds by postgrey-1.37 at lindbergh.monkeyblade.net; Thu, 04 Aug 2022 23:41:23 PDT Received: from mxout70.expurgate.net (mxout70.expurgate.net [194.37.255.70]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 95EC8193C9; Thu, 4 Aug 2022 23:41:23 -0700 (PDT) Received: from [127.0.0.1] (helo=localhost) by relay.expurgate.net with smtp (Exim 4.92) (envelope-from ) id 1oJqfF-000L0w-30; Fri, 05 Aug 2022 08:18:29 +0200 Received: from [195.243.126.94] (helo=securemail.tdt.de) by relay.expurgate.net with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1oJqfE-000D8k-28; Fri, 05 Aug 2022 08:18:28 +0200 Received: from securemail.tdt.de (localhost [127.0.0.1]) by securemail.tdt.de (Postfix) with ESMTP id A0153240049; Fri, 5 Aug 2022 08:18:27 +0200 (CEST) Received: from mail.dev.tdt.de (unknown [10.2.4.42]) by securemail.tdt.de (Postfix) with ESMTP id 2E793240040; Fri, 5 Aug 2022 08:18:27 +0200 (CEST) Received: from mschiller01.dev.tdt.de (unknown [10.2.3.20]) by mail.dev.tdt.de (Postfix) with ESMTPSA id AADA028738; Fri, 5 Aug 2022 08:18:26 +0200 (CEST) From: Martin Schiller To: davem@davemloft.net, edumazet@google.com, kuba@kernel.org Cc: linux-x25@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Martin Schiller Subject: [PATCH net] net/x25: fix call timeouts in blocking connects Date: Fri, 5 Aug 2022 08:18:10 +0200 Message-ID: <20220805061810.10824-1-ms@dev.tdt.de> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_LOW, SPF_HELO_PASS,SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Content-Transfer-Encoding: quoted-printable X-purgate-type: clean X-purgate: clean X-purgate-ID: 151534::1659680308-95942F7B-D01DC08B/0/0 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org When a userspace application starts a blocking connect(), a CALL REQUEST is sent, the t21 timer is started and the connect is waiting in x25_wait_for_connection_establishment(). If then for some reason the t21 timer expires before any reaction on the assigned logical channel (e.g. CALL ACCEPT, CLEAR REQUEST), there is sent a CLEAR REQUEST and timer t23 is started waiting for a CLEAR confirmation. If we now receive a CLEAR CONFIRMATION from the peer, x25_disconnect() is called in x25_state2_machine() with reason "0", which means "normal" call clearing. This is ok, but the parameter "reason" is used as sk->sk_err in x25_disconnect() and sock_error(sk) is evaluated in x25_wait_for_connection_establishment() to check if the call is still pending. As "0" is not rated as an error, the connect will stuck here forever. To fix this situation, also check if the sk->sk_state changed form TCP_SYN_SENT to TCP_CLOSE in the meantime, which is also done by x25_disconnect(). Signed-off-by: Martin Schiller --- net/x25/af_x25.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/net/x25/af_x25.c b/net/x25/af_x25.c index 6bc2ac8d8146..3b55502b2965 100644 --- a/net/x25/af_x25.c +++ b/net/x25/af_x25.c @@ -719,6 +719,11 @@ static int x25_wait_for_connection_establishment(str= uct sock *sk) sk->sk_socket->state =3D SS_UNCONNECTED; break; } + rc =3D -ENOTCONN; + if (sk->sk_state =3D=3D TCP_CLOSE) { + sk->sk_socket->state =3D SS_UNCONNECTED; + break; + } rc =3D 0; if (sk->sk_state !=3D TCP_ESTABLISHED) { release_sock(sk); --=20 2.20.1