From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=74.125.82.71 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796317176; b=a67KBwaXk/LeHrzv6iDa6SegOAnYeWuid/GgvT7JJSdz+X0nvndIbXgi6ugzXMqgM6n1 kOH5KoT8JTZJCCFHuVctkR5pebc5XTtX/a7Z2MMIDH397OaLwC/qbdljyus3WXFI8GAQz srkw3KKTxzbbYasTklfVPOFgMs/OQqmPXgcQ64aO2fQW+ETomL0XIWj/XKsKXjoMmVLF4 cP5w002mZ64Cuz70JPehFar8LNurl4qTQb3bGPDU4eR16FUP2Hir3b7n5TAnrRLPhI8AL qgitFZ5BDJEgBST6GD8iWpwpsbwyUwvGp3ZyTWZakSc+E9oQOce+QVZvfHcskHcG4fQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796317176; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Forwarded-Encrypted:X-Gm-Message-State:X-Received:Date:Mime-Version: X-Mailer:Message-ID:Subject:From:To:Cc:Content-Type; bh=lFx++ui8TqwA+J9uJARKS1H78lHSD2u0EiLmb39DSbo=; b=G+WqmLMYmrhpokHUh4ZJDPeiThfuYF+YVMaWgV1oZb87uAoC6479fJn4pz6RPv5Z5Rsr ZJzbLF79i4b4T592isa7UMb+jOX4zgxlofN9MA89zurII9QwiP9hf4PV7NLgwaFBejfLJ u/RwuoUeKK0/ekZY71EitlEMfKC0PH7w+ER2jPpXkGGXFfYXl25p1nueOd9Z9kdATorm8 TRadUni/shybncc91DbaFy/TK7P3jlk2ZwGfSZab/pCoRF2ue1FHVo0qo65cN8sGvgFNg MLnovxsJC3frSEM0xkvvebsB0QExV0Zzk3n/vYc/YBhQ/Tmb2wvKCY/j9jZAWpdGVFA== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=google.com; spf=pass smtp.mailfrom=flex--irogers.bounces.google.com; dkim=pass header.d=google.com header.i=@google.com header.a=rsa-sha256 header.s=20260707 header.b=J08fJ5rX; arc=none smtp.remote-ip=74.125.82.71 Received: from mail-dl1-f71.google.com (mail-dl1-f71.google.com [74.125.82.71]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 01F89606A322 for ; Thu, 3 Dec 2026 16:59:35 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 01F89606A322 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--irogers.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.a=rsa-sha256 header.s=20260707 header.b=J08fJ5rX Received: by mail-dl1-f71.google.com with SMTP id a92af1059eb24-1b597143a81so5172323c88.1 for ; Thu, 03 Dec 2026 08:59:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20260707; t=1796317175; x=1796921975; darn=vger.kernel.org; h=content-type:cc:to:from:subject:message-id:mime-version:date:from :to:cc:subject:date:message-id:reply-to:content-type; bh=lFx++ui8TqwA+J9uJARKS1H78lHSD2u0EiLmb39DSbo=; b=J08fJ5rXnC/qL9XWHc01g5OtGG1D3jKpl+yJMGmCeQSTtmMFtD54jzPSiljJsVfYsd Nw+JrTrXBpr+EWfMeyros3cwnBIHpD7NFNn7FucBlUhOSr64PXqwxN8TSQW4JrtHdZ6T +9xmEwLzHqhTtXtEcagun3Oz/zf+ZD6bX1vK6JAKEhjk32GWQzIxa1URIhmpOT4Pil/p 8RnOS3vPgkmLuDrLeybbOzuVpWQrh/Le7ulQc510SnOkJEriQvUM2W2fgtdEGaEdrs/x 5V/4sOSu2UbPg+N0dhPsWK5TSmRaC5Fh070TnUg9GWuORtbhGNp1X+S5iFG7UjqvUdLW iZkQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796317175; x=1796921975; h=content-type:cc:to:from:subject:message-id:mime-version:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=lFx++ui8TqwA+J9uJARKS1H78lHSD2u0EiLmb39DSbo=; b=wuL8AWi3GmVmzQKEAEKKwAJaZzYPxOnTp2lOOmTibXQBO/n9iv43hFcqoBMmFIDL2H XOFP8kIAjI2QrcBSUyW/J2Bansu+nIddttAuewh8vS6QmxvmT3Un+KnFdqJ+cR/p4q2m 378hKy2VYFWmov4gR5uczKWa8GyyVIVIlatYApXqqSn6GNZA9Gk+frf1OuQeyEEc+VZu ud4wH5es5Fdy2sSJiZWteMST1QGrnzU4NkM78vz/UDKgWXL/NqpkbE9kEG2Kv4ByGow/ bbt0MHQDZlLJrBQoHYa0oaWqw9vDWsfEJsGNCUrYlUWN8E93JiDzTlLeUr36XrF5LMDz uxZA== X-Forwarded-Encrypted: i=1; AL+hErEXBqdD1LYHSI/z6fZ4PrX9Dj1lB8NAOFmF45WLJFjdhzwEidicbEZbc6t1NdfmO8JRGedLvHx7S1i2xT4=@vger.kernel.org X-Gm-Message-State: APuU4Z9BG1eXJ/HDIdZrHl3UDwBoaa1s/00bzER8apk8g6tneV7c0uGv vXXYDWfCqmpqiwNu3A38heI0RLGGRenfm/Ih8ybv6Q3ui4J1CqROYWqZHlvwWq0SO9Uu9ftCKS2 H/rOpYh+X/w== X-Received: from dlbrc1-n1.prod.google.com ([2002:a05:7022:ea81:10b0:1b2:649c:7a14]) (user=irogers job=prod-delivery.src-stubby-dispatcher) by 2002:a05:7022:b155:20b0:1b5:d170:5f01 with SMTP id a92af1059eb24-1b5d17087a5mr1432547c88.35.1796317174780; Thu, 03 Dec 2026 08:59:34 -0800 (PST) Date: Thu, 3 Dec 2026 08:59:30 -0800 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 X-Mailer: git-send-email 2.56.1.911.g883d8bcb20-goog Message-ID: <20261203165930.404266-1-irogers@google.com> Subject: [PATCH net v2] tipc: validate peer address attributes in tipc_nl_peer_rm() From: Ian Rogers To: Jon Maloy , Tung Quang Nguyen , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni Cc: Simon Horman , netdev@vger.kernel.org, tipc-discussion@lists.sourceforge.net, linux-kernel@vger.kernel.org, llvm@lists.linux.dev, Elkin Cruz , Ian Rogers Content-Type: text/plain; charset="UTF-8" tipc_nl_peer_rm() documents TIPC_NLA_NET_ADDR and TIPC_NLA_NET_NODEID as mutually exclusive ways to identify the peer to remove, but checks them in two independent if-blocks with no fallback. If a TIPC_NL_PEER_REMOVE netlink request contains an empty nested TIPC_NLA_NET attribute (or only unrelated TIPC_NLA_NET_* attributes), 'addr' stays uninitialized on the stack and is passed to in_own_node() and tipc_node_find(). If both attributes are present, TIPC_NLA_NET_NODEID silently overwrites the address parsed from TIPC_NLA_NET_ADDR. Return -EINVAL when both attributes are supplied or when neither is present. Found with Clang's -Wconditional-uninitialized on an x86_64 allyesconfig build; Gemini helped review the code path, draft the patch and commit message, and write the QEMU netlink test script. Without this patch on an unmodified kernel booted in QEMU (built with CONFIG_INIT_STACK_NONE=y, no kernel modifications or error injection), sending a TIPCv2 generic netlink TIPC_NL_PEER_REMOVE message with an empty nested TIPC_NLA_NET, with only TIPC_NLA_NET_ID, or with both TIPC_NLA_NET_ADDR and TIPC_NLA_NET_NODEID all fell through to tipc_node_find() and returned -ENXIO instead of -EINVAL. Build-tested with LLVM=1 W=1 (-Werror) and -Wconditional-uninitialized. Runtime-tested in QEMU with CONFIG_INIT_STACK_NONE=y, CONFIG_KCSAN_STRICT=y, and CONFIG_PROVE_LOCKING=y: all three malformed requests (plus zero TIPC_NLA_NET_ADDR and TIPC_NLA_NET_NODEID without TIPC_NLA_NET_NODEID_W1) return -EINVAL, unknown valid addresses/node IDs return -ENXIO, and live peer discovery plus offline peer removal ('tipc peer remove address 1.1.2') over a veth pair between two network namespaces succeeds with no KCSAN or lockdep reports. No TIPC selftest exists under tools/testing/selftests/net/. Fixes: 43fcd906d9c1 ("tipc: support 128bit node identity for peer removing") Reviewed-by: Tung Nguyen Signed-off-by: Ian Rogers --- Notes: v2: - Reproduced the unpatched behavior and runtime-tested the fix in QEMU over TIPCv2 generic netlink and live veth/netns peer removal (Paolo Abeni). - Carried Reviewed-by from Tung Nguyen (code unchanged from v1). v1: https://lore.kernel.org/r/20261119170556.1518068-1-irogers@google.com net/tipc/node.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/net/tipc/node.c b/net/tipc/node.c index 53b0993c2c23..d19ed94b8f41 100644 --- a/net/tipc/node.c +++ b/net/tipc/node.c @@ -2277,18 +2277,21 @@ int tipc_nl_peer_rm(struct sk_buff *skb, struct genl_info *info) /* attrs[TIPC_NLA_NET_NODEID] and attrs[TIPC_NLA_NET_ADDR] are * mutually exclusive cases */ + if (attrs[TIPC_NLA_NET_ADDR] && attrs[TIPC_NLA_NET_NODEID]) + return -EINVAL; + if (attrs[TIPC_NLA_NET_ADDR]) { addr = nla_get_u32(attrs[TIPC_NLA_NET_ADDR]); if (!addr) return -EINVAL; - } - - if (attrs[TIPC_NLA_NET_NODEID]) { + } else if (attrs[TIPC_NLA_NET_NODEID]) { if (!attrs[TIPC_NLA_NET_NODEID_W1]) return -EINVAL; *w0 = nla_get_u64(attrs[TIPC_NLA_NET_NODEID]); *w1 = nla_get_u64(attrs[TIPC_NLA_NET_NODEID_W1]); addr = hash128to32(node_id); + } else { + return -EINVAL; } if (in_own_node(net, addr)) -- 2.56.1.911.g883d8bcb20-goog