RFR: 8229872: (fs) Increase buffer size used with getmntent
Florian Weimer
fweimer at redhat.com
Mon Aug 19 12:54:40 UTC 2019
* Alan Bateman:
> On 19/08/2019 12:56, Florian Weimer wrote:
>> * Vladimir Kempik:
>>
>>> :
>>>
>>> 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»
>>>
>>>
> Is errno set to something useful when getmntent_r fails? Just
> wondering if it can be used to allocate a larger buffer.
getmntent_r currently ignores overlong lines.
One problem is that the interface is fairly broken: Reading a line
consumes it from the stdio stream, and one can determine the required
buffer size only after doing that. This means that the input has to be
seekable, so that the file pointer can be restored to the original value
in case the supplied buffer is too small. /proc/mounts is seekable, so
it could work, but there have been quite a few buffer boundary issues in
the kernel's procfs code, so I'm a bit wary of making this change.
getmntent is easier to fix because glibc can manage the buffer
allocation internally and make it thread-local. But it will take years
until a potential fix reaches most distributions, and until that
happens, using getmntent makes things potentially worse.
Thanks,
Florian
More information about the nio-dev
mailing list