ipv6: fix potential "struct net" leak in inet6_rtm_getaddr()
Subsystems (3)
PATCH 1/1 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.
--- net/ipv6/addrconf.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
net/ipv6/addrconf.c +4 -3
@@ -5509,9 +5509,10 @@ static int inet6_rtm_getaddr(struct sk_buff *in_skb, struct nlmsghdr *nlh, } addr =extract_addr (tb[IFA_ADDRESS ], tb[IFA_LOCAL ], &peer); -if (!addr) -return -EINVAL ; - +if (!addr) { + err = -EINVAL ; + goto errout; + } ifm =nlmsg_data (nlh);if (ifm->ifa_index) dev =dev_get_by_index (tgt_net, ifm->ifa_index);
Signature · 1 line
2.44.0.rc1.240.g4c46232300-goog
Quoted 4 lines · Eric Dumazet
It seems that if userspace provides a correct
IFA_TARGET_NETNSIDvalue but noIFA_ADDRESSandIFA_LOCALattributes,inet6_rtm_getaddr()returns-EINVALwith an elevated "struct net" refcount.
Quoted 8 lines
Fixes 6ecf4c37eb3e ("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]>--- net/ipv6/addrconf.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
This patch was applied to netdev/net.git (main) by David S. Miller <[email protected]>:
Hello:
This patch was applied to netdev/net.git (main)
by David S. Miller <[email protected]>:
Quoted 10 lines · On Thu, 22 Feb 2024 12:17:47 +0000 you wrote:
It seems that if userspace provides a correct
IFA_TARGET_NETNSIDvalue but noIFA_ADDRESSandIFA_LOCALattributes,inet6_rtm_getaddr()returns-EINVALwith an elevated "struct net" refcount.Fixes 6ecf4c37eb3e ("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]>[...]
Here is the summary with links:
- [net] ipv6: fix potential "struct net" leak in inet6_rtm_getaddr()
https://git.kernel.org/netdev/net/c/10bfd453da64
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html