Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp656419pxv; Thu, 15 Jul 2021 12:38:39 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwLAzHVFX4CTJjK5Wfa64gubQJza0I6ZHC71OrlE87yFyYGECUVT+7kee75+TGz5B3wmWtR X-Received: by 2002:aa7:d352:: with SMTP id m18mr9529739edr.235.1626377919780; Thu, 15 Jul 2021 12:38:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626377919; cv=none; d=google.com; s=arc-20160816; b=DqxSAEKOeRUvSmPWh+fB5FBMPpqAScAN9fPLvxPpEpcspXOINs0dD5Gwz4J+Uq6X7+ C2O0wzR4Fxh4XU/Grnlo9x3WJKCHyGFM2qbCKpt2eYUq2KjvkwJ7pIwNV3dz3GGGSsjT FT0C9ZmoAOWtsoLjYtsY7yH5oFQTWmKPE30XU41EKKEJJ9RNq8pfPJ/joOeCRBXgp2yn AgxaoWFqQP7aJRmq1tsK2+w6zplJVDcOtWpmSpLN2MznLMloq6lVCyLlVfhS7ZV9Fe4D i7st2bUPuLWotl4wzLBI7rnMaJUKsE01zkGGyxEKcY4mYBY/CiuBwhDJTfYL6YcFByr2 wOdQ== 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=ggN1oFLvSYJFYUJXMJ3UauYNRhqtMfWkXMYoepkIvHE=; b=a+AsFEMHr8sKJmqXM3Lqtck8wzy37upWjanZCE5veCzpSxqJSofB1j0L46iAN0HnD5 98dnaEbWEMiMnJQzB14WfBLM6sIgaq2lbsczohgvdac9KpyrMqMazXdWo0gBg6+aU3Ix 1IuF7LJtCHwqAt95VOSAPbaRE2LmZDGPcKmOk8IAHSHDRMNm/9N9/YMwvv9MOhz1HHEo +OBVA9G+vdsb5xINtd8PzhQmhHwEOjEnhe2adtWqHFODdeKFvLiDi6yELQZDx0FlRN9t waJl3Du1FpWTWNQUUk1JYWWYZxNtxpYQksSJmrdn3r89oJ8kP90ZybNNOamln1wMcvmZ GczQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=zDOk+JVY; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id m3si8140010edp.85.2021.07.15.12.38.16; Thu, 15 Jul 2021 12:38:39 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=zDOk+JVY; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 S1344121AbhGOTfB (ORCPT + 99 others); Thu, 15 Jul 2021 15:35:01 -0400 Received: from mail.kernel.org ([198.145.29.99]:51284 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243350AbhGOTLe (ORCPT ); Thu, 15 Jul 2021 15:11:34 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 6BE5D613DA; Thu, 15 Jul 2021 19:08:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1626376119; bh=tytnmXerQIt1RPYDn2rY2jpf+S/K6nIdFbmYASoy5C4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=zDOk+JVYjb24N8H160dVSHGCHwHLrqD5W7KKbzk/8/wKhxuwyh6hHQFGZGU7Z5frp gwANMZeuSMMkyefGkkAs8YiR85qjy2WagiYyuT9Jf2BK//cIr8vU2q3k15h69Frsc8 rNDTRXyzDxXQXXDnVbmTzQ+6UtIlqd8K93rf/d6c= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, "David S. Miller" , Jakub Kicinski , Jorgen Hansen , Norbert Slusarek , Andra Paraschiv , Colin Ian King , David Brazdil , Alexander Popov , Stefano Garzarella , lixianming , "Longpeng(Mike)" , Sasha Levin Subject: [PATCH 5.13 135/266] vsock: notify server to shutdown when client has pending signal Date: Thu, 15 Jul 2021 20:38:10 +0200 Message-Id: <20210715182637.652430446@linuxfoundation.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210715182613.933608881@linuxfoundation.org> References: <20210715182613.933608881@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Longpeng(Mike) [ Upstream commit c7ff9cff70601ea19245d997bb977344663434c7 ] The client's sk_state will be set to TCP_ESTABLISHED if the server replay the client's connect request. However, if the client has pending signal, its sk_state will be set to TCP_CLOSE without notify the server, so the server will hold the corrupt connection. client server 1. sk_state=TCP_SYN_SENT | 2. call ->connect() | 3. wait reply | | 4. sk_state=TCP_ESTABLISHED | 5. insert to connected list | 6. reply to the client 7. sk_state=TCP_ESTABLISHED | 8. insert to connected list | 9. *signal pending* <--------------------- the user kill client 10. sk_state=TCP_CLOSE | client is exiting... | 11. call ->release() | virtio_transport_close if (!(sk->sk_state == TCP_ESTABLISHED || sk->sk_state == TCP_CLOSING)) return true; *return at here, the server cannot notice the connection is corrupt* So the client should notify the peer in this case. Cc: David S. Miller Cc: Jakub Kicinski Cc: Jorgen Hansen Cc: Norbert Slusarek Cc: Andra Paraschiv Cc: Colin Ian King Cc: David Brazdil Cc: Alexander Popov Suggested-by: Stefano Garzarella Link: https://lkml.org/lkml/2021/5/17/418 Signed-off-by: lixianming Signed-off-by: Longpeng(Mike) Reviewed-by: Stefano Garzarella Signed-off-by: David S. Miller Signed-off-by: Sasha Levin --- net/vmw_vsock/af_vsock.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/net/vmw_vsock/af_vsock.c b/net/vmw_vsock/af_vsock.c index 92a72f0e0d94..ae11311807fd 100644 --- a/net/vmw_vsock/af_vsock.c +++ b/net/vmw_vsock/af_vsock.c @@ -1369,7 +1369,7 @@ static int vsock_stream_connect(struct socket *sock, struct sockaddr *addr, if (signal_pending(current)) { err = sock_intr_errno(timeout); - sk->sk_state = TCP_CLOSE; + sk->sk_state = sk->sk_state == TCP_ESTABLISHED ? TCP_CLOSING : TCP_CLOSE; sock->state = SS_UNCONNECTED; vsock_transport_cancel_pkt(vsk); goto out_wait; -- 2.30.2