Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8229872

(fs) Increase buffer size used with getmntent

    Details

    • Type: Bug
    • Status: In Progress
    • Priority: P4
    • Resolution: Unresolved
    • Affects Version/s: 8u221, 11, 13, 14
    • Fix Version/s: tbd
    • Component/s: core-libs
    • Subcomponent:
    • Understanding:
      Fix Understood
    • OS:
      linux

      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

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                vkempik Vladimir Kempik
                Reporter:
                vkempik Vladimir Kempik
              • Votes:
                0 Vote for this issue
                Watchers:
                2 Start watching this issue

                Dates

                • Created:
                  Updated: