Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp708251pxv; Thu, 15 Jul 2021 14:04:31 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxN0+WKY+Tavcjlr4LoYjlU6YcrT16Hjw5MPuGdWBGCfDVAsQV+mhP4cow40t1VEdJcMkgp X-Received: by 2002:aa7:c1cc:: with SMTP id d12mr9804956edp.282.1626383071495; Thu, 15 Jul 2021 14:04:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626383071; cv=none; d=google.com; s=arc-20160816; b=aLxwatEbsJm9sCZ7sGGJvgHi2P6cBMSJOCVJiYgNYHdlWZ6Y7Ap5v/OwGft1o1O/xL EshsZSyGPvPFir4lN8C4VLPny+/tCYR6YhohKy2OBpdg1yQUhd1KgyoVtTvRU261tnxq yMLxeJAPT9fVIc9AX9C7potyt6ptJpBdGqaEa8Qd2f2vcaf6eezSqMCwrbRJ8U8qV3Of 17jSi76J54xfnU6w1virQAXAFJeUFh0B8rIcXgS2aAnUA5YDyabWa8wC5dPEcUxsYHad mzoFy/0B90H2nPAoFNltoLl+KNJBRh7KJOOtC9aLOTt5fpz0hnVBlUkbwPVuquQq6R+U 7Lxw== 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=hvk8X1j0wt9uKAmZ+30WAMAdLGfg31V5bk75nYjzYYA=; b=hV+cBaJrp94C+N0N1bxnojaChSzmmjEtsoiJrKQBT4hACKyn/wbj06ksqTfbaTc4Et l309DfwX3OlqW8VlK472hUWuhZHmplN4H36iC4AT/PhAz1qjmTJ+rCSDsh15gym12JGD HS0bhJ0nMZ2nDI+C2imxbUPeXjHdjIc8YgWhlcCOu56SsDbHkaOxNMahJRW/clz3qh4l 4SNbKk7uKJIEsAk589REAtkCcjdOU/QkSdWho+1GFx8N3I4ytxnbk05lT4yJN2SMUlZP vOZRHfea6815R1RyX+cG+R9SxJIFnV7Pp9SVW3mEbXKqIqwuCZMZ65YF+/sNOn7Kf9iw MBEw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=1WA11gSo; 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 dc17si8501968edb.517.2021.07.15.14.04.08; Thu, 15 Jul 2021 14:04:31 -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=1WA11gSo; 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 S244724AbhGOTPL (ORCPT + 99 others); Thu, 15 Jul 2021 15:15:11 -0400 Received: from mail.kernel.org ([198.145.29.99]:38832 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241580AbhGOTBq (ORCPT ); Thu, 15 Jul 2021 15:01:46 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 2376F613E6; Thu, 15 Jul 2021 18:58:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1626375515; bh=vKFXiCr46NNPCg9fxGbJwGsIJ4mRWhdYKbX8fbdZOLU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=1WA11gSoe+rFx18LnldLBgPGalR+8RgQcc7OWyefh5o3d+UZ9jz5IGO9+7P+oAgdK YBXmm+bgl0Hbuk0y+D2UxCaOfTIZ8JWJmbBfxdKj6sNOUDL07Y7MzNnifzzfnx/2fc ZEHUbUR3zRg50uAydPP/QFkNxjdnvc+waeRphfok= 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.12 113/242] vsock: notify server to shutdown when client has pending signal Date: Thu, 15 Jul 2021 20:37:55 +0200 Message-Id: <20210715182613.008811068@linuxfoundation.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210715182551.731989182@linuxfoundation.org> References: <20210715182551.731989182@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 bc7fb9bf3351..2a82fbf32ccc 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