Received: by 2002:a05:6358:5282:b0:b5:90e7:25cb with SMTP id g2csp3407487rwa; Tue, 23 Aug 2022 04:23:14 -0700 (PDT) X-Google-Smtp-Source: AA6agR7MRQ2S0MI+gaAHMFpxsr7EvHsyLw6iNagJ+XWs7WsFhDXxq3PPwJFl7t2YKsCIcLw2qgTr X-Received: by 2002:a17:90a:c782:b0:1f7:a4ed:11a1 with SMTP id gn2-20020a17090ac78200b001f7a4ed11a1mr2938919pjb.12.1661253794485; Tue, 23 Aug 2022 04:23:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1661253794; cv=none; d=google.com; s=arc-20160816; b=hwfphEZJMQAjOnYF2B+Ia7/3dqoQowISmZXEcFqD+mogZ+ZyxJ4/+b3UMLX79vaHSJ EN6Sejt1cgnmLZGcrj3CCc4TPPZjVDEQaPdAATqDv3ZVhbDRJbvYqmxu2txIqdyryqbV LGaEtWiTdRHUKSqTHkF98rEmq777NS9RPAfIkwKYzcbM372/NB9FMGzN/vTYg8Tcca13 puvprUnA3yFZDxCfCwN5AUoJDNs3erOgnWEmxTsqCTCy+F8tmo16WN6Nzz04meofryFN sw0McSDZ+25D7Hy4JOqEqsJ2zcCvQOE75rbtJPhfq0RBGmTA8bT1IEgc3no17QM6NgKE hBNQ== 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=FmwieVewB9lwikPduhzOO1M0Zx5EvV2ZKaUXJzgq8xY=; b=bC5OT3UcMWXjxKeV1nPlOasIF/4UTboC/8VZaFefoIoJUjzcCqslAhGrPm4xThc0Rg dzXA823IeJ9Fzaigd6CfPGcBS6GFtlVVX+2fEeLtSmhGAkTGpLb74IK2unSx6WReS06e nNO20XZxxqnyqSnwVwalJ53z4NB4a/zyu9wBASHJQCr/JpCPxodGuxHRpzH1tBQ44/ME WB2ZSjAFZdkx19pK1sIFlRNkqeQGpJgSdntIB2efpsCDaT+vbbvQ6qYhqATZLEW/OrSO OljhwY2LYxvCwKqUIAxTjj2nPwZAzabNldiYRfevwxtPuWxDiFVJ6qkidNTo6MPypBAk dlRw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=tIeWJIYz; 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 i189-20020a6387c6000000b00415d1eeabc6si14163976pge.344.2022.08.23.04.23.02; Tue, 23 Aug 2022 04:23:14 -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=tIeWJIYz; 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 S1356656AbiHWK6N (ORCPT + 99 others); Tue, 23 Aug 2022 06:58:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51392 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1356256AbiHWKyS (ORCPT ); Tue, 23 Aug 2022 06:54:18 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 064D01055D; Tue, 23 Aug 2022 02:13:20 -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 dfw.source.kernel.org (Postfix) with ESMTPS id 00CCD60F85; Tue, 23 Aug 2022 09:13:18 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id E2FF7C433C1; Tue, 23 Aug 2022 09:13:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1661245997; bh=YyS6kzcP5LnTRVkg6JjJD2bti6S4kghdoWLmjpu6yHw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=tIeWJIYznO+8kUst9WtnwSD967agzczbochFyZj8q7vamtDtOq9vEEGR99fMMkZ6D 7Cz60dmG3rGL9dUclm35b6hKxuVNm0GBAbP1q3kRTY0ll7+eKpFMymqzKrPZdS6uHm iXlEcsC7+/+brFN1b5px7VMVPT0lPYRcf5SPWc6Q= 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 4.19 239/287] vsock: Set socket state back to SS_UNCONNECTED in vsock_connect_timeout() Date: Tue, 23 Aug 2022 10:26:48 +0200 Message-Id: <20220823080109.124885855@linuxfoundation.org> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220823080100.268827165@linuxfoundation.org> References: <20220823080100.268827165@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 @@ -1118,6 +1118,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);