Messages in this thread | | | From | Joel Fernandes <> | Date | Wed, 31 Oct 2018 07:43:34 -0700 | Subject | Re: [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().
| |