Re: [PATCH v5] Implement "info proc mappings" for NetBSD

Kamil Rytarowski
2020-04-12T10:18:34Z

On 12.04.2020 02:56, Simon Marchi wrote:
> On 2020-04-11 8:09 p.m., Kamil Rytarowski wrote:
>> + /* Prereserve more space. The length argument is volatile and can change
>> + between the sysctl(3) calls as this function can be called against a
>> + running process. */
>> + length = length * 5 / 3;
>
> I was also wondering why such a "precise" factor, and why not simply times two, for example.
>

It's just guessing and there are races... actually a kernel can return a
similar result too for various sysctl(3) calls, adding some more room
for users that forgot to enlarge the buffer.

In almost 100% cases this code will be good enough, and when it won't be
good enough we might have bigger problems in the system.

For a traced process there are no races as the process is stopped.

> In any case, the patch v5 is ok to push.
>

OK!

> Simon
>