[PATCH] exec: improve clarity of comment regarding pid save-asides

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Problem: Current comment regarding saving aside the old pid and old vpid
is very vague, especially when considering that it is unexpected that
execve can actually kill the current process.

Solution: Improve the description of the comment explaining more
in-depth the reasoning behind.

Suggested-by: Kees Cook <kees@xxxxxxxxxx>
Signed-off-by: Nir Lichtman <nir@xxxxxxxxxxxx>
---
 fs/exec.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/fs/exec.c b/fs/exec.c
index 506cd411f4ac..343c435b00ee 100644
--- a/fs/exec.c
+++ b/fs/exec.c
@@ -1792,7 +1792,14 @@ static int exec_binprm(struct linux_binprm *bprm)
 	pid_t old_pid, old_vpid;
 	int ret, depth;
 
-	/* Need to fetch pid before load_binary changes it */
+	/*
+	 * Need to save aside the current thread pid and vpid
+	 * since if the current thread is not a thread group leader
+	 * the logic in de_thread kills the current thread and all
+	 * other threads in the current thread group, except the leader.
+	 * The new program will execute in the leader, with the leader pid
+	 * ("man 2 clone" CLONE_THREAD flag for more info)
+	 */
 	old_pid = current->pid;
 	rcu_read_lock();
 	old_vpid = task_pid_nr_ns(current, task_active_pid_ns(current->parent));
-- 
2.39.5





[Index of Archives]     [Linux Ext4 Filesystem]     [Union Filesystem]     [Filesystem Testing]     [Ceph Users]     [Ecryptfs]     [NTFS 3]     [AutoFS]     [Kernel Newbies]     [Share Photos]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux Cachefs]     [Reiser Filesystem]     [Linux RAID]     [NTFS 3]     [Samba]     [Device Mapper]     [CEPH Development]

  Powered by Linux