Bug 1210739

Summary: JNDI: DNS Naming service does not handle platform IPv6 addresses correctly
Product: [Fedora] Fedora Reporter: Severin Gehwolf <sgehwolf>
Component: java-1.8.0-openjdkAssignee: Severin Gehwolf <sgehwolf>
Status: CLOSED ERRATA QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 21CC: ahughes, alonbl, dbhole, jerboaa, jvanek, lzachar, omajid, sbaiduzh
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: java-1.8.0-openjdk-1.8.0.45-36.b13.fc22 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2015-05-03 17:23:19 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On:    
Bug Blocks: 1203666    
Attachments:
Description Flags
Simple Java reproducer.
none
Proposed fix for upstream JDK 9
none
spec file patch for f21's java-1.8.0-openjdk none

Description Severin Gehwolf 2015-04-10 13:07:41 UTC
Created attachment 1013140 [details]
Simple Java reproducer.

Description of problem:
OpenJDK uses DNS lookup for various internal purposes. For example if a KDC is looked up via DNS. This service does not work if /etc/resolv.conf contains IPv6 addresses as per rfc2373.

Version-Release number of selected component (if applicable):
java-1.8.0-openjdk-1.8.0.40-21.b25.fc21.x86_64

How reproducible:
Always.

Steps to Reproduce:
1. Add an IPv6 address as "nameserver" in /etc/resolv.conf
2. javac DNSClientTest.java
3. java DNSClientTest

Actual results:
FAIL: Tried to parse non-[]-encapsulated IPv6 address.
java.lang.NumberFormatException: For input string: "52:0:2258:42f2:e9ff:fef0:8d33"
	at java.lang.NumberFormatException.forInputString(NumberFormatException.java:65)
	at java.lang.Integer.parseInt(Integer.java:580)
	at java.lang.Integer.parseInt(Integer.java:615)
	at com.sun.jndi.dns.DnsClient.<init>(DnsClient.java:127)
	at DNSClientTest.main(DNSClientTest.java:38)

Expected results:
PASS: Found IPv6 address and DnsClient parsed it correctly.

Additional info:
The problem is that class com.sun.jndi.dns.DnsClient expects the string list of servers to be [] encapsulated for literal IPv6 addresses. However, when the list of nameservers is retrieved from the platform via sun.net.dns.ResolverConfigurationImpl.loadConfig() the list of nameservers isn't correctly encapsulated, in '[' and ']' respectively. This breaks the contract for DnsClient since the nameservers list is passed on verbatim to DnsClient's constructor.

Also note that tools (such as network manager) that generate /etc/resolv.conf aren't expected to wrap IPv6 addresses for "nameserver" entries.

Comment 2 Severin Gehwolf 2015-04-10 16:06:50 UTC
Created attachment 1013194 [details]
Proposed fix for upstream JDK 9

Comment 3 Deepak Bhole 2015-04-13 19:01:50 UTC
Assigning to Severin as he already has a patch ready :)

Comment 6 Alon Bar-Lev 2015-04-16 09:25:27 UTC
Hi,

If attachment#1013194 [details] is to be sent to upstream, it should be applied to linux only, as in *bsd the [] is legal[1], or at least do not add double [].

Alon

[1] http://www.openbsd.org/cgi-bin/man.cgi/OpenBSD-current/man5/resolv.conf.5?query=resolv.conf&sec=5

Comment 7 Severin Gehwolf 2015-04-16 13:12:05 UTC
(In reply to Alon Bar-Lev from comment #6)
> Hi,
> 
> If attachment#1013194 [details] is to be sent to upstream, it should be
> applied to linux only, as in *bsd the [] is legal[1], or at least do not add
> double [].

Understood, thanks! AFAIKS, there is only a distinction between Windows and Solaris+Linux in the JDK as far as platform resolvers are concerned. The attachment in comment 2 was only the first shot. Once I have more cycles I'll improve it and then propose it upstream. So yes at the very least we'll have to make sure no double [] get introduced.

Comment 9 Severin Gehwolf 2015-04-20 12:04:55 UTC
Upstream review thread:
http://mail.openjdk.java.net/pipermail/core-libs-dev/2015-April/032912.html

Comment 10 Severin Gehwolf 2015-04-22 19:00:07 UTC
Relevant JDK 9 upstream commits:
http://hg.openjdk.java.net/jdk9/dev/jdk/rev/4be070b8aaba
http://hg.openjdk.java.net/jdk9/dev/jdk/rev/8000249dcb2a

I'll ask for an 8 backport, next.

Comment 12 Severin Gehwolf 2015-04-23 15:45:23 UTC
8 backport request:
http://mail.openjdk.java.net/pipermail/jdk8u-dev/2015-April/003458.html

Comment 13 Andrew John Hughes 2015-04-23 18:15:50 UTC
Is this applicable to 6 & 7 too?

Comment 14 Severin Gehwolf 2015-04-24 07:36:26 UTC
(In reply to Andrew John Hughes from comment #13)
> Is this applicable to 6 & 7 too?

Yes, latest icedtea 7 and openjdk 6 forests have the same bug.

Comment 15 Severin Gehwolf 2015-04-29 15:20:07 UTC
This fix was pushed to 8:
http://hg.openjdk.java.net/jdk8u/jdk8u-dev/jdk/rev/b02550d62bdb

Comment 16 Severin Gehwolf 2015-04-29 18:15:38 UTC
Builds with the upstream 8 fix:

rawhide: http://koji.fedoraproject.org/koji/taskinfo?taskID=9599391
f22:     http://koji.fedoraproject.org/koji/taskinfo?taskID=9599395

Comment 17 Severin Gehwolf 2015-04-29 18:40:36 UTC
Created attachment 1020289 [details]
spec file patch for f21's java-1.8.0-openjdk

Comment 18 Fedora Update System 2015-04-30 08:21:20 UTC
java-1.8.0-openjdk-1.8.0.45-36.b13.fc22 has been submitted as an update for Fedora 22.
https://admin.fedoraproject.org/updates/java-1.8.0-openjdk-1.8.0.45-36.b13.fc22

Comment 19 Fedora Update System 2015-05-01 16:39:47 UTC
Package java-1.8.0-openjdk-1.8.0.45-36.b13.fc22:
* should fix your issue,
* was pushed to the Fedora 22 testing repository,
* should be available at your local mirror within two days.
Update it with:
# su -c 'yum update --enablerepo=updates-testing java-1.8.0-openjdk-1.8.0.45-36.b13.fc22'
as soon as you are able to.
Please go to the following url:
https://admin.fedoraproject.org/updates/FEDORA-2015-7301/java-1.8.0-openjdk-1.8.0.45-36.b13.fc22
then log in and leave karma (feedback).

Comment 20 Fedora Update System 2015-05-03 17:23:19 UTC
java-1.8.0-openjdk-1.8.0.45-36.b13.fc22 has been pushed to the Fedora 22 stable repository.  If problems still persist, please make note of it in this bug report.

Comment 21 Stanislav Baiduzhyi 2015-06-23 14:41:54 UTC
*** Bug 1203666 has been marked as a duplicate of this bug. ***