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 --- 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 #include #include 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