lkml.org 
[lkml]   [2018]   [Oct]   [31]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
Date
SubjectRe: [RFC PATCH] Minimal non-child process exit notification support
On Wed, Oct 31, 2018 at 7:41 AM, Joel Fernandes <joel@joelfernandes.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().

\
 
 \ /
  Last update: 2018-10-31 15:44    [W:0.104 / U:0.168 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site