From: Kyuwon Cho <kyuwoncho18@gmail.com>
To: Jon Maloy <jmaloy@redhat.com>,
Tung Quang Nguyen <tung.quang.nguyen@est.tech>
Cc: "David S. Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@kernel.org>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
Willem de Bruijn <willemb@google.com>,
Simon Horman <horms@kernel.org>,
Ying Xue <ying.xue@windriver.com>,
netdev@vger.kernel.org, tipc-discussion@lists.sourceforge.net
Subject: [PATCH net] tipc: initialize the whole connect retry delay
Date: Wed, 25 Nov 2026 11:05:02 +0900 [thread overview]
Message-ID: <179553307367.1670514.861086873017775410@gmail.com> (raw)
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
reply other threads:[~2026-11-25 2:05 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=179553307367.1670514.861086873017775410@gmail.com \
--to=kyuwoncho18@gmail.com \
--cc=davem@davemloft.net \
--cc=edumazet@kernel.org \
--cc=horms@kernel.org \
--cc=jmaloy@redhat.com \
--cc=kuba@kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=tipc-discussion@lists.sourceforge.net \
--cc=tung.quang.nguyen@est.tech \
--cc=willemb@google.com \
--cc=ying.xue@windriver.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox