From 5d520d7fab2231498382006524ba2adaa085d141 Mon Sep 17 00:00:00 2001 From: Dmitry Chagin Date: Tue, 30 Apr 2019 17:18:05 +0000 Subject: [PATCH] Follow the FreeBSD and implement PDEATH_SIG prctl ops in the Linuxulator. It was first introduced in r163734 and missied by me in r283383. MFC after: 1 week --- sys/compat/linux/linux_emul.c | 1 - sys/compat/linux/linux_emul.h | 1 - sys/compat/linux/linux_misc.c | 21 +++++++++++---------- 3 files changed, 11 insertions(+), 12 deletions(-) diff --git a/sys/compat/linux/linux_emul.c b/sys/compat/linux/linux_emul.c index b30fb09b86bf..e88eb554aed1 100644 --- a/sys/compat/linux/linux_emul.c +++ b/sys/compat/linux/linux_emul.c @@ -127,7 +127,6 @@ linux_proc_init(struct thread *td, struct thread *newtd, int flags) em->em_tid = p->p_pid; em->flags = 0; - em->pdeath_signal = 0; em->robust_futexes = NULL; em->child_clear_tid = NULL; em->child_set_tid = NULL; diff --git a/sys/compat/linux/linux_emul.h b/sys/compat/linux/linux_emul.h index 3784d6a061a3..fb445de5db98 100644 --- a/sys/compat/linux/linux_emul.h +++ b/sys/compat/linux/linux_emul.h @@ -40,7 +40,6 @@ struct linux_emuldata { int *child_set_tid; /* in clone(): Child's TID to set on clone */ int *child_clear_tid;/* in clone(): Child's TID to clear on exit */ - int pdeath_signal; /* parent death signal */ int flags; /* thread emuldata flags */ int em_tid; /* thread id */ diff --git a/sys/compat/linux/linux_misc.c b/sys/compat/linux/linux_misc.c index f888a2640d1f..a05c6a59be66 100644 --- a/sys/compat/linux/linux_misc.c +++ b/sys/compat/linux/linux_misc.c @@ -51,6 +51,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include #include @@ -1993,7 +1994,6 @@ linux_prctl(struct thread *td, struct linux_prctl_args *args) int error = 0, max_size; struct proc *p = td->td_proc; char comm[LINUX_MAX_COMM_LEN]; - struct linux_emuldata *em; int pdeath_signal; #ifdef DEBUG @@ -2007,17 +2007,18 @@ linux_prctl(struct thread *td, struct linux_prctl_args *args) case LINUX_PR_SET_PDEATHSIG: if (!LINUX_SIG_VALID(args->arg2)) return (EINVAL); - em = em_find(td); - KASSERT(em != NULL, ("prctl: emuldata not found.\n")); - em->pdeath_signal = args->arg2; - break; + pdeath_signal = linux_to_bsd_signal(args->arg2); + return (kern_procctl(td, P_PID, 0, PROC_PDEATHSIG_CTL, + &pdeath_signal)); case LINUX_PR_GET_PDEATHSIG: - em = em_find(td); - KASSERT(em != NULL, ("prctl: emuldata not found.\n")); - pdeath_signal = em->pdeath_signal; - error = copyout(&pdeath_signal, + error = kern_procctl(td, P_PID, 0, PROC_PDEATHSIG_STATUS, + &pdeath_signal); + if (error != 0) + return (error); + pdeath_signal = bsd_to_linux_signal(pdeath_signal); + return (copyout(&pdeath_signal, (void *)(register_t)args->arg2, - sizeof(pdeath_signal)); + sizeof(pdeath_signal))); break; case LINUX_PR_GET_KEEPCAPS: /*