All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH net] tipc: initialize the whole connect retry delay
@ 2026-11-25  2:05 Kyuwon Cho
  2026-11-26  8:31 ` Tung Quang Nguyen
  2026-12-02  2:40 ` patchwork-bot+netdevbpf
  0 siblings, 2 replies; 3+ messages in thread
From: Kyuwon Cho @ 2026-11-25  2:05 UTC (permalink / raw)
  To: Jon Maloy, Tung Quang Nguyen
  Cc: David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
	Willem de Bruijn, Simon Horman, Ying Xue, netdev, tipc-discussion

When a connecting socket gets TIPC_ERR_OVERLOAD and still has its SYN,
tipc_sk_filter_connect() schedules a retry after a random delay:

	get_random_bytes(&delay, 2);
	...
	delay %= (tsk->conn_timeout / 4);

delay is an unsigned long, so only two of its bytes are random and the
rest are whatever was on the stack:

  BUG: KMSAN: uninit-value in tipc_sk_filter_rcv (net/tipc/socket.c:2244)
   tipc_sk_filter_rcv (net/tipc/socket.c:2244 net/tipc/socket.c:2379)
   tipc_sk_backlog_rcv (net/tipc/socket.c:2422)
   __release_sock (net/core/sock.c:3344)
   release_sock (net/core/sock.c:3941)
   tipc_wait_for_connect (net/tipc/socket.c:2559)
   tipc_connect (net/tipc/socket.c:2658)
   __sys_connect (net/socket.c:2185)
  Local variable delay.i created at:
   tipc_sk_filter_rcv (net/tipc/socket.c:2207 net/tipc/socket.c:2379)

Use get_random_u16(), which gives the same range.

Fixes: 6787927475e5 ("tipc: buffer overflow handling in listener socket")
Signed-off-by: Kyuwon Cho <kyuwoncho18@gmail.com>
---
The issue was found by an LLM-guided test generator that we are
developing as a research prototype. A reproducer, which runs as any
user:

#include <linux/tipc.h>
#include <sys/socket.h>
#include <unistd.h>

int main(void)
{
	struct sockaddr_tipc a = {
		.family = AF_TIPC,
		.addrtype = TIPC_SERVICE_ADDR,
		.scope = TIPC_NODE_SCOPE,
		.addr.name.name = { .type = 18888, .instance = 1 },
	};
	int srv = socket(AF_TIPC, SOCK_STREAM, 0), rcvbuf = 1024, tmo = 3;

	/* a listener that is overloaded at once */
	setsockopt(srv, SOL_SOCKET, SO_RCVBUF, &rcvbuf, sizeof(rcvbuf));
	bind(srv, (void *)&a, sizeof(a));
	listen(srv, 0);
	for (int i = 0; i < 96; i++) {
		int fd = socket(AF_TIPC, SOCK_STREAM, 0);

		setsockopt(fd, SOL_TIPC, TIPC_CONN_TIMEOUT, &tmo, sizeof(tmo));
		connect(fd, (void *)&a, sizeof(a));
	}
	sleep(1);
	return 0;
}

Without the patch, KMSAN reports the uninit-value above during the
connects; with it, it does not.

The patch was written with LLM assistance; we reviewed and tested it.

 net/tipc/socket.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/tipc/socket.c b/net/tipc/socket.c
index 65cc0c4964b3..e84168b29df9 100644
--- a/net/tipc/socket.c
+++ b/net/tipc/socket.c
@@ -2237,7 +2237,7 @@ static bool tipc_sk_filter_connect(struct tipc_sock *tsk, struct sk_buff *skb,
 		/* Prepare for new setup attempt if we have a SYN clone */
 		if (skb_queue_empty(&sk->sk_write_queue))
 			break;
-		get_random_bytes(&delay, 2);
+		delay = get_random_u16();
 		if (tsk->conn_timeout < 4)
 			tsk->conn_timeout = 4;
 		delay %= (tsk->conn_timeout / 4);
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* RE: [PATCH net] tipc: initialize the whole connect retry delay
  2026-11-25  2:05 [PATCH net] tipc: initialize the whole connect retry delay Kyuwon Cho
@ 2026-11-26  8:31 ` Tung Quang Nguyen
  2026-12-02  2:40 ` patchwork-bot+netdevbpf
  1 sibling, 0 replies; 3+ messages in thread
From: Tung Quang Nguyen @ 2026-11-26  8:31 UTC (permalink / raw)
  To: Kyuwon Cho
  Cc: David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
	Willem de Bruijn, Simon Horman, netdev@vger.kernel.org,
	tipc-discussion@lists.sourceforge.net, Jon Maloy

>Subject: [PATCH net] tipc: initialize the whole connect retry delay
>
>When a connecting socket gets TIPC_ERR_OVERLOAD and still has its SYN,
>tipc_sk_filter_connect() schedules a retry after a random delay:
>
>	get_random_bytes(&delay, 2);
>	...
>	delay %= (tsk->conn_timeout / 4);
>
>delay is an unsigned long, so only two of its bytes are random and the rest are
>whatever was on the stack:
>
>  BUG: KMSAN: uninit-value in tipc_sk_filter_rcv (net/tipc/socket.c:2244)
>   tipc_sk_filter_rcv (net/tipc/socket.c:2244 net/tipc/socket.c:2379)
>   tipc_sk_backlog_rcv (net/tipc/socket.c:2422)
>   __release_sock (net/core/sock.c:3344)
>   release_sock (net/core/sock.c:3941)
>   tipc_wait_for_connect (net/tipc/socket.c:2559)
>   tipc_connect (net/tipc/socket.c:2658)
>   __sys_connect (net/socket.c:2185)
>  Local variable delay.i created at:
>   tipc_sk_filter_rcv (net/tipc/socket.c:2207 net/tipc/socket.c:2379)
>
>Use get_random_u16(), which gives the same range.
>
>Fixes: 6787927475e5 ("tipc: buffer overflow handling in listener socket")
>Signed-off-by: Kyuwon Cho <kyuwoncho18@gmail.com>

Reviewed-by: Tung Nguyen <tung.quang.nguyen@est.tech>

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH net] tipc: initialize the whole connect retry delay
  2026-11-25  2:05 [PATCH net] tipc: initialize the whole connect retry delay Kyuwon Cho
  2026-11-26  8:31 ` Tung Quang Nguyen
@ 2026-12-02  2:40 ` patchwork-bot+netdevbpf
  1 sibling, 0 replies; 3+ messages in thread
From: patchwork-bot+netdevbpf @ 2026-12-02  2:40 UTC (permalink / raw)
  To: Kyuwon Cho
  Cc: jmaloy, tung.quang.nguyen, davem, edumazet, kuba, pabeni, willemb,
	horms, ying.xue, netdev, tipc-discussion

Hello:

This patch was applied to netdev/net.git (main)
by Willem de Bruijn <willemb@google.com>:

On Wed, 25 Nov 2026 11:05:02 +0900 you wrote:
> When a connecting socket gets TIPC_ERR_OVERLOAD and still has its SYN,
> tipc_sk_filter_connect() schedules a retry after a random delay:
> 
> 	get_random_bytes(&delay, 2);
> 	...
> 	delay %= (tsk->conn_timeout / 4);
> 
> [...]

Here is the summary with links:
  - [net] tipc: initialize the whole connect retry delay
    https://git.kernel.org/netdev/net/c/b978a3a745a6

You are awesome, thank you!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-12-02  2:40 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-25  2:05 [PATCH net] tipc: initialize the whole connect retry delay Kyuwon Cho
2026-11-26  8:31 ` Tung Quang Nguyen
2026-12-02  2:40 ` patchwork-bot+netdevbpf

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.