]> git.proxmox.com Git - mirror_ubuntu-zesty-kernel.git/blobdiff - kernel/exit.c
elf_core_dump: use rcu_read_lock() to access ->real_parent
[mirror_ubuntu-zesty-kernel.git] / kernel / exit.c
index 213f906f5e165dd07d73e9e7db9debf6b682f703..94a9992e6fd9e037921c15a1e8447dd6b3cd8f75 100644 (file)
@@ -757,7 +757,7 @@ static void reparent_thread(struct task_struct *father, struct task_struct *p,
        p->exit_signal = SIGCHLD;
 
        /* If it has exited notify the new parent about this child's death. */
-       if (!p->ptrace &&
+       if (!task_ptrace(p) &&
            p->exit_state == EXIT_ZOMBIE && thread_group_empty(p)) {
                do_notify_parent(p, p->exit_signal);
                if (task_detached(p)) {
@@ -782,7 +782,7 @@ static void forget_original_parent(struct task_struct *father)
        list_for_each_entry_safe(p, n, &father->children, sibling) {
                p->real_parent = reaper;
                if (p->parent == father) {
-                       BUG_ON(p->ptrace);
+                       BUG_ON(task_ptrace(p));
                        p->parent = p->real_parent;
                }
                reparent_thread(father, p, &dead_children);
@@ -1191,7 +1191,6 @@ static int wait_task_zombie(struct task_struct *p, int options,
        if (likely(!traced)) {
                struct signal_struct *psig;
                struct signal_struct *sig;
-               struct task_cputime cputime;
 
                /*
                 * The resource counters for the group leader are in its
@@ -1204,26 +1203,23 @@ static int wait_task_zombie(struct task_struct *p, int options,
                 * p->signal fields, because they are only touched by
                 * __exit_signal, which runs with tasklist_lock
                 * write-locked anyway, and so is excluded here.  We do
-                * need to protect the access to p->parent->signal fields,
+                * need to protect the access to parent->signal fields,
                 * as other threads in the parent group can be right
                 * here reaping other children at the same time.
-                *
-                * We use thread_group_cputime() to get times for the thread
-                * group, which consolidates times for all threads in the
-                * group including the group leader.
                 */
-               thread_group_cputime(p, &cputime);
-               spin_lock_irq(&p->parent->sighand->siglock);
-               psig = p->parent->signal;
+               spin_lock_irq(&p->real_parent->sighand->siglock);
+               psig = p->real_parent->signal;
                sig = p->signal;
                psig->cutime =
                        cputime_add(psig->cutime,
-                       cputime_add(cputime.utime,
-                                   sig->cutime));
+                       cputime_add(p->utime,
+                       cputime_add(sig->utime,
+                                   sig->cutime)));
                psig->cstime =
                        cputime_add(psig->cstime,
-                       cputime_add(cputime.stime,
-                                   sig->cstime));
+                       cputime_add(p->stime,
+                       cputime_add(sig->stime,
+                                   sig->cstime)));
                psig->cgtime =
                        cputime_add(psig->cgtime,
                        cputime_add(p->gtime,
@@ -1245,7 +1241,7 @@ static int wait_task_zombie(struct task_struct *p, int options,
                        sig->oublock + sig->coublock;
                task_io_accounting_add(&psig->ioac, &p->ioac);
                task_io_accounting_add(&psig->ioac, &sig->ioac);
-               spin_unlock_irq(&p->parent->sighand->siglock);
+               spin_unlock_irq(&p->real_parent->sighand->siglock);
        }
 
        /*
@@ -1482,7 +1478,7 @@ static int wait_consider_task(struct task_struct *parent, int ptrace,
                return 0;
        }
 
-       if (likely(!ptrace) && unlikely(p->ptrace)) {
+       if (likely(!ptrace) && unlikely(task_ptrace(p))) {
                /*
                 * This child is hidden by ptrace.
                 * We aren't allowed to see it now, but eventually we will.