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. This violates the TIPC protocol
specification.
The issue can be reproduced as follows:
1. Run a connection-oriented server that binds to a service range.
2. Run a connection-oriented client that binds to a service range, 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 returning -EINVAL when a client uses a service range to establish
a connection.
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 c607563bb35a..4ed895b75bf3 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);
--
2.53.0