Received: by 2002:a05:6358:5282:b0:b5:90e7:25cb with SMTP id g2csp3516863rwa; Tue, 23 Aug 2022 06:07:53 -0700 (PDT) X-Google-Smtp-Source: AA6agR6rjfgisRbyT84BGNy2fd36XzSJdV6tTn40v63l9+7uuel/R+ypLtaezGD4qy9iq6jpCkTl X-Received: by 2002:a17:902:9341:b0:172:775e:9573 with SMTP id g1-20020a170902934100b00172775e9573mr24685149plp.128.1661260072916; Tue, 23 Aug 2022 06:07:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1661260072; cv=none; d=google.com; s=arc-20160816; b=iFqkP9ED/qqVhIZkugNpSsWBl5quhNWxKaFzbcWUkR9xaEYdd32PQ+TbwRPlSpVpW4 3KKJfNCWagL/KsM1OxHcGEjqIq2ZfUut6+9apvAT1SdQwmFdpkYfKHcDZI2GXeJR2CXI jPcSbZPn215bMONjN76XJpwS55tVAH1CCCkcsN47B9oasUvAHozEekLD9ewW1voAy4Er UgcSy2wMmfC4RtM2sqlVFDUleXRwd8x8DV4jvah1OKQ34qyBhu2fr+vOmNvCfeXaEdvI nQIAR6sqNoVBr8N+wndf/uu6km6neB782cv/Y7woMG6VAriP8ne34Xpj9KD4+MkZJ0yh N4aQ== 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=UQrdX/k3kes/3X8GIgRMfqibNQ8nolLmOpDp1utj5+8=; b=D/1edOEcAWpHAJJ/SLzYnXoQGJssF4jkiCta7wVg4p6VstNsrj9G4A+wI0b9eM6C1O dORr7qhnoOvSYdYmDL99zsx11pYKJD5E30AS5kFgyDZhqgXrh0t14UocKenvHHDuT/vp ScEdtOpfxy2Y3Cd0XgCyjZis83b4qPemER2bFiLd96NDU2a/usOuJecu9c1CwquCdHBs iupNfljhQihNV1mq/ykXEMgysiE0uf+8cpJ9CYMi934/v5O9EGVGfAWSvcf9WlnVPsKk +frGUxvgItI/N5sk2u1rh6sk2mPTPQ/6S+6ihPf/5/2DcS53N9uF6Zzbnfl8EUsLUPEU F47Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=YxqHU8Fc; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id f6-20020a635106000000b0041bc8882540si12780173pgb.370.2022.08.23.06.07.40; Tue, 23 Aug 2022 06:07:52 -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; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=YxqHU8Fc; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1358635AbiHWLx5 (ORCPT + 99 others); Tue, 23 Aug 2022 07:53:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57844 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1358731AbiHWLuo (ORCPT ); Tue, 23 Aug 2022 07:50:44 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E03B6D2EAB; Tue, 23 Aug 2022 02:31:48 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 16B44B8105C; Tue, 23 Aug 2022 09:31:47 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 51F4FC433D6; Tue, 23 Aug 2022 09:31:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1661247105; bh=tgwi/tP+hcVfUhfNfNmv7WL2po1ZQx4WqR5FMscIIQM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=YxqHU8Fcow4VV0zd4n6PGJ4HMmSdS9oCNVybyJUvu/lxZVlS7n0eR/qdKLqyx9e4j 3hB4m3B0zFzQDVorSrOMrIGgI+tpMN3EQlRFEy5YWmUzGT+LEo866BQY9s9ID7vrZc ibXxtekL6RT2E06E0rDNy91RTTq4fVVJzgWwrDvM= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Stefano Garzarella , Peilin Ye , "David S. Miller" Subject: [PATCH 5.4 319/389] vsock: Set socket state back to SS_UNCONNECTED in vsock_connect_timeout() Date: Tue, 23 Aug 2022 10:26:37 +0200 Message-Id: <20220823080128.865043509@linuxfoundation.org> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220823080115.331990024@linuxfoundation.org> References: <20220823080115.331990024@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Peilin Ye commit a3e7b29e30854ed67be0d17687e744ad0c769c4b upstream. Imagine two non-blocking vsock_connect() requests on the same socket. The first request schedules @connect_work, and after it times out, vsock_connect_timeout() sets *sock* state back to TCP_CLOSE, but keeps *socket* state as SS_CONNECTING. Later, the second request returns -EALREADY, meaning the socket "already has a pending connection in progress", even though the first request has already timed out. As suggested by Stefano, fix it by setting *socket* state back to SS_UNCONNECTED, so that the second request will return -ETIMEDOUT. Suggested-by: Stefano Garzarella Fixes: d021c344051a ("VSOCK: Introduce VM Sockets") Reviewed-by: Stefano Garzarella Signed-off-by: Peilin Ye Signed-off-by: David S. Miller Signed-off-by: Greg Kroah-Hartman --- net/vmw_vsock/af_vsock.c | 1 + 1 file changed, 1 insertion(+) --- a/net/vmw_vsock/af_vsock.c +++ b/net/vmw_vsock/af_vsock.c @@ -1110,6 +1110,7 @@ static void vsock_connect_timeout(struct if (sk->sk_state == TCP_SYN_SENT && (sk->sk_shutdown != SHUTDOWN_MASK)) { sk->sk_state = TCP_CLOSE; + sk->sk_socket->state = SS_UNCONNECTED; sk->sk_err = ETIMEDOUT; sk->sk_error_report(sk); vsock_transport_cancel_pkt(vsk);