Crash in java.net.NetworkInterface.getNetworkInterfaces() when ifr_ifindex exceeds 255
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
openjdk-6 (Ubuntu) |
Fix Released
|
Undecided
|
Unassigned | ||
Oneiric |
Fix Released
|
High
|
Unassigned | ||
openjdk-7 (Ubuntu) |
Fix Released
|
Undecided
|
Unassigned | ||
Oneiric |
Fix Released
|
Undecided
|
Unassigned |
Bug Description
If the system contains at least one network interface in state "UP" whose interface index (ifr_ifindex) is greater than 255, any calls to java.net.
Interface index numbers can get quite large when we're on a system where network interfaces are added and removed frequently. For example, miredo (a teredo implementation) seems to create and destroy a tuntap interface whenever we need to reestablish the teredo tunnel -- which can be quite often on a laptop. High interface numbers can also be induced artificially by repeatedly adding and removing, say, a macvlan interface.
I'm attaching a simple shell script that demonstrates this bug, along with the glibc buffer overflow crash output that results. I'm also attaching a gdb backtrace.
The problem seems to be caused by the Linux version of the enumIPv6Interfaces function in openjdk/
> fe8000000000000
> 20010000<
> fe8000000000000
> fe8000000000000
> 000000000000000
The second column contains the interface index in hex. Notice that it's normally two characters long, but it becomes longer when the index exceeds 255. However, enumIPv6Interfaces uses fscanf with the format string
"%4s%
which insists that the index is only two characters long. Thus, an index that's 3 chars long causes fscanf to give us lots of garbage, eventually resulting in a crash when we try to do something with the nonsense.
I'm attaching a patch that contains a simple fix. However, it might be a good idea to find a better way to do this and replace this fragile parsing stuff altogether, esp. since the kernel docs don't even bother to document the format of /proc/net/if_inet6. (Netlink, maybe? How does 'ip addr list' do it?)
CVE References
- 2011-3521
- 2011-3544
- 2011-3547
- 2011-3548
- 2011-3551
- 2011-3552
- 2011-3553
- 2011-3554
- 2011-3556
- 2011-3557
- 2011-3558
- 2011-3560
- 2011-3563
- 2011-3571
- 2011-5035
- 2012-0497
- 2012-0501
- 2012-0502
- 2012-0503
- 2012-0505
- 2012-0506
- 2012-1711
- 2012-1713
- 2012-1716
- 2012-1717
- 2012-1718
- 2012-1719
- 2012-1723
- 2012-1724
- 2012-1725
- 2012-1726
- 2012-3216
- 2012-4416
- 2012-4681
- 2012-5068
- 2012-5069
- 2012-5070
- 2012-5071
- 2012-5072
- 2012-5073
- 2012-5074
- 2012-5075
- 2012-5076
- 2012-5077
- 2012-5079
- 2012-5081
- 2012-5084
- 2012-5085
- 2012-5086
- 2012-5087
- 2012-5088
- 2012-5089
The attachment "enumipv6- fix.patch" of this bug report has been identified as being a patch. The ubuntu-reviewers team has been subscribed to the bug report so that they can review the patch. In the event that this is in fact not a patch you can resolve this situation by removing the tag 'patch' from the bug report and editing the attachment so that it is not flagged as a patch. Additionally, if you are member of the ubuntu-reviewers team please also unsubscribe the team from this bug report.
[This is an automated message performed by a Launchpad user owned by Brian Murray. Please contact him regarding any issues with the action taken in this bug report.]