From: Nir Lichtman <nir@lichtman.org>
To: viro@zeniv.linux.org.uk, brauner@kernel.org, jack@suse.cz,
kees@kernel.org, ebiederm@xmission.com,
linux-fsdevel@vger.kernel.org, linux-mm@kvack.org,
linux-kernel@vger.kernel.org
Subject: [PATCH] exec: improve clarity of comment regarding pid save-asides
Date: Sat, 1 Feb 2025 20:51:27 +0000 [thread overview]
Message-ID: <20250201205127.GA1191798@lichtman.org> (raw)
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@kernel.org>
Signed-off-by: Nir Lichtman <nir@lichtman.org>
---
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
reply other threads:[~2025-02-01 20:51 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250201205127.GA1191798@lichtman.org \
--to=nir@lichtman.org \
--cc=brauner@kernel.org \
--cc=ebiederm@xmission.com \
--cc=jack@suse.cz \
--cc=kees@kernel.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=viro@zeniv.linux.org.uk \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox