Skip to contentSkip to conversation

Use task_pid() to find leader's pid

PATCH Superseded [email protected] 1 participant 1 message Jul 15, 2007

Subsystems (2)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 3/5 Use task_pid() to find leader's pid

Subject: [PATCH 3/5] Use task_pid() to find leader's pid

From: Sukadev Bhattiprolu <[email protected]>

Use task_pid() to get leader's pid since find_pid() cannot be used after detach_pid(). See comments in the code below for more details.

Cc Eric W. Biederman <[email protected]>
Cc Cedric Le Goater <[email protected]>
Cc Dave Hansen <[email protected]>
Cc Serge Hallyn <[email protected]>
Cc Herbert Poetzel <[email protected]>
---
 fs/exec.c |    9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)
fs/exec.c +8 -1
Index: lx26-22-rc6-mm1/fs/exec.c
===================================================================
@@ -905,10 +905,17 @@ static int de_thread(struct task_struct 
 		 * The old leader becomes a thread of the this thread group.
 		 * Note: The old leader also uses this pid until release_task
 		 *       is called.  Odd but simple and correct.
+		 * Note: With multiple pid namespaces, active pid namespace of
+		 * 	 a process is stored in its struct pid. The detach_pid
+		 * 	 below frees the struct pid, so we will have no notion
+		 * 	 of an active pid namespace until we complete the
+		 * 	 subsequent attach_pid(). Which means - calls like
+		 * 	 find_pid()/pid_to_nr() return NULL and cannot be used
+		 * 	 between the detach_pid() and attach_pid() calls.
 		 */
 		detach_pid(tsk, PIDTYPE_PID);
 		tsk->pid = leader->pid;
-		attach_pid(tsk, PIDTYPE_PID,  find_pid(tsk->pid));
+		attach_pid(tsk, PIDTYPE_PID,  task_pid(leader));
 		transfer_pid(leader, tsk, PIDTYPE_PGID);
 		transfer_pid(leader, tsk, PIDTYPE_SID);
 		list_replace_rcu(&leader->tasks, &tsk->tasks);