Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

tipc: fix possible crash in __tipc_nl_net_set()

syzbot reported a crash in __tipc_nl_net_set() caused by NULL dereference.

We need to check that both TIPC_NLA_NET_NODEID and TIPC_NLA_NET_NODEID_W1
are present.

We also need to make sure userland provided u64 attributes.

Fixes: d50ccc2d3909 ("tipc: add 128-bit node identifier")
Signed-off-by: Eric Dumazet <edumazet@google.com>
Cc: Jon Maloy <jon.maloy@ericsson.com>
Cc: Ying Xue <ying.xue@windriver.com>
Reported-by: syzbot <syzkaller@googlegroups.com>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

Eric Dumazet and committed by
David S. Miller
c6404122 ec518f21

+4
+2
net/tipc/net.c
··· 252 252 u64 *w0 = (u64 *)&node_id[0]; 253 253 u64 *w1 = (u64 *)&node_id[8]; 254 254 255 + if (!attrs[TIPC_NLA_NET_NODEID_W1]) 256 + return -EINVAL; 255 257 *w0 = nla_get_u64(attrs[TIPC_NLA_NET_NODEID]); 256 258 *w1 = nla_get_u64(attrs[TIPC_NLA_NET_NODEID_W1]); 257 259 tipc_net_init(net, node_id, 0);
+2
net/tipc/netlink.c
··· 81 81 [TIPC_NLA_NET_UNSPEC] = { .type = NLA_UNSPEC }, 82 82 [TIPC_NLA_NET_ID] = { .type = NLA_U32 }, 83 83 [TIPC_NLA_NET_ADDR] = { .type = NLA_U32 }, 84 + [TIPC_NLA_NET_NODEID] = { .type = NLA_U64 }, 85 + [TIPC_NLA_NET_NODEID_W1] = { .type = NLA_U64 }, 84 86 }; 85 87 86 88 const struct nla_policy tipc_nl_link_policy[TIPC_NLA_LINK_MAX + 1] = {