Skip to content

Commit 44112bc

Browse files
edumazetgregkh
authored andcommitted
ipv6: fix potential "struct net" leak in inet6_rtm_getaddr()
[ Upstream commit 10bfd45 ] It seems that if userspace provides a correct IFA_TARGET_NETNSID value but no IFA_ADDRESS and IFA_LOCAL attributes, inet6_rtm_getaddr() returns -EINVAL with an elevated "struct net" refcount. Fixes: 6ecf4c3 ("ipv6: enable IFA_TARGET_NETNSID for RTM_GETADDR") Signed-off-by: Eric Dumazet <edumazet@google.com> Cc: Christian Brauner <brauner@kernel.org> Cc: David Ahern <dsahern@kernel.org> Reviewed-by: David Ahern <dsahern@kernel.org> Signed-off-by: David S. Miller <davem@davemloft.net> Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent 16edf51 commit 44112bc

1 file changed

Lines changed: 4 additions & 3 deletions

File tree

net/ipv6/addrconf.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5505,9 +5505,10 @@ static int inet6_rtm_getaddr(struct sk_buff *in_skb, struct nlmsghdr *nlh,
55055505
}
55065506

55075507
addr = extract_addr(tb[IFA_ADDRESS], tb[IFA_LOCAL], &peer);
5508-
if (!addr)
5509-
return -EINVAL;
5510-
5508+
if (!addr) {
5509+
err = -EINVAL;
5510+
goto errout;
5511+
}
55115512
ifm = nlmsg_data(nlh);
55125513
if (ifm->ifa_index)
55135514
dev = dev_get_by_index(tgt_net, ifm->ifa_index);

0 commit comments

Comments
 (0)