From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=91.198.224.70 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796028339; b=g+VrwEwJjrNXaH7+ges10JdO6mZG9CgNzDus3iZEy9/wHaRdwYhk79Cp1kxV+sBTKlIj qZu2i6+5nyrxiMXBvvpoLUWw62PWzFqB2yFV+dlzjEbwfUBlisHm+8rV4Tzaz4XoII1fU 5xze7MbUqLZjpNlnCUNJx9qlKJBKO1CbatH4opw0SJtLlq1di/7zQlQZ8s+IzX0L61kYS OBbMz5HcvIhkn+PQuh/fpMrsOaN2gUnqLD5tLXwVC/sZkheBGVlUth7FQkn87JQHo09nz RD5BxGXcPtgiZjpNKm9E8NEGPhA++5IIDqX6t8CK4sULdzWwbuepqvw3IUegom9BQYg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796028339; h=DMARC-Filter:Received:Received:DKIM-Signature:Received:Received: Received:From:Date:Subject:MIME-Version:Content-Type: Content-Transfer-Encoding:Message-ID:X-B4-Tracking:X-Change-ID:To:Cc: X-Mailer:X-Developer-Signature:X-Developer-Key:X-Spam-Status: X-Spam-Checker-Version:X-purgate-type:X-purgate-ID:X-purgate; bh=nq5VBctiNT6XvqnIG+jWt3jTCr3X5UVGNViM1IGM618=; b=bEHQqIIbUwGD0hkPQKNgHLH4qz3V573Hqw7LBpcVAadCqlyuQTOik/eKKPuaXE48jxIS wFMSAw+KiXp9nmhmT4oY2c9Ndq9TJIbP2KKnJAc/G6+nPrxj77DAikeezpwoGu6/cVY+m zrOVj1pGza10KL3pibgNyRijy+19Z1M5Uc2WqGJli1xp3DuElhL1qGel/r1cZLSa8X4eS 0rkUBgpPLgfO7XKbA5TbbSMoF8fw8rs5jn2i/Wq3NOPddWPGtbRB19aRbJIc+rw7G0ndX vqmwoFpEjVgrRwGnMJi3yd707FkFn25uxjNagK4tDuxq+urwHaLkwBsrIqXB+XsPKGg== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=dev.tdt.de; spf=pass smtp.mailfrom=dev.tdt.de; dkim=temperror header.d=dev.tdt.de header.i=@dev.tdt.de header.a=rsa-sha256 header.s=z1-selector1 header.b=xK+qhRF9; arc=none smtp.remote-ip=91.198.224.70 Received: from mxout70.expurgate.net (mxout70.expurgate.net [91.198.224.70]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8C353606A33A; Mon, 30 Nov 2026 08:45:38 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 8C353606A33A Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=dev.tdt.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=dev.tdt.de Authentication-Results: smtp.subspace.kernel.org; dkim=temperror header.d=dev.tdt.de header.i=@dev.tdt.de header.a=rsa-sha256 header.s=z1-selector1 header.b=xK+qhRF9 Received: from [194.37.255.9] (helo=mxout.expurgate.net) by relay.expurgate.net with smtp (Exim 4.92) (envelope-from ) id 1xXx0p-00FINX-2B; Mon, 30 Nov 2026 09:45:27 +0100 Received: from [195.243.126.94] (helo=securemail.tdt.de) by relay.expurgate.net with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1xXx0m-009SL1-NC; Mon, 30 Nov 2026 09:45:24 +0100 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=dev.tdt.de; s=z1-selector1; t=1796028323; bh=nq5VBctiNT6XvqnIG+jWt3jTCr3X5UVGNViM1IGM618=; h=From:Date:Subject:To:Cc:From; b=xK+qhRF9lvImelLEsThtinfpgCWFeVEnHcnh6CH7yo0SeVERRa57jvu8I1XUbs8Xz 1h6p4BGp3ILBHuzcZH8eEEJJWXFhw7cDuYCeGtBqOgRbDKkh0tfdOLYu4tfnVZVkIU 2InLq4yPIFBhPRiCTgOpyBlYy8C3JGLK6e4yC2Fe19cVNiaHX+BrYEo8SdmIGmIqus 681uKzD4qSb6v+bpSR79ELD0+wuy43mToSK+wSlN1Xeg+eZgW3IHbubEI3aF/Rj9P3 fD97+Xw1r8NRgYDDO3bWfCrkz6Bb/Av+sINtp/OkP9gjJSfyN+bQ6wuBGwrri2f4l/ k0Avzs3eDrdPA== Received: from securemail.tdt.de (localhost [127.0.0.1]) by securemail.tdt.de (Postfix) with ESMTP id E6BA3240040; Mon, 30 Nov 2026 09:45:23 +0100 (CET) Received: from mail.dev.tdt.de (unknown [10.2.4.42]) by securemail.tdt.de (Postfix) with ESMTP id D0C53240036; Mon, 30 Nov 2026 09:45:23 +0100 (CET) Received: from [127.0.1.1] (unknown [10.2.3.19]) by mail.dev.tdt.de (Postfix) with ESMTPSA id 74A782A88C; Mon, 30 Nov 2026 09:45:23 +0100 (CET) From: Martin Schiller Date: Mon, 30 Nov 2026 09:45:07 +0100 (CET) Subject: [PATCH net v2] net/x25: release the route on a nonblocking connect X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-ID: <20261130-x25-route-leak-v2-1-dec62d76bfbc@dev.tdt.de> X-B4-Tracking: v=1; b=H4sIAJM3DWsC/x3M0QpAMBSH8VfRuXbKxqa8ilyI/zjRaENK3t1y+ bv4vocigiBSkz0UcEmUzSfoPKNh7v0EljGZdKGtUmXBtzYctvMAr+gXVnU1qNo6MxpQivYAJ/c /bMnjoO59PzlUFSBlAAAA X-Change-ID: 20261130-x25-route-leak-174c176f5d5e To: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Willem de Bruijn , Simon Horman Cc: linux-x25@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Wentao Liang , stable@vger.kernel.org, Martin Schiller X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1796028323; l=2344; i=ms@dev.tdt.de; s=20260220; h=from:subject:message-id; bh=eEA8OzpwSsJt6TWuUExUh3PqRlOnRWUV9SGgYMlOMug=; b=8j+aDjajogC3DJe25Tq6FHJfW0uqpPlxclFXicceI8shSwYU+rKzxQy7snoKiYJGDEr8fj05P FQjW4MNlkINBvJNbJdKoFDT9Wlbdg8bLSzWQFNm8+xcKY5uE4UFPqIk X-Developer-Key: i=ms@dev.tdt.de; a=ed25519; pk=MAojd7D5IafMnqCYSFC7hY/u/jppX58CLIEhsEsSOYE= X-purgate-type: clean X-purgate-ID: 151534::1796028325-CE761E18-97D58297/0/0 X-purgate: clean From: Wentao Liang 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 [ms: describe how the leak shows up, drop the Assisted-by tag] Signed-off-by: Martin Schiller --- 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