]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
um: Add os_set_pdeathsig helper function
authorTiwei Bie <tiwei.btw@antgroup.com>
Thu, 24 Oct 2024 14:28:25 +0000 (22:28 +0800)
committerJohannes Berg <johannes.berg@intel.com>
Fri, 25 Oct 2024 09:34:54 +0000 (11:34 +0200)
This helper can be used to set the parent-death signal of the calling
process to SIGKILL to ensure that the process will be killed if the
UML kernel dies unexpectedly without proper cleanup. This helper will
be used in the follow-up patches.

Signed-off-by: Tiwei Bie <tiwei.btw@antgroup.com>
Link: https://patch.msgid.link/20241024142828.2612828-2-tiwei.btw@antgroup.com
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
arch/um/include/shared/os.h
arch/um/os-Linux/process.c

index 09f8201de5db324b79b1c54db046759c280621c6..d709a24dc6fc83ed4ebce2f8ce60c89c8d1261d3 100644 (file)
@@ -216,6 +216,8 @@ extern int os_drop_memory(void *addr, int length);
 extern int can_drop_memory(void);
 extern int os_mincore(void *addr, unsigned long len);
 
+void os_set_pdeathsig(void);
+
 /* execvp.c */
 extern int execvp_noalloc(char *buf, const char *file, char *const argv[]);
 /* helper.c */
index f20602e793d914945ebb559c6d2570f51e3b2895..9f086f9394202d15776db4594c91cb51a405781c 100644 (file)
@@ -12,6 +12,7 @@
 #include <fcntl.h>
 #include <sys/mman.h>
 #include <sys/ptrace.h>
+#include <sys/prctl.h>
 #include <sys/wait.h>
 #include <asm/unistd.h>
 #include <init.h>
@@ -203,3 +204,8 @@ void init_new_thread_signals(void)
        set_handler(SIGIO);
        signal(SIGWINCH, SIG_IGN);
 }
+
+void os_set_pdeathsig(void)
+{
+       prctl(PR_SET_PDEATHSIG, SIGKILL);
+}