From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-oa1-f49.google.com (mail-oa1-f49.google.com [209.85.160.49]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3C7A340B0F2 for ; Mon, 24 Aug 2026 12:29:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.160.49 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787574585; cv=none; b=EZJdGEBawNKcVFJNJ+8+L6qqz0+0amcUsIaEj9ewhFKr++M86F1XmNyWW92c1gCXZO9X0x2O/JX9NwTJs2EA+d0alufxS0Cio9rxAyoAoWhOskDChwfpfQcJgCYZChMHbYox9z8gx94pOn7gkRBQg5i+Zr6TLKloMBDo8G5rfjk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787574585; c=relaxed/simple; bh=/p4Yl9cRrA/08EFs7XUHDyj23xIlq6ZPP0gzi9wHapg=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=Tpn3waCWg/yoXsBVGDk9g77rQnsbEAvVgQ3j2kP8mrO0KiMogUbyEz9/rMprncz2oApT2Ua5Y2K1TIupO8220J+kh43wVxpuJeBEyUi24Te/+vur8Z25otYukbZlIuCNkiASnq3CibBL4SXjXNMEgtpWZIGoa5jjsOAzjikiH4w= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=USrDBV0b; arc=none smtp.client-ip=209.85.160.49 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="USrDBV0b" Received: by mail-oa1-f49.google.com with SMTP id 586e51a60fabf-4498f3b4910so479524fac.3 for ; Mon, 24 Aug 2026 05:29:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1787574581; x=1788179381; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to:content-type; bh=udVPUe6IPHcf7p6BJaM0xcgin13VVHNN5Zpwgn/hQ6I=; b=USrDBV0bKQZq9JYtrMP2fBafqLKGBeX/fy3asHPsvY+XBbwv3V0sRSF7QKlk0w2al7 cFw5Vwd2IYBOPkmoYH7USfKgKZCXUrYkZh5cDr8FPdRI8jLgtYhCJjMVv0Ab7yBxQhF+ TTZCTwi/oZlqCukP8q94ImTs0zoQrorFjrM9hBQSJIJqdUasGIg6ihcck4D3SYuV14p7 /1L/PgWtRgOQpDdjccYU/3O8a7HMI0LDTM/nu1DxeUY29gmUzV7DhVZF/X3E+jv0Ytwr XiIX5vSx/WphTevs3Zrw307wYpgD0scVEuOagsdam7X3Ap4PTmyuWMP3C7kYmhhInOcf QcEg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1787574581; x=1788179381; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to:content-type; bh=udVPUe6IPHcf7p6BJaM0xcgin13VVHNN5Zpwgn/hQ6I=; b=bZ5eA6Fsr7DVJCKqV6N8wY/6dHW3cHc6u7cu03pFD1X4ZmGtAIhHOZnueoTyXeGyEq fRoOkLnYY7wYY8Tse19Ya3QZY+6FFqA5G/zojjIxOfuNZE3pdJpqirAcPdvnsWnH8oSV VK376z/wFCTJPoIIj2tPyu0P3AiA9/zX/AklTBerfhMrmH24oU+XvRQtUJ7nHUhnKfiJ oiYtGqPdURR5QE95xCXNLT2nZNbQ9Pp9+JEDuqx31XTBeHOasl2QEuRl5YAsI/7ZOK5D TuXoVSJ3r7nvBQ/Q9ckKJK60bYSAmPp6jF7fKhu/fhV9e8f0LUIF5unHYLPrkklekw+7 JYSw== X-Forwarded-Encrypted: i=1; AHgh+RonC/BSN4OVVfTvLsaFtmEmaqk6zzB9F0R/vfYsq6dRrE267Hcrb+1ax7O//exTinpmcxsxLTjuXx+suf8=@vger.kernel.org X-Gm-Message-State: AFuF++nG1ed/U6igReCppajBgEzH6gTuqSysW8dtaJqK/WV5F1LdWvkI ZgQxTJEpi6io8n2r/UZxCAU8qUy1lOUlqN0G4/lZw/rb/XgiD1cp7zXv X-Gm-Gg: AR+sD10NEVcD1r0FR/cnVCebQ9FcWAFQpFQEzkTnEfxFiI9s8O52TgZSmJjG+nOwUrT zZ7R/iSS3npE22aCBtlqHUywvSePiHpJsCtDpFm/jf50OTXAXc7zP6uxmk+0U/i0kP+pNspDGHl yu3KWJhTTBZwVcMyeHk3T5fqPOXDtMVwR0JCcGgCWNVKviBoBAhhE/w7WHBDHRdeIfWYmTEc8UF 6jyqE1+GJPTiD8QCtLy4nkkSpConn4bz3r0KO/7IiTo6PkvjEIvoVc2kGarmn4372WSEX8lENvq OnlBg95m5Udn73kXysDXX5t0gkyVuk09hkLFkXN3SUgNuiu2H+2amLstJ/EdozJSa4dAwgNzlzy W/W2nTuKdkNj5E1peiVJ+430fztHpxxjfQ/9ZIszWwyo0UIbkn2vU3Uq9MFI8nTPEu1TdtjUF+f oE7nkvivCZyoAQS2Ae4WPCWXgCtx2EopOMWvMDoWruJz/DVJXPivHx+FNQbfSr3L2IN8uf3a+xy Fi3R19VGNt+oCIAVfFCBdWU8+GWQSLNqS2KCOyP+5j/hfMbL8/V2RM0 X-Received: by 2002:a05:6820:341a:20b0:6a3:6bb0:e584 with SMTP id 006d021491bc7-6b1592c253cmr9992591eaf.1.1787574580793; Mon, 24 Aug 2026 05:29:40 -0700 (PDT) Received: from localhost.localdomain (45.78.65.84.16clouds.com. [45.78.65.84]) by smtp.gmail.com with ESMTPSA id 006d021491bc7-6b17c832d31sm3598839eaf.5.2026.08.24.05.29.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 24 Aug 2026 05:29:40 -0700 (PDT) From: Chengfeng Ye To: Jon Maloy , "David S . Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni Cc: Simon Horman , Tuong Lien , Ying Xue , netdev@vger.kernel.org, tipc-discussion@lists.sourceforge.net, linux-kernel@vger.kernel.org, stable@vger.kernel.org, Chengfeng Ye Subject: [PATCH net v2] tipc: protect node reset trace dump with node lock Date: Mon, 24 Aug 2026 20:29:29 +0800 Message-ID: <20260824122929.210431-1-nicoyip.dev@gmail.com> X-Mailer: git-send-email 2.43.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit The tipc_node_reset_links trace event asks tipc_node_dump() to walk the node's link entries. Unlike the other node events that request link data, this event runs without the node lock. This permits bearer teardown to free a link while the trace callback is dumping it: CPU 0 CPU 1 trace_tipc_node_reset_links() tipc_node_dump() l = n->links[0].link tipc_node_write_lock() kfree(l) n->links[0].link = NULL tipc_node_write_unlock() tipc_link_dump(l) tipc_link_dump() then dereferences the stale pointer. KASAN reported: BUG: KASAN: slab-use-after-free in tipc_link_dump (net/tipc/link.c:2910) Read of size 4 by task poc/115 Call Trace: tipc_link_dump+0x10cb/0x16b0 tipc_node_dump+0x4bb/0x740 trace_event_raw_event_tipc_node_class+0x258/0x360 tipc_node_reset_links+0x14d/0x1a0 tipc_rcv+0x13f5/0x3030 tipc_udp_recv+0x4e3/0x670 Allocated by task 0: tipc_link_create+0x1e1/0x1020 tipc_node_check_dest+0x7d2/0x11a0 tipc_disc_rcv+0xdbf/0x1430 Freed by task 89: kfree+0x131/0x3c0 tipc_node_link_down+0x267/0x4b0 tipc_node_delete_links+0xec/0x160 bearer_disable+0x107/0x260 Take the node write lock around the trace event. This serializes the dump against tipc_node_link_down(delete=true), which frees the link under the same write lock. Do not take the lock inside tipc_node_dump() itself: several dump callers, including tipc_node_link_down(), already hold the write lock. Fixes: eb18a510b5cd ("tipc: add trace_events for tipc node") Cc: stable@vger.kernel.org Signed-off-by: Chengfeng Ye --- v1 -> v2: - Use tipc_node_write_lock() instead of tipc_node_read_lock() so the dump is exclusive with link deletion. net/tipc/node.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/net/tipc/node.c b/net/tipc/node.c index 683a136e53ef..127848e8a644 100644 --- a/net/tipc/node.c +++ b/net/tipc/node.c @@ -1333,7 +1333,9 @@ static void tipc_node_reset_links(struct tipc_node *n) pr_warn("Resetting all links to %x\n", n->addr); + tipc_node_write_lock(n); trace_tipc_node_reset_links(n, true, " "); + tipc_node_write_unlock(n); for (i = 0; i < MAX_BEARERS; i++) { tipc_node_link_down(n, i, false); } -- 2.43.0