• David Meybohm's avatar
    [PATCH] preempt race in getppid · 4c5640cb
    David Meybohm authored
    With CONFIG_PREEMPT && !CONFIG_SMP, it's possible for sys_getppid to
    return a bogus value if the parent's task_struct gets reallocated after
    current->group_leader->real_parent is read:
    
            asmlinkage long sys_getppid(void)
            {
                    int pid;
                    struct task_struct *me = current;
                    struct task_struct *parent;
    
                    parent = me->group_leader->real_parent;
    RACE HERE =>    for (;;) {
                            pid = parent->tgid;
            #ifdef CONFIG_SMP
            {
                            struct task_struct *old = parent;
    
                            /*
                             * Make sure we read the pid before re-reading the
                             * parent pointer:
                             */
                            smp_rmb();
                            parent = me->group_leader->real_parent;
                            if (old != parent)
                                    continue;
            }
            #endif
                            br...
    4c5640cb
timer.c 42 KB