JDK-8229872 : (fs) Increase buffer size used with getmntent
  • Type: Bug
  • Component: core-libs
  • Sub-Component: java.nio
  • Affected Version: 8u221,11,13,14
  • Priority: P4
  • Status: Closed
  • Resolution: Fixed
  • OS: linux
  • Submitted: 2019-08-19
  • Updated: 2023-09-01
  • Resolved: 2019-09-30
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 11 JDK 13 JDK 14 Other
11.0.6Fixed 13.0.2Fixed 14 b17Fixed openjdk8u252Fixed
Related Reports
Relates :  
Relates :  
Description
Currently jni func getmntent uses library's getmntent_r with work buffer of size 1024, allocated on stack.

JNIEXPORT jint JNICALL
Java_sun_nio_fs_LinuxNativeDispatcher_getmntent(JNIEnv* env, jclass this,
    jlong value, jobject entry)
{
    struct mntent ent;
    char buf[1024];
....
 m = getmntent_r(fp, &ent, (char*)&buf, buflen);

In some circumstances it's not enough. for example in docker, with overlayfs we can easily go greater than 1024 bytes per line

need to increase that size, it's better to go with library's getmntent, which will allocate 4096 on glibc and as much as needed on musl. In this case java will be on par with other system utils.

example of entry in /proc/mounts which causes parsing failure in java 

overlay / overlay rw,relatime,lowerdir=/var/lib/docker/overlay2/l/4OJWMLVEPUYBIINATIJYD5AR4A:/var/lib/docker/overlay2/l/BDPV7JUZMLFT2UTSHLSXAAEXJF:/var/lib/docker/overlay2/l/FJSNMHMQCRZYZ7DM6U7ZNTTDB3:/var/lib/docker/overlay2/l/VD3XKYF5UG747TAPJQARVNZQGS:/var/lib/docker/overlay2/l/FAM4UQVWPZY4VY7OWZYNQTYFKR:/var/lib/docker/overlay2/l/DJKXL7Y4XW736RZHCPHNPYBXST:/var/lib/docker/overlay2/l/EFQNH7TVKW2JE6WPQZ2GOI5IXL:/var/lib/docker/overlay2/l/7ZHB6OK5AAA3BEM5AHC55P52D5:/var/lib/docker/overlay2/l/Z3DKKP4J27SFFJWBJ3BRCFPOEC:/var/lib/docker/overlay2/l/FBREGCKO3ELPH4TDOKME5D7ZN5:/var/lib/docker/overlay2/l/DOVG72SJ7UVTP3NMAMBRVYFIK3:/var/lib/docker/overlay2/l/UT6LTWTRKNCSIVE3SN6KU5OBYD:/var/lib/docker/overlay2/l/IOYADTFJLVEG3E7P6YOT5TPEUM:/var/lib/docker/overlay2/l/3FFG3CZ65N42NXFHPBFS3ZG4DL:/var/lib/docker/overlay2/l/VROD4KBP7ADH5O5JKFHH7BSZJF:/var/lib/docker/overlay2/l/IRAV2XDBVUHXQ5YCOKUHOTI74A:/var/lib/docker/overlay2/l/JD6LPCYSY2ZYD5ZKTLF36S6H6U:/var/lib/docker/overlay2/l/7PM25KREJ3VRRD7AHYMUZO3GAP:/var/lib/docker/overlay2/l/TVAAGWQIIGNRRSW6CFVCTWNQEA,upperdir=/var/lib/docker/overlay2/cb73ac1031f0eb741fbcd882e7349a531a07f8dd5c8423252a4ea9708b8a9ee5/diff,workdir=/var/lib/docker/overlay2/cb73ac1031f0eb741fbcd882e7349a531a07f8dd5c8423252a4ea9708b8a9ee5/work 0 0
Comments
8u review approval: https://mail.openjdk.java.net/pipermail/jdk8u-dev/2019-October/010540.html
04-12-2019

Fix Request (8u) This fixes the issue of parsing long lines (1024+ chars) in /proc/mounts affects mostly overlayfs when used in docker. linux-only fix. Didn't apply cleanly to jdk8, review thread for 8u: https://mail.openjdk.java.net/pipermail/jdk8u-dev/2019-October/010484.html Testing: full cycle testing done for azul's october psu (where this fix already included)
31-10-2019

Fix Request (11u) This fixes the issue of parsing long lines (1024+ chars) in /proc/mounts affects mostly overlayfs when used in docker. linux-only fix. Applies cleanly to 11u, needs additional copyright year update in header for few files
16-10-2019

Fix Request (13u) This fixes the issue of parsing long lines (1024+ chars) in /proc/mounts affects mostly overlayfs when used in docker. linux-only fix. Applies cleanly to 13u
03-10-2019

URL: https://hg.openjdk.java.net/jdk/jdk/rev/2d40e6a7ce8e User: bae Date: 2019-09-30 11:52:05 +0000
30-09-2019

Discussion here: https://mail.openjdk.java.net/pipermail/nio-dev/2019-August/006466.html
19-08-2019