[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAEXW_YQkVZ3w1oJ+sgmR_YZSHh2gKzAZ=euirHirqz4WxMWt9A@mail.gmail.com>
Date: Wed, 31 Oct 2018 07:43:34 -0700
From: Joel Fernandes <joel@...lfernandes.org>
To: David Laight <David.Laight@...lab.com>
Cc: Daniel Colascione <dancol@...gle.com>,
"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
"timmurray@...gle.com" <timmurray@...gle.com>,
"joelaf@...gle.com" <joelaf@...gle.com>
Subject: Re: [RFC PATCH] Minimal non-child process exit notification support
On Wed, Oct 31, 2018 at 7:41 AM, Joel Fernandes <joel@...lfernandes.org> wrote:
[...]
>>> > Indeed, to avoid killing the wrong process you need to have opened
>>> > some node of /proc/pid/* (maybe cmdline) before sending the kill
>>> > signal.
>>>
>>> The kernel really needs better documentation of the semantics of
>>> procfs file descriptors. You're not the only person to think,
>>> mistakenly, that keeping a reference to a /proc/$PID/something FD
>>> reserves $PID and prevents it being used for another process. Procfs
>>> FDs do no such thing. kill(2) is unsafe whether or not
>>> /proc/pid/cmdline or any other /proc file is open.
>>
>> Interesting.
>> Linux 'fixed' the problem of pid reuse in the kernel by adding (IIRC)
>> 'struct pid' that reference counts the pid stopping reuse.
>
> This is incorrect if you mean numeric pids. See the end of these
> comments in include/linux/pid.h . A pid value can be reused, it just
> works Ok because it causes a new struct pid allocation. That doesn't
> mean there isn't a numeric reuse. There's also no where in pid_alloc()
> where we prevent the numeric reuse AFAICT.
Bleh, I mean alloc_pid().
Powered by blists - more mailing lists