Received: by 2002:a05:6358:5282:b0:b5:90e7:25cb with SMTP id g2csp3340755rwa; Tue, 23 Aug 2022 03:10:36 -0700 (PDT) X-Google-Smtp-Source: AA6agR51qF9/htO9XuhhZHP0a5A9h+168uXX8Q/QI0x1l3SroUDz6Yh1TVPggJ5WQsRrvuzavvSe X-Received: by 2002:a05:6402:34ca:b0:446:d718:58be with SMTP id w10-20020a05640234ca00b00446d71858bemr3014368edc.40.1661249436055; Tue, 23 Aug 2022 03:10:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1661249436; cv=none; d=google.com; s=arc-20160816; b=EnOsj4/Wn2/e+nnUVDbMTDEmGqiPO4bzd4UEQah+mkD+fcQ1qclwohV/8SEEgqDTSy bfrVv1t/AYs1JL3P6G/sIshTBirPnLwdzMY7WLeJlLBTLSxdJ8DOj/KYlTHe3+SSNjF4 iDflm7ToN+Kc3Qqkr5XKTgU9tQW64eqGqfzTLgEEpnrYwlzJFxRNvuRC/4lNuJl2D8r4 KJi6dKkt7HFoEKPYZAswkyg56GR3/XkaDP6EU4SHXzKlxiQFQuQbn1/S4BlWXxK4QBbP RRNYudXEc3jkv7nq/3Z8oxg4rXZ3V/CSUXpWodeCqu9/2NOQYBeZ9tZSkan8nmkfBC6F Bb+w== 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=spuIxgBhYJn3Mx+K+U1QbzMe5YXfOtJDjuQovEQnBvw=; b=l1YPKhTbDxnfTH+6+HITDnDAjklqhnz4wU41mKIDicIu+4KZpL2zCQCRDLPSkwQJZE hJTs7j7ry6WpsIKK5x3ngwrPaAUEd274pv+xeGlyxIlbX+l699SdIxxSCse4XA4EEuKM FJQAxsdCbcU3L2EYhfTB9LXGANMReOnpHGWgIzJoca1l7FcBPbwFKOx8jDWoPTPRF0E8 fAYjpQpbbQe42nzyjjepfczfTDSnZuKvRkvKWWhlEM7j/+AdUYIwGtlmaCFYQHoviulM opaB9HUi2MLFPsPVzacyU97uMXkAfQdxDqi9W6RJE/Psx3Q0ZiAxiP75ZmW8RpWAsDCy 3cgQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=Asav5WKi; 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 s1-20020a17090699c100b0073c1d6b30fbsi13994162ejn.355.2022.08.23.03.10.10; Tue, 23 Aug 2022 03:10:36 -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=Asav5WKi; 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 S1352632AbiHWKIX (ORCPT + 99 others); Tue, 23 Aug 2022 06:08:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46324 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1352498AbiHWKB7 (ORCPT ); Tue, 23 Aug 2022 06:01:59 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6854C70E53; Tue, 23 Aug 2022 01:49:50 -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 7C523B81B90; Tue, 23 Aug 2022 08:49:48 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id B7E90C433C1; Tue, 23 Aug 2022 08:49:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1661244587; bh=BlCmXcTZu+EWNPS2irvhKqaRmVQCnnQHWvNPA6UBN7U=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Asav5WKiV0On0leM5bZYMF/dKLqqz4w3n+Osl7i0uOkcNNdAS79Pm6/z5k97MO48X DjxSEKB1MujPW3NsYb/NPj+YrAVDRl7HuugG86wbmJzPtfQ1KbmIX84TarCBzc2Dfn 6WEkKef/IHRdxnN/EtwLZaSf803Utgc6l+AJGaik= 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.15 081/244] vsock: Set socket state back to SS_UNCONNECTED in vsock_connect_timeout() Date: Tue, 23 Aug 2022 10:24:00 +0200 Message-Id: <20220823080101.749275404@linuxfoundation.org> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220823080059.091088642@linuxfoundation.org> References: <20220823080059.091088642@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 @@ -1285,6 +1285,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_error_report(sk); vsock_transport_cancel_pkt(vsk);