For connection-oriented messaging, the address types that can be used are service addresses or socket addresses on the client side, and service addresses or service ranges on the server side. However, the current implementation allows a client to send a SYN or an implicit connection message using a service range. It also allows a server socket that is neither SOCK_STREAM nor SOCK_SEQPACKET to receive a SYN or an implicit connection message. This violates the TIPC protocol specification. Fix this by: - returning -EINVAL when a client uses a service range to establish a connection. - sending a reject message (TIPC_ERR_NO_PORT) when the server socket is neither SOCK_STREAM nor SOCK_SEQPACKET. Fixes: b97bf3fd8f6a ("[TIPC] Initial merge") Reported-by: Andrew Stellman Closes: https://lore.kernel.org/netdev/20261129001748.78733-1-bugs@stellman-greene.com/ Signed-off-by: Tung Nguyen --- net/tipc/socket.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/net/tipc/socket.c b/net/tipc/socket.c index c607563bb35a..1366c6a49d79 100644 --- a/net/tipc/socket.c +++ b/net/tipc/socket.c @@ -1458,6 +1458,8 @@ static int __tipc_sendmsg(struct socket *sock, struct msghdr *m, size_t dlen) return -EISCONN; if (tsk->published) return -EOPNOTSUPP; + if (atype == TIPC_SERVICE_RANGE) + return -EINVAL; if (atype == TIPC_SERVICE_ADDR) tsk->conn_addrtype = atype; msg_set_syn(hdr, 1); @@ -2377,6 +2379,7 @@ static void tipc_sk_filter_rcv(struct sock *sk, struct sk_buff *skb, hdr = buf_msg(skb); limit = rcvbuf_limit(sk, skb); if ((sk_conn && !tipc_sk_filter_connect(tsk, skb, xmitq)) || + (!sk_conn && msg_is_syn(hdr) && mtyp != TIPC_MCAST_MSG) || (!sk_conn && msg_connected(hdr)) || (!grp && msg_in_group(hdr))) err = TIPC_ERR_NO_PORT; -- 2.53.0