Skip to content

Commit 10bfd45

Browse files
edumazetdavem330
authored andcommitted
ipv6: fix potential "struct net" leak in inet6_rtm_getaddr()
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 <[email protected]> Cc: Christian Brauner <[email protected]> Cc: David Ahern <[email protected]> Reviewed-by: David Ahern <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 1a825e4 commit 10bfd45

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

net/ipv6/addrconf.c

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

55115511
addr = extract_addr(tb[IFA_ADDRESS], tb[IFA_LOCAL], &peer);
5512-
if (!addr)
5513-
return -EINVAL;
5514-
5512+
if (!addr) {
5513+
err = -EINVAL;
5514+
goto errout;
5515+
}
55155516
ifm = nlmsg_data(nlh);
55165517
if (ifm->ifa_index)
55175518
dev = dev_get_by_index(tgt_net, ifm->ifa_index);

0 commit comments

Comments
 (0)