Revert "exec: fix up /proc/pid/comm in the execveat(AT_EMPTY_PATH) case"

This reverts commit b45605fac3 which is
commit 543841d1806029889c2f69f040e88b247aba8e22 upstream.

It breaks the Android kernel abi and can be brought back in the future
in an abi-safe way if it is really needed.

Bug: 161946584
Change-Id: I22e4874caa735da68f10a3d6477069f24bc0462d
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
This commit is contained in:
Greg Kroah-Hartman
2025-03-07 11:02:53 +00:00
parent ac6e319e7c
commit 96d435eb13
2 changed files with 4 additions and 29 deletions

View File

@@ -1364,28 +1364,7 @@ int begin_new_exec(struct linux_binprm * bprm)
set_dumpable(current->mm, SUID_DUMP_USER); set_dumpable(current->mm, SUID_DUMP_USER);
perf_event_exec(); perf_event_exec();
__set_task_comm(me, kbasename(bprm->filename), true);
/*
* If the original filename was empty, alloc_bprm() made up a path
* that will probably not be useful to admins running ps or similar.
* Let's fix it up to be something reasonable.
*/
if (bprm->comm_from_dentry) {
/*
* Hold RCU lock to keep the name from being freed behind our back.
* Use acquire semantics to make sure the terminating NUL from
* __d_alloc() is seen.
*
* Note, we're deliberately sloppy here. We don't need to care about
* detecting a concurrent rename and just want a terminated name.
*/
rcu_read_lock();
__set_task_comm(me, smp_load_acquire(&bprm->file->f_path.dentry->d_name.name),
true);
rcu_read_unlock();
} else {
__set_task_comm(me, kbasename(bprm->filename), true);
}
/* An exec changes our domain. We are no longer part of the thread /* An exec changes our domain. We are no longer part of the thread
group */ group */
@@ -1544,13 +1523,11 @@ static struct linux_binprm *alloc_bprm(int fd, struct filename *filename)
if (fd == AT_FDCWD || filename->name[0] == '/') { if (fd == AT_FDCWD || filename->name[0] == '/') {
bprm->filename = filename->name; bprm->filename = filename->name;
} else { } else {
if (filename->name[0] == '\0') { if (filename->name[0] == '\0')
bprm->fdpath = kasprintf(GFP_KERNEL, "/dev/fd/%d", fd); bprm->fdpath = kasprintf(GFP_KERNEL, "/dev/fd/%d", fd);
bprm->comm_from_dentry = 1; else
} else {
bprm->fdpath = kasprintf(GFP_KERNEL, "/dev/fd/%d/%s", bprm->fdpath = kasprintf(GFP_KERNEL, "/dev/fd/%d/%s",
fd, filename->name); fd, filename->name);
}
if (!bprm->fdpath) if (!bprm->fdpath)
goto out_free; goto out_free;

View File

@@ -42,9 +42,7 @@ struct linux_binprm {
* Set when errors can no longer be returned to the * Set when errors can no longer be returned to the
* original userspace. * original userspace.
*/ */
point_of_no_return:1, point_of_no_return:1;
/* Set when "comm" must come from the dentry. */
comm_from_dentry:1;
struct file *executable; /* Executable to pass to the interpreter */ struct file *executable; /* Executable to pass to the interpreter */
struct file *interpreter; struct file *interpreter;
struct file *file; struct file *file;