]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
um: restore process name
authorJohannes Berg <johannes.berg@intel.com>
Thu, 10 Oct 2024 14:14:12 +0000 (16:14 +0200)
committerJohannes Berg <johannes.berg@intel.com>
Wed, 23 Oct 2024 07:25:55 +0000 (09:25 +0200)
After the execve() to disable ASLR, comm is now "exe",
which is a bit confusing. Use readlink() to get this
to the right name again.

Disable stack frame size warnings on main.o since it's
part of the initial userspace and can use larger stack.

Fixes: 68b9883cc16e ("um: Discover host_task_size from envp")
Link: https://patch.msgid.link/20241010161411.c576e2aeb3e5.I244d4f34b8a8555ee5bec0e1cf5027bce4cc491b@changeid
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
arch/um/os-Linux/Makefile
arch/um/os-Linux/main.c

index 544e0b344c754aedcf51b73e91dca8e74211a225..049dfa5bc9c69a0d8d13916820a1b7e1880959ca 100644 (file)
@@ -12,6 +12,8 @@ obj-y = execvp.o file.o helper.o irq.o main.o mem.o process.o \
 
 CFLAGS_signal.o += -Wframe-larger-than=4096
 
+CFLAGS_main.o += -Wno-frame-larger-than
+
 obj-$(CONFIG_ARCH_REUSE_HOST_VSYSCALL_AREA) += elf_aux.o
 
 USER_OBJS := $(user-objs-y) elf_aux.o execvp.o file.o helper.o irq.o \
index 8a52c49c53615352e75fb55efb7fc6bb5e616567..5e0cba5aee931350d5b9f3bf65c7fbcb0ec1cec7 100644 (file)
@@ -10,6 +10,7 @@
 #include <errno.h>
 #include <signal.h>
 #include <string.h>
+#include <limits.h>
 #include <sys/resource.h>
 #include <sys/personality.h>
 #include <as-layout.h>
@@ -112,8 +113,17 @@ int __init main(int argc, char **argv, char **envp)
        /* Disable randomization and re-exec if it was changed successfully */
        ret = personality(PER_LINUX | ADDR_NO_RANDOMIZE);
        if (ret >= 0 && (ret & (PER_LINUX | ADDR_NO_RANDOMIZE)) !=
-                        (PER_LINUX | ADDR_NO_RANDOMIZE))
-               execve("/proc/self/exe", argv, envp);
+                        (PER_LINUX | ADDR_NO_RANDOMIZE)) {
+               char buf[PATH_MAX] = {};
+               ssize_t ret;
+
+               ret = readlink("/proc/self/exe", buf, sizeof(buf));
+               if (ret < 0 || ret >= sizeof(buf)) {
+                       perror("readlink failure");
+                       exit(1);
+               }
+               execve(buf, argv, envp);
+       }
 
        set_stklim();