kern_pax.c revision 1.3.14.2 1 1.3.14.2 ad /* $NetBSD: kern_pax.c,v 1.3.14.2 2007/01/12 01:04:06 ad Exp $ */
2 1.1 elad
3 1.1 elad /*-
4 1.1 elad * Copyright (c) 2006 Elad Efrat <elad (at) NetBSD.org>
5 1.1 elad * All rights reserved.
6 1.1 elad *
7 1.1 elad * Redistribution and use in source and binary forms, with or without
8 1.1 elad * modification, are permitted provided that the following conditions
9 1.1 elad * are met:
10 1.1 elad * 1. Redistributions of source code must retain the above copyright
11 1.1 elad * notice, this list of conditions and the following disclaimer.
12 1.1 elad * 2. Redistributions in binary form must reproduce the above copyright
13 1.1 elad * notice, this list of conditions and the following disclaimer in the
14 1.1 elad * documentation and/or other materials provided with the distribution.
15 1.3.14.2 ad * 3. The name of the author may not be used to endorse or promote products
16 1.1 elad * derived from this software without specific prior written permission.
17 1.1 elad *
18 1.1 elad * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
19 1.1 elad * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
20 1.1 elad * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
21 1.1 elad * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
22 1.1 elad * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
23 1.1 elad * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24 1.1 elad * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25 1.1 elad * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26 1.1 elad * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
27 1.1 elad * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 1.1 elad */
29 1.1 elad
30 1.1 elad #include "opt_pax.h"
31 1.1 elad
32 1.1 elad #include <sys/param.h>
33 1.1 elad #include <sys/proc.h>
34 1.1 elad #include <sys/exec_elf.h>
35 1.1 elad #include <sys/pax.h>
36 1.1 elad #include <sys/sysctl.h>
37 1.3.14.2 ad #include <sys/malloc.h>
38 1.3.14.2 ad #include <sys/fileassoc.h>
39 1.3.14.2 ad #include <sys/syslog.h>
40 1.3.14.2 ad #include <sys/vnode.h>
41 1.3.14.2 ad #include <sys/queue.h>
42 1.3.14.2 ad #include <sys/kauth.h>
43 1.1 elad
44 1.3.14.2 ad #ifdef PAX_MPROTECT
45 1.3.14.1 ad static int pax_mprotect_enabled = 1;
46 1.3.14.1 ad static int pax_mprotect_global = PAX_MPROTECT;
47 1.1 elad
48 1.3.14.2 ad specificdata_key_t pax_mprotect_key;
49 1.3.14.2 ad #endif
50 1.3.14.2 ad
51 1.3.14.2 ad #ifdef PAX_SEGVGUARD
52 1.3.14.2 ad #ifndef PAX_SEGVGUARD_EXPIRY
53 1.3.14.2 ad #define PAX_SEGVGUARD_EXPIRY (2 * 60)
54 1.3.14.2 ad #endif
55 1.3.14.2 ad
56 1.3.14.2 ad #ifndef PAX_SEGVGUARD_SUSPENSION
57 1.3.14.2 ad #define PAX_SEGVGUARD_SUSPENSION (10 * 60)
58 1.3.14.2 ad #endif
59 1.3.14.2 ad
60 1.3.14.2 ad #ifndef PAX_SEGVGUARD_MAXCRASHES
61 1.3.14.2 ad #define PAX_SEGVGUARD_MAXCRASHES 5
62 1.3.14.2 ad #endif
63 1.3.14.2 ad
64 1.3.14.2 ad static int pax_segvguard_enabled = 1;
65 1.3.14.2 ad static int pax_segvguard_global = PAX_SEGVGUARD;
66 1.3.14.2 ad static int pax_segvguard_expiry = PAX_SEGVGUARD_EXPIRY;
67 1.3.14.2 ad static int pax_segvguard_suspension = PAX_SEGVGUARD_SUSPENSION;
68 1.3.14.2 ad static int pax_segvguard_maxcrashes = PAX_SEGVGUARD_MAXCRASHES;
69 1.3.14.2 ad
70 1.3.14.2 ad static fileassoc_t segvguard_id;
71 1.3.14.2 ad specificdata_key_t pax_segvguard_key;
72 1.3.14.2 ad
73 1.3.14.2 ad struct pax_segvguard_uid_entry {
74 1.3.14.2 ad uid_t sue_uid;
75 1.3.14.2 ad size_t sue_ncrashes;
76 1.3.14.2 ad time_t sue_expiry;
77 1.3.14.2 ad time_t sue_suspended;
78 1.3.14.2 ad LIST_ENTRY(pax_segvguard_uid_entry) sue_list;
79 1.3.14.2 ad };
80 1.3.14.2 ad
81 1.3.14.2 ad struct pax_segvguard_entry {
82 1.3.14.2 ad LIST_HEAD(, pax_segvguard_uid_entry) segv_uids;
83 1.3.14.2 ad };
84 1.3.14.2 ad
85 1.3.14.2 ad static void pax_segvguard_cb(void *);
86 1.3.14.2 ad #endif /* PAX_SEGVGUARD */
87 1.3.14.2 ad
88 1.3.14.2 ad /* PaX internal setspecific flags */
89 1.3.14.2 ad #define PAX_MPROTECT_EXPLICIT_ENABLE (void *)0x01
90 1.3.14.2 ad #define PAX_MPROTECT_EXPLICIT_DISABLE (void *)0x02
91 1.3.14.2 ad #define PAX_SEGVGUARD_EXPLICIT_ENABLE (void *)0x03
92 1.3.14.2 ad #define PAX_SEGVGUARD_EXPLICIT_DISABLE (void *)0x04
93 1.3.14.2 ad
94 1.1 elad SYSCTL_SETUP(sysctl_security_pax_setup, "sysctl security.pax setup")
95 1.1 elad {
96 1.3.14.2 ad const struct sysctlnode *rnode = NULL, *cnode;
97 1.1 elad
98 1.1 elad sysctl_createv(clog, 0, NULL, &rnode,
99 1.1 elad CTLFLAG_PERMANENT,
100 1.1 elad CTLTYPE_NODE, "security", NULL,
101 1.1 elad NULL, 0, NULL, 0,
102 1.3.14.2 ad CTL_SECURITY, CTL_EOL);
103 1.1 elad
104 1.1 elad sysctl_createv(clog, 0, &rnode, &rnode,
105 1.1 elad CTLFLAG_PERMANENT,
106 1.1 elad CTLTYPE_NODE, "pax",
107 1.1 elad SYSCTL_DESCR("PaX (exploit mitigation) features."),
108 1.1 elad NULL, 0, NULL, 0,
109 1.1 elad CTL_CREATE, CTL_EOL);
110 1.1 elad
111 1.3.14.2 ad cnode = rnode;
112 1.3.14.2 ad
113 1.3.14.2 ad #ifdef PAX_MPROTECT
114 1.1 elad sysctl_createv(clog, 0, &rnode, &rnode,
115 1.1 elad CTLFLAG_PERMANENT,
116 1.1 elad CTLTYPE_NODE, "mprotect",
117 1.1 elad SYSCTL_DESCR("mprotect(2) W^X restrictions."),
118 1.1 elad NULL, 0, NULL, 0,
119 1.1 elad CTL_CREATE, CTL_EOL);
120 1.1 elad sysctl_createv(clog, 0, &rnode, NULL,
121 1.2 elad CTLFLAG_PERMANENT|CTLFLAG_READWRITE,
122 1.1 elad CTLTYPE_INT, "enabled",
123 1.1 elad SYSCTL_DESCR("Restrictions enabled."),
124 1.2 elad NULL, 0, &pax_mprotect_enabled, 0,
125 1.1 elad CTL_CREATE, CTL_EOL);
126 1.1 elad sysctl_createv(clog, 0, &rnode, NULL,
127 1.2 elad CTLFLAG_PERMANENT|CTLFLAG_READWRITE,
128 1.3.14.1 ad CTLTYPE_INT, "global",
129 1.1 elad SYSCTL_DESCR("When enabled, unless explicitly "
130 1.3.14.1 ad "specified, apply restrictions to "
131 1.1 elad "all processes."),
132 1.2 elad NULL, 0, &pax_mprotect_global, 0,
133 1.1 elad CTL_CREATE, CTL_EOL);
134 1.3.14.2 ad #endif /* PAX_MPROTECT */
135 1.3.14.2 ad
136 1.3.14.2 ad rnode = cnode;
137 1.3.14.2 ad
138 1.3.14.2 ad #ifdef PAX_SEGVGUARD
139 1.3.14.2 ad sysctl_createv(clog, 0, &rnode, &rnode,
140 1.3.14.2 ad CTLFLAG_PERMANENT,
141 1.3.14.2 ad CTLTYPE_NODE, "segvguard",
142 1.3.14.2 ad SYSCTL_DESCR("PaX segvguard."),
143 1.3.14.2 ad NULL, 0, NULL, 0,
144 1.3.14.2 ad CTL_CREATE, CTL_EOL);
145 1.3.14.2 ad sysctl_createv(clog, 0, &rnode, NULL,
146 1.3.14.2 ad CTLFLAG_PERMANENT|CTLFLAG_READWRITE,
147 1.3.14.2 ad CTLTYPE_INT, "enabled",
148 1.3.14.2 ad SYSCTL_DESCR("segvguard enabled."),
149 1.3.14.2 ad NULL, 0, &pax_segvguard_enabled, 0,
150 1.3.14.2 ad CTL_CREATE, CTL_EOL);
151 1.3.14.2 ad sysctl_createv(clog, 0, &rnode, NULL,
152 1.3.14.2 ad CTLFLAG_PERMANENT|CTLFLAG_READWRITE,
153 1.3.14.2 ad CTLTYPE_INT, "global",
154 1.3.14.2 ad SYSCTL_DESCR("segvguard all programs."),
155 1.3.14.2 ad NULL, 0, &pax_segvguard_global, 0,
156 1.3.14.2 ad CTL_CREATE, CTL_EOL);
157 1.3.14.2 ad sysctl_createv(clog, 0, &rnode, NULL,
158 1.3.14.2 ad CTLFLAG_PERMANENT|CTLFLAG_READWRITE,
159 1.3.14.2 ad CTLTYPE_INT, "expiry_timeout",
160 1.3.14.2 ad SYSCTL_DESCR("Entry expiry timeout (in seconds)."),
161 1.3.14.2 ad NULL, 0, &pax_segvguard_expiry, 0,
162 1.3.14.2 ad CTL_CREATE, CTL_EOL);
163 1.3.14.2 ad sysctl_createv(clog, 0, &rnode, NULL,
164 1.3.14.2 ad CTLFLAG_PERMANENT|CTLFLAG_READWRITE,
165 1.3.14.2 ad CTLTYPE_INT, "suspend_timeout",
166 1.3.14.2 ad SYSCTL_DESCR("Entry suspension timeout (in seconds)."),
167 1.3.14.2 ad NULL, 0, &pax_segvguard_suspension, 0,
168 1.3.14.2 ad CTL_CREATE, CTL_EOL);
169 1.3.14.2 ad sysctl_createv(clog, 0, &rnode, NULL,
170 1.3.14.2 ad CTLFLAG_PERMANENT|CTLFLAG_READWRITE,
171 1.3.14.2 ad CTLTYPE_INT, "max_crashes",
172 1.3.14.2 ad SYSCTL_DESCR("Max number of crashes before expiry."),
173 1.3.14.2 ad NULL, 0, &pax_segvguard_maxcrashes, 0,
174 1.3.14.2 ad CTL_CREATE, CTL_EOL);
175 1.3.14.2 ad #endif /* PAX_SEGVGUARD */
176 1.1 elad }
177 1.1 elad
178 1.3.14.2 ad /*
179 1.3.14.2 ad * Initialize PaX.
180 1.3.14.2 ad */
181 1.1 elad void
182 1.3.14.2 ad pax_init(void)
183 1.1 elad {
184 1.3.14.2 ad #ifdef PAX_SEGVGUARD
185 1.3.14.2 ad int error;
186 1.3.14.2 ad #endif /* PAX_SEGVGUARD */
187 1.3.14.2 ad
188 1.3.14.2 ad #ifdef PAX_MPROTECT
189 1.3.14.2 ad proc_specific_key_create(&pax_mprotect_key, NULL);
190 1.3.14.2 ad #endif /* PAX_MPROTECT */
191 1.3.14.2 ad
192 1.3.14.2 ad #ifdef PAX_SEGVGUARD
193 1.3.14.2 ad error = fileassoc_register("segvguard", pax_segvguard_cb,
194 1.3.14.2 ad &segvguard_id);
195 1.3.14.2 ad if (error) {
196 1.3.14.2 ad panic("pax_init: segvguard_id: error=%d\n", error);
197 1.3.14.2 ad }
198 1.3.14.2 ad proc_specific_key_create(&pax_segvguard_key, NULL);
199 1.3.14.2 ad #endif /* PAX_SEGVGUARD */
200 1.3.14.2 ad }
201 1.3.14.2 ad
202 1.3.14.2 ad void
203 1.3.14.2 ad pax_adjust(struct lwp *l, int f)
204 1.3.14.2 ad {
205 1.3.14.2 ad #ifdef PAX_MPROTECT
206 1.3.14.2 ad if (pax_mprotect_enabled) {
207 1.3.14.2 ad if (f & PF_PAXMPROTECT)
208 1.3.14.2 ad proc_setspecific(l->l_proc, pax_mprotect_key,
209 1.3.14.2 ad PAX_MPROTECT_EXPLICIT_ENABLE);
210 1.3.14.2 ad if (f & PF_PAXNOMPROTECT)
211 1.3.14.2 ad proc_setspecific(l->l_proc, pax_mprotect_key,
212 1.3.14.2 ad PAX_MPROTECT_EXPLICIT_DISABLE);
213 1.3.14.2 ad }
214 1.3.14.2 ad #endif /* PAX_MPROTECT */
215 1.1 elad
216 1.3.14.2 ad #ifdef PAX_SEGVGUARD
217 1.3.14.2 ad if (pax_segvguard_enabled) {
218 1.3.14.2 ad if (f & PF_PAXGUARD) {
219 1.3.14.2 ad proc_setspecific(l->l_proc, pax_segvguard_key,
220 1.3.14.2 ad PAX_SEGVGUARD_EXPLICIT_ENABLE);
221 1.3.14.2 ad }
222 1.3.14.2 ad if (f & PF_PAXNOGUARD)
223 1.3.14.2 ad proc_setspecific(l->l_proc, pax_segvguard_key,
224 1.3.14.2 ad PAX_SEGVGUARD_EXPLICIT_DISABLE);
225 1.3.14.2 ad }
226 1.3.14.2 ad #endif /* PAX_SEGVGUARD */
227 1.1 elad }
228 1.1 elad
229 1.3.14.2 ad #ifdef PAX_MPROTECT
230 1.1 elad void
231 1.3 elad pax_mprotect(struct lwp *l, vm_prot_t *prot, vm_prot_t *maxprot)
232 1.1 elad {
233 1.3.14.2 ad void *t;
234 1.3.14.2 ad
235 1.3.14.2 ad if (!pax_mprotect_enabled)
236 1.3.14.2 ad return;
237 1.3.14.2 ad
238 1.3.14.2 ad t = proc_getspecific(l->l_proc, pax_mprotect_key);
239 1.3.14.2 ad if ((pax_mprotect_global && t == PAX_MPROTECT_EXPLICIT_DISABLE) ||
240 1.3.14.2 ad (!pax_mprotect_global && t != PAX_MPROTECT_EXPLICIT_ENABLE))
241 1.1 elad return;
242 1.1 elad
243 1.3 elad if ((*prot & (VM_PROT_WRITE|VM_PROT_EXECUTE)) != VM_PROT_EXECUTE) {
244 1.3 elad *prot &= ~VM_PROT_EXECUTE;
245 1.3 elad *maxprot &= ~VM_PROT_EXECUTE;
246 1.1 elad } else {
247 1.3 elad *prot &= ~VM_PROT_WRITE;
248 1.3 elad *maxprot &= ~VM_PROT_WRITE;
249 1.1 elad }
250 1.1 elad }
251 1.3.14.2 ad #endif /* PAX_MPROTECT */
252 1.3.14.2 ad
253 1.3.14.2 ad #ifdef PAX_SEGVGUARD
254 1.3.14.2 ad static void
255 1.3.14.2 ad pax_segvguard_cb(void *v)
256 1.3.14.2 ad {
257 1.3.14.2 ad struct pax_segvguard_entry *p;
258 1.3.14.2 ad struct pax_segvguard_uid_entry *up;
259 1.3.14.2 ad
260 1.3.14.2 ad if (v == NULL)
261 1.3.14.2 ad return;
262 1.3.14.2 ad
263 1.3.14.2 ad p = v;
264 1.3.14.2 ad while ((up = LIST_FIRST(&p->segv_uids)) != NULL) {
265 1.3.14.2 ad LIST_REMOVE(up, sue_list);
266 1.3.14.2 ad free(up, M_TEMP);
267 1.3.14.2 ad }
268 1.3.14.2 ad
269 1.3.14.2 ad free(v, M_TEMP);
270 1.3.14.2 ad }
271 1.3.14.2 ad
272 1.3.14.2 ad /*
273 1.3.14.2 ad * Called when a process of image vp generated a segfault.
274 1.3.14.2 ad */
275 1.3.14.2 ad int
276 1.3.14.2 ad pax_segvguard(struct lwp *l, struct vnode *vp, const char *name,
277 1.3.14.2 ad boolean_t crashed)
278 1.3.14.2 ad {
279 1.3.14.2 ad struct pax_segvguard_entry *p;
280 1.3.14.2 ad struct pax_segvguard_uid_entry *up;
281 1.3.14.2 ad struct timeval tv;
282 1.3.14.2 ad uid_t uid;
283 1.3.14.2 ad void *t;
284 1.3.14.2 ad boolean_t have_uid;
285 1.3.14.2 ad
286 1.3.14.2 ad if (!pax_segvguard_enabled)
287 1.3.14.2 ad return (0);
288 1.3.14.2 ad
289 1.3.14.2 ad t = proc_getspecific(l->l_proc, pax_segvguard_key);
290 1.3.14.2 ad if ((pax_segvguard_global && t == PAX_SEGVGUARD_EXPLICIT_DISABLE) ||
291 1.3.14.2 ad (!pax_segvguard_global && t != PAX_SEGVGUARD_EXPLICIT_ENABLE))
292 1.3.14.2 ad return (0);
293 1.3.14.2 ad
294 1.3.14.2 ad if (vp == NULL)
295 1.3.14.2 ad return (EFAULT);
296 1.3.14.2 ad
297 1.3.14.2 ad /* Check if we already monitor the file. */
298 1.3.14.2 ad p = fileassoc_lookup(vp, segvguard_id);
299 1.3.14.2 ad
300 1.3.14.2 ad /* Fast-path if starting a program we don't know. */
301 1.3.14.2 ad if (p == NULL && !crashed)
302 1.3.14.2 ad return (0);
303 1.3.14.2 ad
304 1.3.14.2 ad microtime(&tv);
305 1.3.14.2 ad
306 1.3.14.2 ad /*
307 1.3.14.2 ad * If a program we don't know crashed, we need to create a new entry
308 1.3.14.2 ad * for it.
309 1.3.14.2 ad */
310 1.3.14.2 ad if (p == NULL) {
311 1.3.14.2 ad p = malloc(sizeof(*p), M_TEMP, M_WAITOK);
312 1.3.14.2 ad if (fileassoc_add(vp, segvguard_id, p) != 0) {
313 1.3.14.2 ad fileassoc_table_add(vp->v_mount, 16);
314 1.3.14.2 ad fileassoc_add(vp, segvguard_id, p);
315 1.3.14.2 ad }
316 1.3.14.2 ad LIST_INIT(&p->segv_uids);
317 1.3.14.2 ad
318 1.3.14.2 ad /*
319 1.3.14.2 ad * Initialize a new entry with "crashes so far" of 1.
320 1.3.14.2 ad * The expiry time is when we purge the entry if it didn't
321 1.3.14.2 ad * reach the limit.
322 1.3.14.2 ad */
323 1.3.14.2 ad up = malloc(sizeof(*up), M_TEMP, M_WAITOK);
324 1.3.14.2 ad up->sue_uid = kauth_cred_getuid(l->l_cred);
325 1.3.14.2 ad up->sue_ncrashes = 1;
326 1.3.14.2 ad up->sue_expiry = tv.tv_sec + pax_segvguard_expiry;
327 1.3.14.2 ad up->sue_suspended = 0;
328 1.3.14.2 ad
329 1.3.14.2 ad LIST_INSERT_HEAD(&p->segv_uids, up, sue_list);
330 1.3.14.2 ad
331 1.3.14.2 ad return (0);
332 1.3.14.2 ad }
333 1.3.14.2 ad
334 1.3.14.2 ad /*
335 1.3.14.2 ad * A program we "know" either executed or crashed again.
336 1.3.14.2 ad * See if it's a culprit we're familiar with.
337 1.3.14.2 ad */
338 1.3.14.2 ad uid = kauth_cred_getuid(l->l_cred);
339 1.3.14.2 ad have_uid = FALSE;
340 1.3.14.2 ad LIST_FOREACH(up, &p->segv_uids, sue_list) {
341 1.3.14.2 ad if (up->sue_uid == uid) {
342 1.3.14.2 ad have_uid = TRUE;
343 1.3.14.2 ad break;
344 1.3.14.2 ad }
345 1.3.14.2 ad }
346 1.3.14.2 ad
347 1.3.14.2 ad /*
348 1.3.14.2 ad * It's someone else. Add an entry for him if we crashed.
349 1.3.14.2 ad */
350 1.3.14.2 ad if (!have_uid) {
351 1.3.14.2 ad if (crashed) {
352 1.3.14.2 ad up = malloc(sizeof(*up), M_TEMP, M_WAITOK);
353 1.3.14.2 ad up->sue_uid = uid;
354 1.3.14.2 ad up->sue_ncrashes = 1;
355 1.3.14.2 ad up->sue_expiry = tv.tv_sec + pax_segvguard_expiry;
356 1.3.14.2 ad up->sue_suspended = 0;
357 1.3.14.2 ad
358 1.3.14.2 ad LIST_INSERT_HEAD(&p->segv_uids, up, sue_list);
359 1.3.14.2 ad }
360 1.3.14.2 ad
361 1.3.14.2 ad return (0);
362 1.3.14.2 ad }
363 1.3.14.2 ad
364 1.3.14.2 ad if (crashed) {
365 1.3.14.2 ad /* Check if timer on previous crashes expired first. */
366 1.3.14.2 ad if (up->sue_expiry < tv.tv_sec) {
367 1.3.14.2 ad log(LOG_INFO, "PaX Segvguard: [%s] Suspension"
368 1.3.14.2 ad " expired.\n", name ? name : "unknown");
369 1.3.14.2 ad
370 1.3.14.2 ad up->sue_ncrashes = 1;
371 1.3.14.2 ad up->sue_expiry = tv.tv_sec + pax_segvguard_expiry;
372 1.3.14.2 ad up->sue_suspended = 0;
373 1.3.14.2 ad
374 1.3.14.2 ad return (0);
375 1.3.14.2 ad }
376 1.3.14.2 ad
377 1.3.14.2 ad up->sue_ncrashes++;
378 1.3.14.2 ad
379 1.3.14.2 ad if (up->sue_ncrashes >= pax_segvguard_maxcrashes) {
380 1.3.14.2 ad log(LOG_ALERT, "PaX Segvguard: [%s] Suspending "
381 1.3.14.2 ad "execution for %d seconds after %zu crashes.\n",
382 1.3.14.2 ad name ? name : "unknown", pax_segvguard_suspension,
383 1.3.14.2 ad up->sue_ncrashes);
384 1.3.14.2 ad
385 1.3.14.2 ad /* Suspend this program for a while. */
386 1.3.14.2 ad up->sue_suspended = tv.tv_sec + pax_segvguard_suspension;
387 1.3.14.2 ad up->sue_ncrashes = 0;
388 1.3.14.2 ad up->sue_expiry = 0;
389 1.3.14.2 ad }
390 1.3.14.2 ad } else {
391 1.3.14.2 ad /* Are we supposed to be suspended? */
392 1.3.14.2 ad if (up->sue_suspended > tv.tv_sec) {
393 1.3.14.2 ad log(LOG_ALERT, "PaX Segvguard: [%s] Preventing "
394 1.3.14.2 ad "execution due to repeated segfaults.\n", name ?
395 1.3.14.2 ad name : "unknown");
396 1.3.14.2 ad
397 1.3.14.2 ad return (EPERM);
398 1.3.14.2 ad }
399 1.3.14.2 ad }
400 1.3.14.2 ad
401 1.3.14.2 ad return (0);
402 1.3.14.2 ad }
403 1.3.14.2 ad #endif /* PAX_SEGVGUARD */
404