• Sergey Senozhatsky's avatar
    posix-cpu-timers: Rcu_read_lock/unlock protect find_task_by_vpid call · c0deae8c
    Sergey Senozhatsky authored
    Commit 4221a991 "Add RCU check for
    find_task_by_vpid()" introduced rcu_lockdep_assert to find_task_by_pid_ns.
    Add rcu_read_lock/rcu_read_unlock to call find_task_by_vpid.
    Tetsuo Handa wrote:
    | Quoting from one of posts in that thead
    | http://kerneltrap.org/mailarchive/linux-kernel/2010/2/8/4536388
    || Usually tasklist gives enough protection, but if copy_process() fails
    || it calls free_pid() lockless and does call_rcu(delayed_put_pid().
    || This means, without rcu lock find_pid_ns() can't scan the hash table
    || safely.
    Thomas Gleixner wrote:
    | We can remove the tasklist_lock while at it. rcu_read_lock is enough.
    Patch also replaces thread_group_leader with has_group_leader_pid
    in accordance to comment by Oleg Nesterov:
    | ... thread_group_leader() check is not relaible without 
    | tasklist. If we race with de_thread() find_task_by_vpid() can find
    | the new leader before it updates its ->group_leader.
    | perhaps it makes sense to change posix_cpu_timer_create() to use 
    | has_group_leader_pid() instead, just to make this code not look racy
    | and avoid adding new problems.
    Signed-off-by: default avatarSergey Senozhatsky <sergey.senozhatsky@gmail.com>
    Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
    Cc: Stanislaw Gruszka <sgruszka@redhat.com>
    Reviewed-by: default avatarOleg Nesterov <oleg@redhat.com>
    LKML-Reference: <20101103165256.GD30053@swordfish.minsk.epam.com>
    Signed-off-by: default avatarThomas Gleixner <tglx@linutronix.de>
posix-cpu-timers.c 42.5 KB