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=HdU/VgkTu6pLEEtWpn37PN9jeXkfZu7D7+g5uYJJEgDouGWiiTjKuO6LPwGzOB/+CM3T NvYfMicviMW4PbJxnTGXfN9T5iOat8x5MyFcX3yf2KpCDcnKXlIKScsp8TOX3w6omvUf9 VRrIcqqw5Ypwm3F83Xkk43JahEk6xZhMz8EuD0TxO3WrqP+qXKV699Ddp5uMMy6BnIKSc 0gSPr7XC9fbPaNqpZVYSoLWg1z9x1TK5Ne/QOFm4zKTZ0Lw3ZyIDR0ud+H1iF3KGF1uxY R6S5nxGNiUe9jWFWWx9UrEywLsdgT63MAY1jQ5BPTab3/mIshe/N5xjOfMV2BVh3wCQ== 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=fNgjW1dVuE87r92zq6uBSpWHOJmKQmtGDQjOrbaUf+kDFLY4D9ml/tZYVGbZNgqlXx6q 8kz4irmC/BF/jfKX8JcD4yxW24kdpn4qUitDwNitkIQy6Eui1KtJv14ymZE6tYa/mz5VE r92pY6MfCDGF7/cao8B7Jnv2ri5C6/ry186+czsTTKYsaMvQKAQVeEP/D8iQT5IRZcG7B c6yv//ssNFLUybqQX3T7YHX3qo30ZjFjBWstDH9yS6JVN12nBL+oNdGJ+fP0kYCeuesm0 XLNqyJ6dVSnxNA3k7yN+QGYGkzqHCeZQWzfkYQvbLP7fm0b1RwVst2cHzte0Eql8GxQ== 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 0205A606A32C for ; Thu, 3 Dec 2026 16:59:35 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 0205A606A32C 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-1b588e4bd7fso10615133c88.0 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=pOO4S8jkwPkCL3GlYQrmjd40oiBTw0Dzn+Leewsj5SMdA7evtoQt8IpKX5VIoP3r9y MIDBXsRqUKCA2PmGt46lP93EtbbDGcVfzwiQJzqMTSYLdOXevGr3I4CoY4XT83v6j+xi 5+Ysy9F8gloWtTebafsUgsL94Eix9DNGudEkgvyYxvjnRwbOvgea3w+rhqAmR1pMGVjp WRr5iwRX/tkxr+2jnFEEf9glOvFVPmjoGWpY6FoFOKH5MFT+XAAVld3eNtbhasyDMLOn lJbjwQpPqqZ6Iu91eQdD6n68aQgCKRzT/22OItdj6dhEY4vF3+87OsZ/2Wc9GvfAXX8q b15w== X-Forwarded-Encrypted: i=1; AL+hErHebzSj1iz17G6XxAjWX5Dq4tDVIDDPeVzA5xgLL7UNSYiRcZ5/hBBOabH9ABWxVMEz7JPh7pU=@vger.kernel.org X-Gm-Message-State: APuU4Z9kOtWgBlPwkE733+GzFobx2qlok22ABXW9Qev1eQ4fB/mVWjIf KIFfvc3EbEAsBR1bK5j8eluKSpAsN5nkFOHlfBaLDQk62ED7fSavUF4izigO9xs+MYXgGsdCJ7N pWzN/1xSEiA== 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: netdev@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