-
Bug
-
Resolution: Done-Errata
-
Major
-
rhel-9.2.0
-
glibc-2.34-98.el9
-
None
-
None
-
ZStream
-
rhel-sst-pt-libraries
-
ssg_platform_tools
-
20
-
23
-
1
-
QE ack, Dev ack
-
False
-
-
Yes
-
None
-
Approved Blocker
-
Bug Fix
-
-
Done
-
x86_64
-
None
What were you trying to do that didn't work?
After a system upgrade that changed the glibc version from glibc-2.34-40.el9_1.1.src.rpm to glibc-2.34-60.el9_2.7.src.rpm we started noticing the JVM intermediately resolving host names to the 0.0.0.0 mask:
import java.net.InetSocketAddress System.setProperty("java.net.preferIPv4Stack" , "true"); System.out.println("Prefer IPv4 = " + System.getProperty("java.net.preferIPv4Stack")); System.out.println("Prefer IPv6 = " + System.getProperty("java.net.preferIPv6Addresses")); System.out.println(); for (int i = 0;; i++) { var addr = new InetSocketAddress("google.com", 443); System.out.println(i + " " + addr); Thread.sleep(5000); }
Prefer IPv4 = true Prefer IPv6 = null 0 google.com/216.58.222.14:443 1 google.com/216.58.222.14:443 2 google.com/216.58.222.14:443 ... 24 google.com/216.58.222.14:443 25 google.com/0.0.0.0:443 26 google.com/0.0.0.0:443 27 google.com/0.0.0.0:443 ... 81 google.com/0.0.0.0:443 82 google.com/216.58.222.14:443 83 google.com/216.58.222.14:443
After reading through the OpenJDK's code base we were able to narrow it down to the glibc's getaddrinfo call: if passing an IPv4 hint and the first IP address in the hosts cache file is an IPv6 address, we get an empty addrinfo struct back with no error code.
Please provide the package NVR for which bug is seen:
The bug was reproduced in:
- glibc-2.34-60.el9_2.7.src.rpm
- glibc-2.34-83.el9_3.7.src.rpm
How reproducible:
Steps to reproduce
- Starting with RHEL 9.2 and install nscd and gcc;
- Compile this code with gcc -o repro repro.c and run it with ./repro google.com);
- On another shell, look at the nscd hosts file with nscd -p /var/db/nscd/hosts and invalidate (sudo nscd -i hosts) nscd's hosts cache until the first IP address in the cache file for the target host name is an IPv6 address, followed by an IPv4 address.
Expected results
The correct IPv4 address is always returned.
Actual results
IPv4 is returned until the hosts file order changes:
[root@5f8af5257739 wrk]# ./repro "google.com" ... 17 family=IPv4 size=16 addr=216.58.222.14 family=IPv4 size=16 addr=216.58.222.14 family=IPv4 size=16 addr=216.58.222.14 18 family=IPv4 size=16 addr=216.58.222.14 family=IPv4 size=16 addr=216.58.222.14 family=IPv4 size=16 addr=216.58.222.14 19 family=IPv4 size=16 addr=216.58.222.14 family=IPv4 size=16 addr=216.58.222.14 family=IPv4 size=16 addr=216.58.222.14 20 family=IPv4 size=16 addr=216.58.222.14 family=IPv4 size=16 addr=216.58.222.14 family=IPv4 size=16 addr=216.58.222.14 21 family=IPv4 size=16 addr=216.58.222.14 family=IPv4 size=16 addr=216.58.222.14 family=IPv4 size=16 addr=216.58.222.14 22 family=IPv4 size=16 addr=216.58.222.14 family=IPv4 size=16 addr=216.58.222.14 family=IPv4 size=16 addr=216.58.222.14 23 family=IPv4 size=16 addr=216.58.222.14 family=IPv4 size=16 addr=216.58.222.14 family=IPv4 size=16 addr=216.58.222.14 ... 24 family=0 family=0 family=0 25 family=0 family=0 family=0 26 family=0 family=0 family=0 27 family=0 family=0 family=0 28 family=0 family=0 family=0 ...
- links to
-
RHBA-2023:122804 glibc bug fix and enhancement update
- mentioned on