mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH net v2] net/x25: release the route on a nonblocking connect
@ 2026-11-30  8:45 Martin Schiller
  0 siblings, 0 replies; only message in thread
From: Martin Schiller @ 2026-11-30  8:45 UTC (permalink / raw)
  To: David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
	Willem de Bruijn, Simon Horman
  Cc: linux-x25, netdev, linux-kernel, Wentao Liang, stable, Martin Schiller

From: Wentao Liang <vulab@iscas.ac.cn>

x25_connect() takes a reference on the route with x25_get_route() and
drops it at out_put_route.  The nonblocking path after
x25_write_internal() jumps straight to out instead, so the reference
is leaked on every nonblocking connect.

That path cannot use out_put_neigh because the neighbour is still
needed by the pending call, but the route is no longer referenced
once the neighbour has been looked up.

Jump to out_put_route so only the route reference is dropped.

The leak is easy to trigger without kernel changes: after a single
nonblocking connect() and deleting the route with SIOCDELRT, kmemleak
reports the route, which was allocated in x25_route_ioctl():

  unreferenced object 0xffff8880008cf940 (size 64):
    comm "x25test", pid 26, jiffies 4294892916
    backtrace (crc 40ba0c57):
      __kmalloc_cache_noprof+0x3c/0x69
      x25_route_ioctl+0xe8/0x1bf
      sock_ioctl+0x2d4/0x35d
      __x64_sys_ioctl+0x56a/0x77c

With this patch, kmemleak reports nothing in the same test.

Fixes: e21dba7a4df4 ("net/x25: fix nonblocking connect")
Cc: stable@vger.kernel.org
Signed-off-by: Wentao Liang <vulab@iscas.ac.cn>
[ms: describe how the leak shows up, drop the Assisted-by tag]
Signed-off-by: Martin Schiller <ms@dev.tdt.de>
---
v2 (Martin Schiller):
- add how to trigger the leak and the kmemleak report
- drop the Assisted-by line; v1 named DeepSeek-V4.1-Flash and OpenAI
  Codex there
- v2 was prepared with the help of an AI assistant (Claude, Anthropic)
- Link to v1: https://lore.kernel.org/all/20261104022812.1484250-1-vulab@iscas.ac.cn/
---
 net/x25/af_x25.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/x25/af_x25.c b/net/x25/af_x25.c
index 802688d5ad5687850764d0b779c72f039097b3d5..ddb32d582e4f8d6900a74c3fd92dc67420944723 100644
--- a/net/x25/af_x25.c
+++ b/net/x25/af_x25.c
@@ -813,7 +813,7 @@ static int x25_connect(struct socket *sock, struct sockaddr_unsized *uaddr,
 	/* Now the loop */
 	rc = -EINPROGRESS;
 	if (sk->sk_state != TCP_ESTABLISHED && (flags & O_NONBLOCK))
-		goto out;
+		goto out_put_route;
 
 	rc = x25_wait_for_connection_establishment(sk);
 	if (rc)

---
base-commit: e2fb9368a41662bc54624f9be87ea8989b109306
change-id: 20261130-x25-route-leak-174c176f5d5e

Best regards,
-- 
Martin Schiller <ms@dev.tdt.de>


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2026-11-30  8:45 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-30  8:45 [PATCH net v2] net/x25: release the route on a nonblocking connect Martin Schiller

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®