tipc: validate peer address attributes in tipc_nl_peer_rm()
Subsystems (3)
PATCH 1/1 tipc: validate peer address attributes in tipc_nl_peer_rm()
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 implements them as two independent if-blocks with no fallback check. If a TIPC_NL_PEER_REMOVE netlink request provides an empty nested TIPC_NLA_NET attribute (or only unrelated TIPC_NLA_NET_* attributes), 'addr' remains uninitialized on the stack and is passed into in_own_node() and tipc_node_find(). Conversely, if both attributes are supplied, the second silently overwrites the first.
Return -EINVAL when both attributes are present or when neither is present.
Found via an x86_64 LLVM=1 (Clang 21.1.8) allyesconfig audit with -Wconditional-uninitialized enabled; fix and changelog drafted with an AI coding assistant. Build-tested under LLVM=1 W=1 and -Wconditional-uninitialized; not runtime-tested over TIPC netlink.
--- net/tipc/node.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-)
net/tipc/node.c +6 -3
@@ -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))
Signature · 1 line
2.56.1.708.g77570a6a1d-goog
Quoted 11 lines
Subject: [PATCH net] tipc: validate peer address attributes in
tipc_nl_peer_rm()
tipc_nl_peer_rm()documentsTIPC_NLA_NET_ADDRandTIPC_NLA_NET_NODEIDas mutually exclusive ways to identify the peer to remove, but implements them as two independent if-blocks with no fallback check. If aTIPC_NL_PEER_REMOVEnetlink request provides an empty nestedTIPC_NLA_NETattribute (or only unrelated TIPC_NLA_NET_* attributes), 'addr' remains uninitialized on the stack and is passed intoin_own_node()andtipc_node_find(). Conversely, if both attributes are supplied, the second silently overwrites the first.
Quoted 1 line
Return
-EINVALwhen both attributes are present or when neither is present.