lkml.org 
[lkml]   [2020]   [Apr]   [28]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    /
    From
    Date
    Subject[PATCH v4 0/2] proc: Ensure we see the exit of each process tid exactly

    In the work to remove proc_mnt I noticed that we were calling
    proc_flush_task now proc_flush_pid possibly multiple times for the same
    pid because of how de_thread works.

    This is a bare minimal patchset to sort out de_thread, by introducing
    exchange_tids and the helper of exchange_tids hlists_swap_heads_rcu.

    The actual call of exchange_tids should be slowpath so I have
    prioritized readability over getting every last drop of performance.

    I have also read through a bunch of the code to see if I could find
    anything that would be affected by this change. Users of
    has_group_leader_pid were a good canidates. But I also looked at other
    cases that might have a pid->task->pid transition. I ignored other
    sources of races with de_thread and exec as those are preexisting.

    I found a close call with send_signals user of task_active_pid_ns, but
    all pids of a thread group are guaranteeds to be in the same pid
    namespace so there is not a problem.

    I found a few pieces of debugging code that do:

    task = pid_task(pid, PIDTYPE_PID);
    if (task) {
    printk("%u\n", task->pid);
    }

    But I can't see how we care if it happens at the wrong moment that
    task->pid might not match pid_nr(pid);

    Similarly because the code in posix-cpu-timers goes pid->task->pid it
    feels like there should be a problem. But as the code that works with
    PIDTYPE_PID is only available within the thread group, and as de_thread
    kills all of the other threads before it makes any changes of this
    kind the race can not happen.

    In short I don't think this change will introduce any regressions.

    Eric W. Biederman (2):
    rculist: Add hlists_swap_heads_rcu
    proc: Ensure we see the exit of each process tid exactly once

    fs/exec.c | 5 +----
    include/linux/pid.h | 1 +
    include/linux/rculist.h | 21 +++++++++++++++++++++
    kernel/pid.c | 19 +++++++++++++++++++
    4 files changed, 42 insertions(+), 4 deletions(-)

    Eric

    \
     
     \ /
      Last update: 2020-04-28 14:21    [W:5.930 / U:0.124 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site