Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753984AbdFOSAv (ORCPT ); Thu, 15 Jun 2017 14:00:51 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:55270 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753062AbdFOSAr (ORCPT ); Thu, 15 Jun 2017 14:00:47 -0400 From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Ying Xue , Jon Maloy , John Thompson , Parthasarathy Bhuvaragan , "David S. Miller" , Sasha Levin Subject: [PATCH 4.9 093/108] tipc: ignore requests when the connection state is not CONNECTED Date: Thu, 15 Jun 2017 19:53:39 +0200 Message-Id: <20170615175341.574876071@linuxfoundation.org> X-Mailer: git-send-email 2.13.1 In-Reply-To: <20170615175337.190782107@linuxfoundation.org> References: <20170615175337.190782107@linuxfoundation.org> User-Agent: quilt/0.65 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1921 Lines: 65 4.9-stable review patch. If anyone has any objections, please let me know. ------------------ From: Parthasarathy Bhuvaragan [ Upstream commit 4c887aa65d38633885010277f3482400681be719 ] In tipc_conn_sendmsg(), we first queue the request to the outqueue followed by the connection state check. If the connection is not connected, we should not queue this message. In this commit, we reject the messages if the connection state is not CF_CONNECTED. Acked-by: Ying Xue Acked-by: Jon Maloy Tested-by: John Thompson Signed-off-by: Parthasarathy Bhuvaragan Signed-off-by: David S. Miller Signed-off-by: Sasha Levin Signed-off-by: Greg Kroah-Hartman --- net/tipc/server.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) --- a/net/tipc/server.c +++ b/net/tipc/server.c @@ -458,6 +458,11 @@ int tipc_conn_sendmsg(struct tipc_server if (!con) return -EINVAL; + if (!test_bit(CF_CONNECTED, &con->flags)) { + conn_put(con); + return 0; + } + e = tipc_alloc_entry(data, len); if (!e) { conn_put(con); @@ -471,12 +476,8 @@ int tipc_conn_sendmsg(struct tipc_server list_add_tail(&e->list, &con->outqueue); spin_unlock_bh(&con->outqueue_lock); - if (test_bit(CF_CONNECTED, &con->flags)) { - if (!queue_work(s->send_wq, &con->swork)) - conn_put(con); - } else { + if (!queue_work(s->send_wq, &con->swork)) conn_put(con); - } return 0; } @@ -500,7 +501,7 @@ static void tipc_send_to_sock(struct tip int ret; spin_lock_bh(&con->outqueue_lock); - while (1) { + while (test_bit(CF_CONNECTED, &con->flags)) { e = list_entry(con->outqueue.next, struct outqueue_entry, list); if ((struct list_head *) e == &con->outqueue)