* [PATCH net v2 0/2] tipc: reject invalid use cases in connection-oriented client/server communication
@ 2026-12-04 0:29 Tung Nguyen
2026-12-04 0:29 ` [PATCH net v2 1/2] tipc: reject service-range SYN sent from connection-oriented socket Tung Nguyen
2026-12-04 0:29 ` [PATCH net v2 2/2] tipc: reject SYN sent from a connection-oriented socket to a datagram server Tung Nguyen
0 siblings, 2 replies; 8+ messages in thread
From: Tung Nguyen @ 2026-12-04 0:29 UTC (permalink / raw)
To: netdev
Cc: davem, kuba, edumazet, pabeni, jmaloy, horms, tipc-discussion,
willemb, Tung Nguyen
Patch 1 rejects service-range SYN sent from a connection-oriented socket
to a connection-oriented server.
Patch 2 rejects SYN sent from a connection-oriented socket to a
connectionless server.
v2:
- Patch 1: correct closed link in Closes tag.
- Patch 2: correct closed link in Closes tag.
v1: https://lore.kernel.org/netdev/20261202094607.219027-1-tung.quang.nguyen@est.tech/
Tung Nguyen (2):
tipc: reject service-range SYN sent from connection-oriented socket
tipc: reject SYN sent from a connection-oriented socket to a datagram
server
net/tipc/socket.c | 4 ++++
1 file changed, 4 insertions(+)
--
2.53.0
^ permalink raw reply [flat|nested] 8+ messages in thread* [PATCH net v2 1/2] tipc: reject service-range SYN sent from connection-oriented socket 2026-12-04 0:29 [PATCH net v2 0/2] tipc: reject invalid use cases in connection-oriented client/server communication Tung Nguyen @ 2026-12-04 0:29 ` Tung Nguyen 2026-12-05 1:11 ` netdev-bot+sashiko 2026-12-04 0:29 ` [PATCH net v2 2/2] tipc: reject SYN sent from a connection-oriented socket to a datagram server Tung Nguyen 1 sibling, 1 reply; 8+ messages in thread From: Tung Nguyen @ 2026-12-04 0:29 UTC (permalink / raw) To: netdev Cc: davem, kuba, edumazet, pabeni, jmaloy, horms, tipc-discussion, willemb, Tung Nguyen, Andrew Stellman 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 <astellman@stellman-greene.com> Closes: https://lore.kernel.org/netdev/20261129144901.90934-1-bugs@stellman-greene.com/ Signed-off-by: Tung Nguyen <tung.quang.nguyen@est.tech> --- v2: correct closed link in Closes tag. v1: https://lore.kernel.org/netdev/20261202094607.219027-1-tung.quang.nguyen@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 ^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH net v2 1/2] tipc: reject service-range SYN sent from connection-oriented socket 2026-12-04 0:29 ` [PATCH net v2 1/2] tipc: reject service-range SYN sent from connection-oriented socket Tung Nguyen @ 2026-12-05 1:11 ` netdev-bot+sashiko 2026-12-05 1:37 ` Tung Quang Nguyen 0 siblings, 1 reply; 8+ messages in thread From: netdev-bot+sashiko @ 2026-12-05 1:11 UTC (permalink / raw) To: tung.quang.nguyen Cc: netdev, davem, kuba, edumazet, pabeni, jmaloy, horms, tipc-discussion, willemb, astellman Thank you for your contribution! Sashiko AI review found more severe issue(s) in other patches of this series. This mail is only an FYI, in case you want to address the nit picks below when you respin. Low priority / nit picks for your consideration: - [Low] The commit message's reproducer and problem statement don't match the code. - [Low] tipc: Fixes trailer cites initial merge instead of 0abd8ff21f19 -- tipc: reject service-range SYN sent from connection-oriented socket This commit makes __tipc_sendmsg() return -EINVAL when a connection-oriented socket tries to set up a connection to a TIPC_SERVICE_RANGE destination. Before this change, such a send fell through to tipc_sendmcast(). Closes: https://lore.kernel.org/netdev/20261129144901.90934-1-bugs@stellman-greene.com/ > 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. [Severity: Low] Can step 2 of this reproducer trigger the bug? On a connection-oriented socket, bind goes through tipc_bind()->tipc_sk_bind()->__tipc_bind()->tipc_sk_publish(), which does this: net/tipc/socket.c:tipc_sk_publish() { ... tsk->published = true; return 0; } In __tipc_sendmsg(), the syn branch checks published before it gets to the new service range check: if (tsk->published) return -EOPNOTSUPP; if (atype == TIPC_SERVICE_RANGE) return -EINVAL; So a client that binds first gets -EOPNOTSUPP from sendto() whether or not this patch is applied, and the server never receives anything. The path this patch closes seems to be an unbound SOCK_STREAM or SOCK_SEQPACKET client that calls sendto() or sendmsg() with a TIPC_SERVICE_RANGE destination. The code change looks correct for that case. Should step 2 say that the client sends to a service range, rather than binds to one? > However, the current implementation allows a client to send a SYN or an implicit > connection message using a service range. Is the explicit SYN part of this sentence accurate? tipc_connect() already rejects service ranges on connection-oriented sockets: net/tipc/socket.c:tipc_connect() { ... } else if (dst->addrtype == TIPC_SERVICE_RANGE) { res = -EINVAL; goto exit; } ... } It looks like only the implicit connect through sendmsg() was open. The second patch in the series, "tipc: reject SYN sent from a connection-oriented socket to a datagram server", only changes tipc_sk_filter_rcv(), so it does not affect this. [ ... ] > diff --git a/net/tipc/socket.c b/net/tipc/socket.c > --- 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); [Severity: Low] Is b97bf3fd8f6a the right commit for the Fixes tag? In the initial merge, send_msg() already refused TIPC_ADDR_MCAST (the old name for TIPC_SERVICE_RANGE) on connection-oriented sockets: if (needs_conn) { res = -EOPNOTSUPP; goto exit; } That guard survived e2dafe87d328 ("tipc: RDM/DGRAM transport uses new fragmenting and sending functions"). That commit split the multicast path out into tipc_sendmcast() and kept a sock->state != SS_READY test there that returned -EOPNOTSUPP. The protection appears to have been lost in 0abd8ff21f19 ("tipc: start using the new multicast functions"). That commit rewrote tipc_sendmcast() and dropped the SS_READY check without adding an equivalent one in tipc_sendmsg(). That seems to be the first point where an unconnected SOCK_STREAM or SOCK_SEQPACKET socket could reach tipc_sendmcast() with a service range destination. If that history is right, should the tag be: Fixes: 0abd8ff21f19 ("tipc: start using the new multicast functions") There is no runtime impact either way. However, blaming the initial merge misleads anyone tracing where the regression came from. It also misleads the tooling that uses the Fixes tag to decide which trees need the backport. -- Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261204003240.63452-1-tung.quang.nguyen%40est.tech ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH net v2 1/2] tipc: reject service-range SYN sent from connection-oriented socket 2026-12-05 1:11 ` netdev-bot+sashiko @ 2026-12-05 1:37 ` Tung Quang Nguyen 0 siblings, 0 replies; 8+ messages in thread From: Tung Quang Nguyen @ 2026-12-05 1:37 UTC (permalink / raw) To: netdev-bot+sashiko@kernel.org Cc: netdev@vger.kernel.org, davem@davemloft.net, kuba@kernel.org, edumazet@kernel.org, pabeni@redhat.com, jmaloy@redhat.com, horms@kernel.org, tipc-discussion@lists.sourceforge.net, willemb@google.com, astellman@stellman-greene.com > Subject: Re: [PATCH net v2 1/2] tipc: reject service-range SYN sent from connection-oriented socket > Low priority / nit picks for your consideration: > - [Low] The commit message's reproducer and problem statement don't match the code. > - [Low] tipc: Fixes trailer cites initial merge instead of 0abd8ff21f19 I will address above comments in v3. -- pw-bot: cr ^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH net v2 2/2] tipc: reject SYN sent from a connection-oriented socket to a datagram server 2026-12-04 0:29 [PATCH net v2 0/2] tipc: reject invalid use cases in connection-oriented client/server communication Tung Nguyen 2026-12-04 0:29 ` [PATCH net v2 1/2] tipc: reject service-range SYN sent from connection-oriented socket Tung Nguyen @ 2026-12-04 0:29 ` Tung Nguyen 2026-12-04 1:17 ` Andrew Stellman 2026-12-05 1:11 ` netdev-bot+sashiko 1 sibling, 2 replies; 8+ messages in thread From: Tung Nguyen @ 2026-12-04 0:29 UTC (permalink / raw) To: netdev Cc: davem, kuba, edumazet, pabeni, jmaloy, horms, tipc-discussion, willemb, Tung Nguyen, Andrew Stellman 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 <astellman@stellman-greene.com> Closes: https://lore.kernel.org/netdev/20261129144901.90934-1-bugs@stellman-greene.com/ Signed-off-by: Tung Nguyen <tung.quang.nguyen@est.tech> --- v2: correct closed link in Closes tag. v1: https://lore.kernel.org/netdev/20261202094607.219027-1-tung.quang.nguyen@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 ^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH net v2 2/2] tipc: reject SYN sent from a connection-oriented socket to a datagram server 2026-12-04 0:29 ` [PATCH net v2 2/2] tipc: reject SYN sent from a connection-oriented socket to a datagram server Tung Nguyen @ 2026-12-04 1:17 ` Andrew Stellman 2026-12-04 1:27 ` Tung Quang Nguyen 2026-12-05 1:11 ` netdev-bot+sashiko 1 sibling, 1 reply; 8+ messages in thread From: Andrew Stellman @ 2026-12-04 1:17 UTC (permalink / raw) To: Tung Nguyen Cc: netdev, David S. Miller, Jakub Kicinski, Eric Dumazet, Paolo Abeni, Jon Maloy, Simon Horman, tipc-discussion, Willem de Bruijn Hi Tung, Thanks for picking these up. In 2/2, the new condition is narrower than the existing (!sk_conn && msg_connected(hdr)) line right after it, which the patch leaves in place, so as far as I can tell it doesn't change behaviour. __tipc_sendmsg() sends a SYN as a NAMED or DIRECT message with the SYN bit set, so msg_connected() (TIPC_CONN_MSG) won't match it. Did you mean msg_is_syn(hdr) instead of msg_connected(hdr)? Andrew --- I checked this with Claude Opus 5.5 by reading net/tipc/socket.c and net/tipc/msg.h on mainline; I haven't run the patch. ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH net v2 2/2] tipc: reject SYN sent from a connection-oriented socket to a datagram server 2026-12-04 1:17 ` Andrew Stellman @ 2026-12-04 1:27 ` Tung Quang Nguyen 0 siblings, 0 replies; 8+ messages in thread From: Tung Quang Nguyen @ 2026-12-04 1:27 UTC (permalink / raw) To: Andrew Stellman Cc: netdev@vger.kernel.org, David S. Miller, Jakub Kicinski, Eric Dumazet, Paolo Abeni, Jon Maloy, Simon Horman, tipc-discussion@lists.sourceforge.net, Willem de Bruijn > Subject: Re: [PATCH net v2 2/2] tipc: reject SYN sent from a connection-oriented socket to a datagram server > Hi Tung, > Thanks for picking these up. In 2/2, the new condition is narrower > than the existing (!sk_conn && msg_connected(hdr)) line right after it, > which the patch leaves in place, so as far as I can tell it doesn't > change behaviour. __tipc_sendmsg() sends a SYN as a NAMED or DIRECT > message with the SYN bit set, so msg_connected() (TIPC_CONN_MSG) won't > match it. Did you mean msg_is_syn(hdr) instead of msg_connected(hdr)? Oops. My bad ! I believe I copied "msg_connected(hdr)" from a wrong place. I will correct in v3 after 24 hours. Thanks for your quick check. ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH net v2 2/2] tipc: reject SYN sent from a connection-oriented socket to a datagram server 2026-12-04 0:29 ` [PATCH net v2 2/2] tipc: reject SYN sent from a connection-oriented socket to a datagram server Tung Nguyen 2026-12-04 1:17 ` Andrew Stellman @ 2026-12-05 1:11 ` netdev-bot+sashiko 1 sibling, 0 replies; 8+ messages in thread From: netdev-bot+sashiko @ 2026-12-05 1:11 UTC (permalink / raw) To: tung.quang.nguyen Cc: netdev, davem, kuba, edumazet, pabeni, jmaloy, horms, tipc-discussion, willemb, astellman Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider. Critical: 0 · High: 1 · Medium: 0 · Low: 0 If you believe none of the issues are legitimate, please reply to each issue of Medium severity or higher and explain why the AI is wrong. If any of them are legitimate and you plan to respin, please let patchwork know by including "pw-bot: cr" as a separate line at the end of your reply (one such reply per series is enough). - [High] This patch has no effect: a datagram server still accepts the SYN that the commit message says it rejects. -- tipc: reject SYN sent from a connection-oriented socket to a datagram server The patch tries to make a connectionless (SOCK_RDM/SOCK_DGRAM) TIPC server socket reject SYN or implicit-connect messages from connection-oriented clients with TIPC_ERR_NO_PORT. To do this it adds a clause to the receive filter in tipc_sk_filter_rcv(). Closes: https://lore.kernel.org/netdev/20261129144901.90934-1-bugs@stellman-greene.com/ > diff --git a/net/tipc/socket.c b/net/tipc/socket.c > index 4ed895b75bf3a..e606954fbd2c3 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)) || [Severity: High] Can this new clause ever be true for a SYN? msg_connected() only checks the message type: net/tipc/msg.h: static inline u32 msg_connected(struct tipc_msg *m) { return msg_type(m) == TIPC_CONN_MSG; } The SYN built by __tipc_sendmsg() is never a TIPC_CONN_MSG. It is a NAMED or DIRECT message with the SYN bit set: net/tipc/socket.c:__tipc_sendmsg() { ... msg_set_syn(hdr, 1); ... if (atype == TIPC_SERVICE_ADDR) { msg_set_type(hdr, TIPC_NAMED_MSG); ... } else { /* TIPC_SOCKET_ADDR */ msg_set_type(hdr, TIPC_DIRECT_MSG); ... } So msg_connected(hdr) is false for every SYN, and the new clause is false too. Whenever the new clause is true, the unchanged line after it is also true: (!sk_conn && msg_connected(hdr)) As a result, the set of rejected messages looks the same as before the patch. A SOCK_RDM or SOCK_DGRAM server would still add the SYN-flagged NAMED/DIRECT message to sk_receive_queue. Would the reproducer in the commit message still show the problem? There is a second issue with the clause. mtyp is read once, from the first skb, before the dequeue loop: int mtyp = msg_type(hdr); The loop never reads it again for the skb it is checking. Was the intent to test msg_is_syn(hdr), together with a type check on the current skb's header? The type check matters because tipc_mcast_send_sync() in net/tipc/bcast.c also sets the SYN bit, on TIPC_MCAST_MSG headers that connectionless sockets legitimately receive: /* Preparing for 'synching' header */ msg_set_syn(hdr, 1); A plain !sk_conn && msg_is_syn(hdr) test would also reject that multicast traffic. > (!grp && msg_in_group(hdr))) > err = TIPC_ERR_NO_PORT; -- Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261204003240.63452-1-tung.quang.nguyen%40est.tech ^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2026-12-05 1:37 UTC | newest] Thread overview: 8+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2026-12-04 0:29 [PATCH net v2 0/2] tipc: reject invalid use cases in connection-oriented client/server communication Tung Nguyen 2026-12-04 0:29 ` [PATCH net v2 1/2] tipc: reject service-range SYN sent from connection-oriented socket Tung Nguyen 2026-12-05 1:11 ` netdev-bot+sashiko 2026-12-05 1:37 ` Tung Quang Nguyen 2026-12-04 0:29 ` [PATCH net v2 2/2] tipc: reject SYN sent from a connection-oriented socket to a datagram server Tung Nguyen 2026-12-04 1:17 ` Andrew Stellman 2026-12-04 1:27 ` Tung Quang Nguyen 2026-12-05 1:11 ` netdev-bot+sashiko
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox