From: Tiwei Bie Date: Thu, 24 Oct 2024 14:28:25 +0000 (+0800) Subject: um: Add os_set_pdeathsig helper function X-Git-Tag: v6.13-rc1~18^2~22 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=4e5adbe447db382cc76e05613581f96aef4f91d2;p=thirdparty%2Fkernel%2Flinux.git um: Add os_set_pdeathsig helper function 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 Link: https://patch.msgid.link/20241024142828.2612828-2-tiwei.btw@antgroup.com Signed-off-by: Johannes Berg --- diff --git a/arch/um/include/shared/os.h b/arch/um/include/shared/os.h index 09f8201de5db3..d709a24dc6fc8 100644 --- a/arch/um/include/shared/os.h +++ b/arch/um/include/shared/os.h @@ -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 */ diff --git a/arch/um/os-Linux/process.c b/arch/um/os-Linux/process.c index f20602e793d91..9f086f9394202 100644 --- a/arch/um/os-Linux/process.c +++ b/arch/um/os-Linux/process.c @@ -12,6 +12,7 @@ #include #include #include +#include #include #include #include @@ -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); +}