]> git.proxmox.com Git - mirror_ubuntu-focal-kernel.git/blobdiff - fs/exec.c
[PATCH] convert sighand_cache to use SLAB_DESTROY_BY_RCU
[mirror_ubuntu-focal-kernel.git] / fs / exec.c
index dd194923c52c77e482d0d4601c27916aee68139f..950ebd43cdc35dd2503214db36289dddb5f26250 100644 (file)
--- a/fs/exec.c
+++ b/fs/exec.c
@@ -708,22 +708,30 @@ static int de_thread(struct task_struct *tsk)
                remove_parent(current);
                remove_parent(leader);
 
-               switch_exec_pids(leader, current);
+
+               /* Become a process group leader with the old leader's pid.
+                * Note: The old leader also uses thispid until release_task
+                *       is called.  Odd but simple and correct.
+                */
+               detach_pid(current, PIDTYPE_PID);
+               current->pid = leader->pid;
+               attach_pid(current, PIDTYPE_PID,  current->pid);
+               attach_pid(current, PIDTYPE_PGID, current->signal->pgrp);
+               attach_pid(current, PIDTYPE_SID,  current->signal->session);
+               list_add_tail(&current->tasks, &init_task.tasks);
 
                current->parent = current->real_parent = leader->real_parent;
                leader->parent = leader->real_parent = child_reaper;
                current->group_leader = current;
                leader->group_leader = leader;
 
-               add_parent(current, current->parent);
-               add_parent(leader, leader->parent);
+               add_parent(current);
+               add_parent(leader);
                if (ptrace) {
                        current->ptrace = ptrace;
                        __ptrace_link(current, parent);
                }
 
-               list_del(&current->tasks);
-               list_add_tail(&current->tasks, &init_task.tasks);
                current->exit_signal = SIGCHLD;
 
                BUG_ON(leader->exit_state != EXIT_ZOMBIE);
@@ -760,7 +768,6 @@ no_thread_group:
                /*
                 * Move our state over to newsighand and switch it in.
                 */
-               spin_lock_init(&newsighand->siglock);
                atomic_set(&newsighand->count, 1);
                memcpy(newsighand->action, oldsighand->action,
                       sizeof(newsighand->action));
@@ -777,7 +784,7 @@ no_thread_group:
                write_unlock_irq(&tasklist_lock);
 
                if (atomic_dec_and_test(&oldsighand->count))
-                       sighand_free(oldsighand);
+                       kmem_cache_free(sighand_cachep, oldsighand);
        }
 
        BUG_ON(!thread_group_leader(current));