[prev in list] [next in list] [prev in thread] [next in thread] 

List:       git-commits-head
Subject:    tipc: close the connection if protocol messages contain errors
From:       "Linux Kernel Mailing List" <linux-kernel () vger ! kernel ! org>
Date:       2017-04-28 21:15:20
Message-ID: 20170428211520.DA7A16611DA () gitolite ! kernel ! org
[Download RAW message or body]

Web:        https://git.kernel.org/torvalds/c/c1be7756284b0fdbfe8aea8da968ce054697e0c5
Commit:     c1be7756284b0fdbfe8aea8da968ce054697e0c5
Parent:     4e0df4951e9ecb7ec026a1330ed59f12e8937a95
Refname:    refs/heads/master
Author:     Parthasarathy Bhuvaragan <parthasarathy.bhuvaragan@ericsson.com>
AuthorDate: Wed Apr 26 10:05:02 2017 +0200
Committer:  David S. Miller <davem@davemloft.net>
CommitDate: Fri Apr 28 12:20:42 2017 -0400

    tipc: close the connection if protocol messages contain errors
    
    When a socket is shutting down, we notify the peer node about the
    connection termination by reusing an incoming message if possible.
    If the last received message was a connection acknowledgment
    message, we reverse this message and set the error code to
    TIPC_ERR_NO_PORT and send it to peer.
    
    In tipc_sk_proto_rcv(), we never check for message errors while
    processing the connection acknowledgment or probe messages. Thus
    this message performs the usual flow control accounting and leaves
    the session hanging.
    
    In this commit, we terminate the connection when we receive such
    error messages.
    
    Signed-off-by: Parthasarathy Bhuvaragan <parthasarathy.bhuvaragan@ericsson.com>
    Reviewed-by: Jon Maloy <jon.maloy@ericsson.com>
    Signed-off-by: David S. Miller <davem@davemloft.net>
---
 net/tipc/socket.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/net/tipc/socket.c b/net/tipc/socket.c
index 38c367f6ced4..bdce99f9407a 100644
--- a/net/tipc/socket.c
+++ b/net/tipc/socket.c
@@ -866,6 +866,14 @@ static void tipc_sk_proto_rcv(struct tipc_sock *tsk, struct sk_buff *skb,
 	if (!tsk_peer_msg(tsk, hdr))
 		goto exit;
 
+	if (unlikely(msg_errcode(hdr))) {
+		tipc_set_sk_state(sk, TIPC_DISCONNECTING);
+		tipc_node_remove_conn(sock_net(sk), tsk_peer_node(tsk),
+				      tsk_peer_port(tsk));
+		sk->sk_state_change(sk);
+		goto exit;
+	}
+
 	tsk->probe_unacked = false;
 
 	if (mtyp == CONN_PROBE) {
--
To unsubscribe from this list: send the line "unsubscribe git-commits-head" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic