RFR: 8229872: (fs) Increase buffer size used with getmntent
Florian Weimer
fweimer at redhat.com
Mon Aug 19 11:56:08 UTC 2019
* Vladimir Kempik:
> Please review the suggested fix for bug JDK-8229872
>
> Files.getFileStore() will fail if there is an entry in /proc/mounts which is greater than 1024 bytes length
> This happens because we allocate 1024 bytes size buffer on stack for use with getmntent_r.
>
> A possible way is to use getmntent instead, it will allocated 4kb buffer on glibc and «as much as needed» on musl
> (https://www.openwall.com/lists/musl/2016/09/08/1)
> But getmntent is dubbed "MT-Unsafe race:mntentbuf locale»
>
> I have tested this fix on openjdk8u222 and it can parse long entries fine.
I think the bug still persists because a mount path can be up to 4095
bytes long, and it can be expanded to four times that using octal
escapes.
getmntent really isn't thread-safe in the current glibc implementation,
so I don't think you can use that.
I think the easiest solution will be to parse /proc/mounts directly,
from Java code. The file format is expected to be stable and quite
simple. The code probably won't be much longer than for parsing struct
mntent. 8-/
In the future, there might be an RFE to ignore certain entries (e.g.,
those installed by autofs), but the kernel doesn't currently provide the
flag required for that.
Thanks,
Florian
More information about the nio-dev
mailing list