Comment 0 for bug 1674776

Revision history for this message
helodron (helodron) wrote :

getaddrinfo() dont work correct with ipv4+ipv6 addreses aftrer upgrade libc6 in Ubuntu Precise.

server has only ipv6 address.
Ubuntu 12.04.5 LTS \n \l
libc6 = 2.15-0ubuntu10.16

host ya.ru
YA.ru has address 93.158.134.3
YA.ru has address 213.180.193.3
YA.ru has address 213.180.204.3
YA.ru has IPv6 address 2a02:6b8::3

strace -e connect nc -zv ya.ru http
connect(3, {sa_family=AF_INET, sin_port=htons(53), sin_addr=inet_addr("127.0.0.1")}, 16) = 0
connect(3, {sa_family=AF_INET, sin_port=htons(53), sin_addr=inet_addr("127.0.0.1")}, 16) = 0
connect(3, {sa_family=AF_INET, sin_port=htons(80), sin_addr=inet_addr("213.180.193.3")}, 16) = -1 ENETUNREACH (Network is unreachable)
connect(3, {sa_family=AF_UNSPEC, sa_data="\0\0\0\0\0\0\0\0\0\0\0\0\0\0"}, 16) = 0
connect(3, {sa_family=AF_INET, sin_port=htons(80), sin_addr=inet_addr("213.180.204.3")}, 16) = -1 ENETUNREACH (Network is unreachable)
connect(3, {sa_family=AF_UNSPEC, sa_data="\0\0\0\0\0\0\0\0\0\0\0\0\0\0"}, 16) = 0
connect(3, {sa_family=AF_INET, sin_port=htons(80), sin_addr=inet_addr("93.158.134.3")}, 16) = -1 ENETUNREACH (Network is unreachable)
connect(3, {sa_family=AF_INET, sin_port=htons(80), sin_addr=inet_addr("213.180.193.3")}, 16) = -1 ENETUNREACH (Network is unreachable)
nc: connect to ya.ru port 80 (tcp) failed: Network is unreachable
connect(3, {sa_family=AF_INET, sin_port=htons(80), sin_addr=inet_addr("213.180.204.3")}, 16) = -1 ENETUNREACH (Network is unreachable)
nc: connect to ya.ru port 80 (tcp) failed: Network is unreachable
connect(3, {sa_family=AF_INET, sin_port=htons(80), sin_addr=inet_addr("93.158.134.3")}, 16) = -1 ENETUNREACH (Network is unreachable)
nc: connect to ya.ru port 80 (tcp) failed: Network is unreachable

python -c 'import socket; print socket.getaddrinfo("ya.ru.", 0, socket.AF_UNSPEC, 0)[0][4]'; python -c 'import socket; print socket.getaddrinfo("ya.ru.", 0, socket.AF_INET6, 0)[0][4]'
('93.158.134.3', 0)
('2a02:6b8::3', 0, 0, 0)

before update libc6=2.15-0ubuntu10.15

strace -e connect nc -zv ya.ru http
connect(3, {sa_family=AF_INET, sin_port=htons(53), sin_addr=inet_addr("127.0.0.1")}, 16) = 0
connect(3, {sa_family=AF_INET, sin_port=htons(53), sin_addr=inet_addr("127.0.0.1")}, 16) = 0
connect(3, {sa_family=AF_INET6, sin6_port=htons(80), inet_pton(AF_INET6, "2a02:6b8::3", &sin6_addr), sin6_flowinfo=0, sin6_scope_id=0}, 28) = 0
connect(3, {sa_family=AF_UNSPEC, sa_data="\0\0\0\0\0\0\0\0\0\0\0\0\0\0"}, 16) = 0
connect(3, {sa_family=AF_INET, sin_port=htons(80), sin_addr=inet_addr("93.158.134.3")}, 16) = -1 ENETUNREACH (Network is unreachable)
connect(3, {sa_family=AF_UNSPEC, sa_data="\0\0\0\0\0\0\0\0\0\0\0\0\0\0"}, 16) = 0
connect(3, {sa_family=AF_INET, sin_port=htons(80), sin_addr=inet_addr("213.180.193.3")}, 16) = -1 ENETUNREACH (Network is unreachable)
connect(3, {sa_family=AF_UNSPEC, sa_data="\0\0\0\0\0\0\0\0\0\0\0\0\0\0"}, 16) = 0
connect(3, {sa_family=AF_INET, sin_port=htons(80), sin_addr=inet_addr("213.180.204.3")}, 16) = -1 ENETUNREACH (Network is unreachable)
connect(3, {sa_family=AF_INET6, sin6_port=htons(80), inet_pton(AF_INET6, "2a02:6b8::3", &sin6_addr), sin6_flowinfo=0, sin6_scope_id=0}, 28) = -1 EINPROGRESS (Operation now in progress)
Connection to ya.ru 80 port [tcp/http] succeeded!

python -c 'import socket; print socket.getaddrinfo("ya.ru.", 0, socket.AF_UNSPEC, 0)[0][4]'; python -c 'import socket; print socket.getaddrinfo("ya.ru.", 0, socket.AF_INET6, 0)[0][4]'
('2a02:6b8::3', 0, 0, 0)
('2a02:6b8::3', 0, 0, 0)

I think problem with patch: CVE-2016-3706: getaddrinfo: stack overflow in hostent conversion [BZ #20010]
https://sourceware.org/git/gitweb.cgi?p=glibc.git;a=blobdiff;f=sysdeps/posix/getaddrinfo.c;h=df6ce8b13e3897f3ed47877b029da39abafe9f25;hp=d2283bcd4ad4fe7e41cf9c6ee74ec8c63ab32e34;hb=762aafec34478bcef01a16acf1959732ab8bb2b6;hpb=e97fb84811238c627f93e5e703a11eb841601947;ds=sidebyside