diff options
author | Cong Wang <xiyou.wangcong@gmail.com> | 2020-07-25 15:40:53 -0700 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2020-07-30 16:30:55 -0700 |
commit | 8c0de6e96c9794cb523a516c465991a70245da1c (patch) | |
tree | d103a45583a4e140dc2053a65ccaa3409eb066c6 /include/pcmcia | |
parent | 27a2145d6f826d1fad9de06ac541b1016ced3427 (diff) | |
download | linux-8c0de6e96c9794cb523a516c465991a70245da1c.tar.bz2 |
ipv6: fix memory leaks on IPV6_ADDRFORM path
IPV6_ADDRFORM causes resource leaks when converting an IPv6 socket
to IPv4, particularly struct ipv6_ac_socklist. Similar to
struct ipv6_mc_socklist, we should just close it on this path.
This bug can be easily reproduced with the following C program:
#include <stdio.h>
#include <string.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <arpa/inet.h>
int main()
{
int s, value;
struct sockaddr_in6 addr;
struct ipv6_mreq m6;
s = socket(AF_INET6, SOCK_DGRAM, 0);
addr.sin6_family = AF_INET6;
addr.sin6_port = htons(5000);
inet_pton(AF_INET6, "::ffff:192.168.122.194", &addr.sin6_addr);
connect(s, (struct sockaddr *)&addr, sizeof(addr));
inet_pton(AF_INET6, "fe80::AAAA", &m6.ipv6mr_multiaddr);
m6.ipv6mr_interface = 5;
setsockopt(s, SOL_IPV6, IPV6_JOIN_ANYCAST, &m6, sizeof(m6));
value = AF_INET;
setsockopt(s, SOL_IPV6, IPV6_ADDRFORM, &value, sizeof(value));
close(s);
return 0;
}
Reported-by: ch3332xr@gmail.com
Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
Signed-off-by: Cong Wang <xiyou.wangcong@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'include/pcmcia')
0 files changed, 0 insertions, 0 deletions