From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pf1-f174.google.com (mail-pf1-f174.google.com [209.85.210.174]) (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 5D026377034 for ; Sat, 18 Jul 2026 09:26:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.174 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784366764; cv=none; b=V7lIYb0mVhdDEaHWsufx2vdJ51cXd/aa0D3Zqkf/ZFrhM0ACLKm60jGhnGiF/b7Oe3lag5gPV5pr/MZ9bByi/WQnVbGYVLjMU9jMYyJO07OMseF0Bcp43SINWeOlcta5iHO0MCN8QZqG5WG+CknhlFRRiP8aN6BP9M5Ru2WYQUE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784366764; c=relaxed/simple; bh=V5tbfNHmo+5s0PdsqFK8WHZyVJb6Yux3ai4P97h9D+w=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=e5k6dWqbySp+V5QW5rk/eo75fNnonmFetuSVCBq5bTRiKCnzxQVASumxxOMcPyvydqXknZmxpQ+65G66+uR8jUy7B6J/Sk0lzRRAr5GglD5q9IgenSZFmi0B+S05fzFdxanuunFHpT5BdkKA9i9QBU1l7LS8p7t8ZnqjxRlihYc= 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=otT73yfc; arc=none smtp.client-ip=209.85.210.174 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="otT73yfc" Received: by mail-pf1-f174.google.com with SMTP id d2e1a72fcca58-84a652535dcso2638566b3a.3 for ; Sat, 18 Jul 2026 02:26:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1784366763; x=1784971563; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=J3QOcSKLKobkAtw0/HZfjC/OUXzunAPfppvcy+NSZqI=; b=otT73yfcEGIjirJ6jK2mHh2yOO6INKvITvdXuv1iVICkq9Lcge8Hi0RwH193qJZG7d dI4DWTl6PqrqikZwGSLdSqAaXmnc3vlV56m43ANBk++BRlUPm1pWQkGFlHCX8h/Lfrga wqZQXx2QCwsVfG+EJe8twU6FBHBecbit0xsLvexpnLyHR/bvAX7F9HTW7+a2UgrrNfgM 7q+H6n6n2JO2vMBgDxZDFKIzNnzXOgYgVaC0206s/8QeVpW9INVu6mJJKCAii+mFgBE1 EjIzvadvqnUa+6QwJF2sjY7/Djr6lRnakayqYe7qeSQr4t12k9XrnPpz2qKY4I1bXfoK Sang== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1784366763; x=1784971563; h=content-transfer-encoding:mime-version:references:in-reply-to :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=J3QOcSKLKobkAtw0/HZfjC/OUXzunAPfppvcy+NSZqI=; b=bojFGmTqKnaX5FuJwIQ/CPwH5KySqAZDz6ufbpzEbnKo483lqwn6TRFehpWENic8qf muZEWJEDqXT8uzTNOn4HZPqAiO6nCkj+JHu2splkI/aOa2/mY0oehp/hthZ9NlqQJqBB ISUJI7nWj62l7rKbBA1j0arU/DHouWT57aIeZcWtN/tokrwPUIvctcMoL1LtDeFPhSfc cNGHebB1o7LOqQMnyN7ijZxhr90jl9TLtUypQ/cMR2dC8ZLarenDsOnB1SWvne2byEDV HeK4/12gQUX74kHULp7p/na87pCgOFyGiLN10a5Ux1gZCofukpYzgouRKadt8CGgEGtc fQ0g== X-Forwarded-Encrypted: i=1; AHgh+RrDXXbtPYj1xxSvOjQ/323OiAehP8mSl1/rsBqltQEUOhRe4QwFdu66yH/W2fVwYhgNpMYeKbFYVALFJWc=@vger.kernel.org X-Gm-Message-State: AOJu0YyR2R9jchC5QJvkyZ6IfvVxIYVbvILGRDCjWwTi62RyBiAcUv2W xY5xIj5I/10kkZNMyYxSEit56JfjmUWemHwVU8yMso9OY7BxF+pTY96G X-Gm-Gg: AfdE7cl+/pW53fwTuTGsE959mWxz9+pjEgJhOj8Z0P3BfDRS511uRuOQ2CRdWfI4KwS KwubQ75NB+gZJnyH4Xx9gH5yJlV96HyLdxiAdGFWQr1MpDeTD+hq0TRWB7gUAB+eedRBeVdJRJR H/L84s7j87+ZgATXdK0U16KwGm4YEERcs7LF84i8/+8FkChGnFgnx3FWtIYI0ejlVpe3goep1zy kPAZJL/3tOcfgdRtuuk2MB/rng3A8Q/1M5mFc4AZpiO0vApviLhQBO22tP53d7tqwv9tEDUEaXh m4oSb++jBjVwdIBtCt0qx6HEgX2KV879up5/nL27tkAm006BkUK1Fg+pHGo01KeGvSdsQ3d/KKl LtyJwdF5w2vxMIY3ZuUIZ5Fdm6M8uhFpowOoVAcI8R2X+o1xdngGdwDXr9CNRDaP+rN7y8uuY8f FJtMoi1p/jo1kgv8FG8oeSklIyE9amHJ/GqKF+Mg== X-Received: by 2002:a05:6a00:3d13:b0:845:dde9:ab62 with SMTP id d2e1a72fcca58-84c2927fa27mr6626506b3a.19.1784366762755; Sat, 18 Jul 2026 02:26:02 -0700 (PDT) Received: from kimi-bug-hunter.. ([47.84.186.216]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-84c30fb62fesm1950464b3a.29.2026.07.18.02.25.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 18 Jul 2026 02:26:01 -0700 (PDT) From: Weiming Shi To: Jon Maloy , Tung Nguyen , netdev@vger.kernel.org, tipc-discussion@lists.sourceforge.net Cc: Xiang Mei , Weiming Shi , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Simon Horman , kernel test robot , Hoang Huu Le , linux-kernel@vger.kernel.org Subject: [PATCH net v8 2/3] tipc: fix NULL deref in deferred bulk distribution on publish failure Date: Sat, 18 Jul 2026 17:25:42 +0800 Message-ID: <20260718092544.785289-3-bestswngs@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260718092544.785289-1-bestswngs@gmail.com> References: <20260718092544.785289-1-bestswngs@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit tipc_net_finalize() does not check the return value of tipc_nametbl_publish(). If the publish fails, for example on a GFP_ATOMIC allocation failure, the node state name never lands in cluster_scope, but tn->finalized is still set. A worker deferred by tipc_named_node_up() then wakes and calls named_distribute() with an empty list. That replays the same unguarded buf_msg(skb_peek_tail(list)) tail stamp, this time on the tipc_node_dist_bulk workqueue: KASAN: null-ptr-deref in range [0x00000000000000c8-0x00000000000000cf] RIP: 0010:named_distribute (net/tipc/name_distr.c:200) Workqueue: events tipc_node_dist_bulk Call Trace: tipc_named_dist_cluster_scope (net/tipc/name_distr.c:267) tipc_node_dist_bulk (net/tipc/node.c:403) process_one_work worker_thread Kernel panic - not syncing: Fatal exception in interrupt Check the publish result and warn on failure, but still set finalized, otherwise deferred workers would sleep forever. In tipc_named_dist_cluster_scope() re-check cluster_scope after the wait and skip the distribution when it is empty. This is a permanent condition, so return 0 instead of an error, otherwise the link would be bounced forever. Also guard the tail stamp in named_distribute() itself, so a caller that misses the precondition gets a warning and a link reset through the existing -ENOBUFS path instead of a crash. Reproducing this needs an allocation failure during finalize, so I verified it by stubbing out the publish call: both nodes log the failure, the workers skip the distribution, no crash, no link flap. The normal path is unchanged with the same two-node test. Fixes: cad2929dc432 ("tipc: update a binding service via broadcast") Reported-by: Xiang Mei Assisted-by: Claude:claude-opus-4-8 Signed-off-by: Weiming Shi --- net/tipc/name_distr.c | 11 +++++++++++ net/tipc/net.c | 3 ++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/net/tipc/name_distr.c b/net/tipc/name_distr.c index b764274df758..5b0fb09226fc 100644 --- a/net/tipc/name_distr.c +++ b/net/tipc/name_distr.c @@ -193,6 +193,10 @@ static int named_distribute(struct net *net, struct sk_buff_head *list, skb_trim(skb, INT_H_SIZE + (msg_dsz - msg_rem)); __skb_queue_tail(list, skb); } + if (skb_queue_empty(list)) { + pr_warn("Bulk publication list empty, nothing to distribute\n"); + return 1; + } hdr = buf_msg(skb_peek_tail(list)); msg_set_last_bulk(hdr); msg_set_named_seqno(hdr, seqno); @@ -253,6 +257,13 @@ int tipc_named_dist_cluster_scope(struct net *net, u32 dnode) spin_unlock_bh(&tn->nametbl_lock); read_lock_bh(&nt->cluster_scope_lock); + if (unlikely(list_empty(&nt->cluster_scope))) { + /* finalize is done but nothing was published (publish + * failed): a permanent state, nothing to synchronize. + */ + read_unlock_bh(&nt->cluster_scope_lock); + return 0; + } if (named_distribute(net, &head, dnode, &nt->cluster_scope, seqno)) { read_unlock_bh(&nt->cluster_scope_lock); return -ENOBUFS; diff --git a/net/tipc/net.c b/net/tipc/net.c index 4c144e720ac1..2aa8812c551a 100644 --- a/net/tipc/net.c +++ b/net/tipc/net.c @@ -138,7 +138,8 @@ static void tipc_net_finalize(struct net *net, u32 addr) tipc_named_reinit(net); tipc_sk_reinit(net); tipc_mon_reinit_self(net); - tipc_nametbl_publish(net, &ua, &sk, addr); + if (!tipc_nametbl_publish(net, &ua, &sk, addr)) + pr_warn("Failed to publish own node state\n"); atomic_inc(&tn->finalized); wake_up_var(&tn->finalized); } -- 2.43.0