aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWarner Losh <imp@FreeBSD.org>2001-07-10 08:18:03 +0000
committerWarner Losh <imp@FreeBSD.org>2001-07-10 08:18:03 +0000
commitd313203e85c01ec64e0bba4b7506a853e98d8795 (patch)
treeb4ca70972ab9780fb9b378cfcbddf49f0559bf3f
parentb68d3b22b2a05cc8be8b68a91e04529e539bff33 (diff)
downloadsrc-d313203e85c01ec64e0bba4b7506a853e98d8795.tar.gz
src-d313203e85c01ec64e0bba4b7506a853e98d8795.zip
MFS: don't share shared signal handlers accross the exec
Notes
Notes: svn path=/releng/4.3/; revision=79518
-rw-r--r--sys/kern/kern_exec.c27
1 files changed, 25 insertions, 2 deletions
diff --git a/sys/kern/kern_exec.c b/sys/kern/kern_exec.c
index 04b8145024b6..4c2130d51343 100644
--- a/sys/kern/kern_exec.c
+++ b/sys/kern/kern_exec.c
@@ -29,7 +29,6 @@
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/sysproto.h>
-#include <sys/signalvar.h>
#include <sys/kernel.h>
#include <sys/mount.h>
#include <sys/filedesc.h>
@@ -39,9 +38,10 @@
#include <sys/imgact.h>
#include <sys/imgact_elf.h>
#include <sys/wait.h>
+#include <sys/malloc.h>
#include <sys/proc.h>
+#include <sys/signalvar.h>
#include <sys/pioctl.h>
-#include <sys/malloc.h>
#include <sys/namei.h>
#include <sys/sysent.h>
#include <sys/shm.h>
@@ -59,6 +59,7 @@
#include <vm/vm_object.h>
#include <vm/vm_pager.h>
+#include <sys/user.h>
#include <machine/reg.h>
MALLOC_DEFINE(M_PARGS, "proc-args", "Process arguments");
@@ -246,6 +247,28 @@ 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 wll 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?\n");
+
+ p->p_addr->u_sigacts = *p->p_sigacts;
+ p->p_sigacts = &p->p_addr->u_sigacts;
+ }
+
/* Stop profiling */
stopprofclock(p);