From 96d435eb130118c992537dd7ec48612eaf16e462 Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Fri, 7 Mar 2025 11:02:53 +0000 Subject: [PATCH] Revert "exec: fix up /proc/pid/comm in the execveat(AT_EMPTY_PATH) case" This reverts commit b45605fac3dec3f6f57c005a7f25198096907284 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 --- fs/exec.c | 29 +++-------------------------- include/linux/binfmts.h | 4 +--- 2 files changed, 4 insertions(+), 29 deletions(-) diff --git a/fs/exec.c b/fs/exec.c index eb088e3cc9a0..0149f828d409 100644 --- a/fs/exec.c +++ b/fs/exec.c @@ -1364,28 +1364,7 @@ int begin_new_exec(struct linux_binprm * bprm) set_dumpable(current->mm, SUID_DUMP_USER); perf_event_exec(); - - /* - * 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); - } + __set_task_comm(me, kbasename(bprm->filename), true); /* An exec changes our domain. We are no longer part of the thread group */ @@ -1544,13 +1523,11 @@ static struct linux_binprm *alloc_bprm(int fd, struct filename *filename) if (fd == AT_FDCWD || filename->name[0] == '/') { bprm->filename = filename->name; } else { - if (filename->name[0] == '\0') { + if (filename->name[0] == '\0') 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", fd, filename->name); - } if (!bprm->fdpath) goto out_free; diff --git a/include/linux/binfmts.h b/include/linux/binfmts.h index af9056d78fad..8d51f69f9f5e 100644 --- a/include/linux/binfmts.h +++ b/include/linux/binfmts.h @@ -42,9 +42,7 @@ struct linux_binprm { * Set when errors can no longer be returned to the * original userspace. */ - point_of_no_return:1, - /* Set when "comm" must come from the dentry. */ - comm_from_dentry:1; + point_of_no_return:1; struct file *executable; /* Executable to pass to the interpreter */ struct file *interpreter; struct file *file;