Received: by 2002:a05:6358:5282:b0:b5:90e7:25cb with SMTP id g2csp3402700rwa; Tue, 23 Aug 2022 04:18:33 -0700 (PDT) X-Google-Smtp-Source: AA6agR6tRrsQVep9SrLcNYaSgz6AdFLv58wpj2P8YfJMR4yeeOTeSY/dDbp8g8H1ljI9air4xsk+ X-Received: by 2002:a63:c108:0:b0:41d:6bf3:6807 with SMTP id w8-20020a63c108000000b0041d6bf36807mr20499821pgf.157.1661253513551; Tue, 23 Aug 2022 04:18:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1661253513; cv=none; d=google.com; s=arc-20160816; b=Y8xp64gWJU4EM79kzD7YSUmBayTmgnzKPlr/ujuWV9pAuj9UuLZ4UKTgj+WzDtUzh5 jnwcvHz3/Q/ETIjrrxxM7N6yv9SBu4HH9QKhIwrgsvXBzgdbFV9f+TGqwVFioKl0i5fc dT0DwolCWjWsph/YtMmUUxDAr+ygW6zCmaJ8SenUfiyIOHhIyHPLSQf9Zy6Ig3zSXLXl ojEmR+Q+XOfTI/NIH+6GZQkApoiGsmTkDjAuDq6tceZI7mnW5C0zNlxF2iv2NOoRe6o7 6ABB5I5b8wFItsoXV51f2STz4aBP5U4Fr0+xBQPwt0spjEZcT48yjF758HcZizNSVUXI ciwQ== 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=YsYqijJzObIPW/5HSGh9IUK3rPmZ4glfUf6aU9908U8=; b=cV8JfaFgJAW09UVDEJ+pvy+1ZS4H+R7FB0R1w4HcwdmDWLltHtowigLd4wORrZcgZP Ev0MF3awadpKHWjv/SgaMdkAOaPOZXoAGoAkVBpkJ1HapOmmhUQ973h11fFO5q4+PQBq HhcPS4pNbihfHzFZEW+/5XwhkgXn2sAASgX+9PlH6Fwjfu1ZSFoov19wp04l/AEh8nDG 5cY3gD3qNWOkhNfa3lNNaeohuYjLOrWyEFZpKvr7p85KjF2O673agsGQm+26PrCwzYdn /eFaXg4MOT/qeZV5e4Lq6dl9oaZynK95XgDn2BeZxT2Klabz0ciwILtKBBZzQYw+nRee fglQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=AZtWrZ3R; 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 k63-20020a638442000000b00429fab244e1si8554253pgd.11.2022.08.23.04.18.23; Tue, 23 Aug 2022 04:18:33 -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=AZtWrZ3R; 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 S1353679AbiHWKPe (ORCPT + 99 others); Tue, 23 Aug 2022 06:15:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58148 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1352848AbiHWKGW (ORCPT ); Tue, 23 Aug 2022 06:06:22 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 673752DEF; Tue, 23 Aug 2022 01:53:19 -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 578F6B8105C; Tue, 23 Aug 2022 08:53:18 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id ADEC6C433C1; Tue, 23 Aug 2022 08:53:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1661244797; bh=1I0ofOchYddj05pVP0sCfvBSf9N7V0uSneCL4SeRj2U=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=AZtWrZ3RshjFZXxQ88cTnTJCsWTbyK4FV8HaCgw3mdaYG/B99DJ9ztcaKgr9JdCG7 OwftvFZ4rcWv52DC1syLn+alSPb5Tc3lTdAUBko6h7/WbZqX4FzUJpXtOqr5C64U6M pro6ylN2i3MEq1OUlsJHn3IqbEphA1mvFLz1cll8= 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.14 193/229] vsock: Set socket state back to SS_UNCONNECTED in vsock_connect_timeout() Date: Tue, 23 Aug 2022 10:25:54 +0200 Message-Id: <20220823080100.511422086@linuxfoundation.org> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220823080053.202747790@linuxfoundation.org> References: <20220823080053.202747790@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 @@ -1125,6 +1125,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);