aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDima Dorfman <dd@FreeBSD.org>2001-07-11 23:04:37 +0000
committerDima Dorfman <dd@FreeBSD.org>2001-07-11 23:04:37 +0000
commit9f7a920119575bed649183b1a88c9fd1a0dc3b17 (patch)
tree90a0ff4c90a258db9b04fb8d108d44a15de1aa73
parenta87462cae31a4badb24f81103f97b5addfed18d0 (diff)
downloadsrc-9f7a920119575bed649183b1a88c9fd1a0dc3b17.tar.gz
src-9f7a920119575bed649183b1a88c9fd1a0dc3b17.zip
MFC 1.134, 1.135: don't share sig handlers after an exec.
Approved by: kris
Notes
Notes: svn path=/stable/3/; revision=79599
-rw-r--r--sys/kern/kern_exec.c24
1 files changed, 23 insertions, 1 deletions
diff --git a/sys/kern/kern_exec.c b/sys/kern/kern_exec.c
index e7d9df98f4a8..10aa92a4061a 100644
--- a/sys/kern/kern_exec.c
+++ b/sys/kern/kern_exec.c
@@ -39,9 +39,9 @@
#include <sys/imgact.h>
#include <sys/imgact_elf.h>
#include <sys/wait.h>
+#include <sys/malloc.h>
#include <sys/proc.h>
#include <sys/pioctl.h>
-#include <sys/malloc.h>
#include <sys/namei.h>
#include <sys/sysent.h>
#include <sys/shm.h>
@@ -56,6 +56,7 @@
#include <vm/pmap.h>
#include <vm/vm_page.h>
#include <vm/vm_map.h>
+#include <sys/user.h>
#include <vm/vm_kern.h>
#include <vm/vm_extern.h>
#include <vm/vm_object.h>
@@ -229,6 +230,27 @@ interpret:
p->p_fd = tmp;
}
+ /*
+ * For security and other reasons, signal handlers cannot
+ * be shared after an exec. The new proces gets a copy of the old
+ * handlers. In execsigs(), the new process will have its signals
+ * reset.
+ */
+ if (p->p_procsig->ps_refcnt > 1) {
+ struct procsig *newprocsig;
+
+ MALLOC(newprocsig, struct procsig *, sizeof(struct procsig),
+ M_SUBPROC, M_WAITOK);
+ bcopy(p->p_procsig, newprocsig, sizeof(*newprocsig));
+ p->p_procsig->ps_refcnt--;
+ p->p_procsig = newprocsig;
+ p->p_procsig->ps_refcnt = 1;
+ if (p->p_sigacts == &p->p_addr->u_sigacts)
+ panic("shared procsig but private sigacts?");
+
+ p->p_addr->u_sigacts = *p->p_sigacts;
+ p->p_sigacts = &p->p_addr->u_sigacts;
+ }
/* Stop profiling */
stopprofclock(p);