From: Parthasarathy Bhuvaragan Date: Tue, 24 Jan 2017 12:00:47 +0000 (+0100) Subject: tipc: ignore requests when the connection state is not CONNECTED X-Git-Tag: Ubuntu-snapdragon-4.4.0-1064.69~654 X-Git-Url: https://git.proxmox.com/?a=commitdiff_plain;h=399ed251f184d724718cb47b07c516e4bb3dab12;p=mirror_ubuntu-artful-kernel.git tipc: ignore requests when the connection state is not CONNECTED BugLink: http://bugs.launchpad.net/bugs/1698817 [ 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 Signed-off-by: Stefan Bader Signed-off-by: Thadeu Lima de Souza Cascardo --- diff --git a/net/tipc/server.c b/net/tipc/server.c index 922e04a43396..50f5b0ca7b3c 100644 --- a/net/tipc/server.c +++ b/net/tipc/server.c @@ -452,6 +452,11 @@ int tipc_conn_sendmsg(struct tipc_server *s, int conid, 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); @@ -465,12 +470,8 @@ int tipc_conn_sendmsg(struct tipc_server *s, int conid, 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; } @@ -494,7 +495,7 @@ static void tipc_send_to_sock(struct tipc_conn *con) 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)