1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
|
Index: kern_exec.c
===================================================================
RCS file: /home/ncvs/src/sys/kern/kern_exec.c,v
retrieving revision 1.107.2.7
diff -u -r1.107.2.7 kern_exec.c
--- kern_exec.c 2001/06/16 23:39:08 1.107.2.7
+++ kern_exec.c 2001/07/10 00:43:48
@@ -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");
@@ -244,6 +245,28 @@
tmp = fdcopy(p);
fdfree(p);
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 */
|