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 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. The issue can be reproduced as follows: 1. Run a datagram (connectionless) server that binds to a service range. 2. Run a connection-oriented client that binds to a service address, then sends an implicit connection message to the server using sendto(). 3. Read from the server socket. The server still receives the connection message, which is unexpected behavior. Fix this by 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 <aste…@stellman-greene.com> Closes: https://lore.kernel.org/netdev/2026…@stellman-greene.com/ Signed-off-by: Tung Nguyen <tung…@est.tech> --- v2: correct closed link in Closes tag. v1: https://lore.kernel.org/netdev/2026…@est.tech/ net/tipc/socket.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/net/tipc/socket.c b/net/tipc/socket.c index 4ed895b75bf3..e606954fbd2c 100644 --- a/net/tipc/socket.c +++ b/net/tipc/socket.c @@ -2379,6 +2379,8 @@ 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_connected(hdr) && + (mtyp == TIPC_NAMED_MSG || mtyp == TIPC_DIRECT_MSG)) || (!sk_conn && msg_connected(hdr)) || (!grp && msg_in_group(hdr))) err = TIPC_ERR_NO_PORT;
-- 2.53.0