Home | History | Annotate | Line # | Download | only in kern
kern_pax.c revision 1.16.6.1
      1  1.16.6.1     joerg /* $NetBSD: kern_pax.c,v 1.16.6.1 2007/10/02 18:29:00 joerg 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.12      elad  * 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.16.6.1     joerg #include <sys/cdefs.h>
     31  1.16.6.1     joerg __KERNEL_RCSID(0, "$NetBSD: kern_pax.c,v 1.16.6.1 2007/10/02 18:29:00 joerg Exp $");
     32  1.16.6.1     joerg 
     33       1.1      elad #include "opt_pax.h"
     34       1.1      elad 
     35       1.1      elad #include <sys/param.h>
     36       1.1      elad #include <sys/proc.h>
     37       1.1      elad #include <sys/exec_elf.h>
     38       1.1      elad #include <sys/pax.h>
     39       1.1      elad #include <sys/sysctl.h>
     40       1.8      elad #include <sys/malloc.h>
     41       1.8      elad #include <sys/fileassoc.h>
     42       1.8      elad #include <sys/syslog.h>
     43       1.8      elad #include <sys/vnode.h>
     44       1.8      elad #include <sys/queue.h>
     45       1.8      elad #include <sys/kauth.h>
     46       1.1      elad 
     47       1.7      elad #ifdef PAX_MPROTECT
     48       1.6      yamt static int pax_mprotect_enabled = 1;
     49       1.6      yamt static int pax_mprotect_global = PAX_MPROTECT;
     50       1.1      elad 
     51       1.7      elad specificdata_key_t pax_mprotect_key;
     52       1.8      elad #endif
     53       1.8      elad 
     54       1.8      elad #ifdef PAX_SEGVGUARD
     55       1.8      elad #ifndef PAX_SEGVGUARD_EXPIRY
     56       1.8      elad #define	PAX_SEGVGUARD_EXPIRY		(2 * 60)
     57       1.8      elad #endif
     58       1.8      elad 
     59       1.8      elad #ifndef PAX_SEGVGUARD_SUSPENSION
     60       1.8      elad #define	PAX_SEGVGUARD_SUSPENSION	(10 * 60)
     61       1.8      elad #endif
     62       1.8      elad 
     63       1.8      elad #ifndef	PAX_SEGVGUARD_MAXCRASHES
     64       1.8      elad #define	PAX_SEGVGUARD_MAXCRASHES	5
     65       1.8      elad #endif
     66       1.8      elad 
     67       1.8      elad static int pax_segvguard_enabled = 1;
     68       1.8      elad static int pax_segvguard_global = PAX_SEGVGUARD;
     69       1.8      elad static int pax_segvguard_expiry = PAX_SEGVGUARD_EXPIRY;
     70       1.8      elad static int pax_segvguard_suspension = PAX_SEGVGUARD_SUSPENSION;
     71       1.8      elad static int pax_segvguard_maxcrashes = PAX_SEGVGUARD_MAXCRASHES;
     72       1.8      elad 
     73       1.8      elad static fileassoc_t segvguard_id;
     74       1.8      elad specificdata_key_t pax_segvguard_key;
     75       1.8      elad 
     76       1.8      elad struct pax_segvguard_uid_entry {
     77       1.8      elad 	uid_t sue_uid;
     78       1.8      elad 	size_t sue_ncrashes;
     79       1.8      elad 	time_t sue_expiry;
     80       1.8      elad 	time_t sue_suspended;
     81       1.8      elad 	LIST_ENTRY(pax_segvguard_uid_entry) sue_list;
     82       1.8      elad };
     83       1.8      elad 
     84       1.8      elad struct pax_segvguard_entry {
     85       1.8      elad 	LIST_HEAD(, pax_segvguard_uid_entry) segv_uids;
     86       1.8      elad };
     87      1.10      yamt 
     88      1.10      yamt static void pax_segvguard_cb(void *);
     89       1.8      elad #endif /* PAX_SEGVGUARD */
     90       1.7      elad 
     91       1.7      elad /* PaX internal setspecific flags */
     92       1.7      elad #define	PAX_MPROTECT_EXPLICIT_ENABLE	(void *)0x01
     93       1.7      elad #define	PAX_MPROTECT_EXPLICIT_DISABLE	(void *)0x02
     94       1.8      elad #define	PAX_SEGVGUARD_EXPLICIT_ENABLE	(void *)0x03
     95       1.8      elad #define	PAX_SEGVGUARD_EXPLICIT_DISABLE	(void *)0x04
     96       1.7      elad 
     97       1.1      elad SYSCTL_SETUP(sysctl_security_pax_setup, "sysctl security.pax setup")
     98       1.1      elad {
     99       1.8      elad 	const struct sysctlnode *rnode = NULL, *cnode;
    100       1.1      elad 
    101       1.1      elad         sysctl_createv(clog, 0, NULL, &rnode,
    102       1.1      elad                        CTLFLAG_PERMANENT,
    103       1.1      elad                        CTLTYPE_NODE, "security", NULL,
    104       1.1      elad                        NULL, 0, NULL, 0,
    105      1.11      elad                        CTL_SECURITY, CTL_EOL);
    106       1.1      elad 
    107       1.1      elad 	sysctl_createv(clog, 0, &rnode, &rnode,
    108       1.1      elad 		       CTLFLAG_PERMANENT,
    109       1.1      elad 		       CTLTYPE_NODE, "pax",
    110       1.1      elad 		       SYSCTL_DESCR("PaX (exploit mitigation) features."),
    111       1.1      elad 		       NULL, 0, NULL, 0,
    112       1.1      elad 		       CTL_CREATE, CTL_EOL);
    113       1.1      elad 
    114       1.8      elad 	cnode = rnode;
    115       1.8      elad 
    116       1.7      elad #ifdef PAX_MPROTECT
    117       1.1      elad 	sysctl_createv(clog, 0, &rnode, &rnode,
    118       1.1      elad 		       CTLFLAG_PERMANENT,
    119       1.1      elad 		       CTLTYPE_NODE, "mprotect",
    120       1.1      elad 		       SYSCTL_DESCR("mprotect(2) W^X restrictions."),
    121       1.1      elad 		       NULL, 0, NULL, 0,
    122       1.1      elad 		       CTL_CREATE, CTL_EOL);
    123       1.1      elad 	sysctl_createv(clog, 0, &rnode, NULL,
    124       1.2      elad 		       CTLFLAG_PERMANENT|CTLFLAG_READWRITE,
    125       1.1      elad 		       CTLTYPE_INT, "enabled",
    126       1.1      elad 		       SYSCTL_DESCR("Restrictions enabled."),
    127       1.2      elad 		       NULL, 0, &pax_mprotect_enabled, 0,
    128       1.1      elad 		       CTL_CREATE, CTL_EOL);
    129       1.1      elad 	sysctl_createv(clog, 0, &rnode, NULL,
    130       1.2      elad 		       CTLFLAG_PERMANENT|CTLFLAG_READWRITE,
    131       1.4      elad 		       CTLTYPE_INT, "global",
    132       1.1      elad 		       SYSCTL_DESCR("When enabled, unless explicitly "
    133       1.5    cbiere 				    "specified, apply restrictions to "
    134       1.1      elad 				    "all processes."),
    135       1.2      elad 		       NULL, 0, &pax_mprotect_global, 0,
    136       1.1      elad 		       CTL_CREATE, CTL_EOL);
    137       1.7      elad #endif /* PAX_MPROTECT */
    138       1.8      elad 
    139       1.8      elad 	rnode = cnode;
    140       1.8      elad 
    141       1.8      elad #ifdef PAX_SEGVGUARD
    142       1.8      elad 	sysctl_createv(clog, 0, &rnode, &rnode,
    143       1.8      elad 		       CTLFLAG_PERMANENT,
    144       1.8      elad 		       CTLTYPE_NODE, "segvguard",
    145       1.8      elad 		       SYSCTL_DESCR("PaX segvguard."),
    146       1.8      elad 		       NULL, 0, NULL, 0,
    147       1.8      elad 		       CTL_CREATE, CTL_EOL);
    148       1.8      elad 	sysctl_createv(clog, 0, &rnode, NULL,
    149       1.8      elad 		       CTLFLAG_PERMANENT|CTLFLAG_READWRITE,
    150       1.8      elad 		       CTLTYPE_INT, "enabled",
    151       1.8      elad 		       SYSCTL_DESCR("segvguard enabled."),
    152       1.8      elad 		       NULL, 0, &pax_segvguard_enabled, 0,
    153       1.8      elad 		       CTL_CREATE, CTL_EOL);
    154       1.8      elad 	sysctl_createv(clog, 0, &rnode, NULL,
    155       1.8      elad 		       CTLFLAG_PERMANENT|CTLFLAG_READWRITE,
    156       1.8      elad 		       CTLTYPE_INT, "global",
    157       1.8      elad 		       SYSCTL_DESCR("segvguard all programs."),
    158       1.8      elad 		       NULL, 0, &pax_segvguard_global, 0,
    159       1.8      elad 		       CTL_CREATE, CTL_EOL);
    160       1.8      elad 	sysctl_createv(clog, 0, &rnode, NULL,
    161       1.8      elad 		       CTLFLAG_PERMANENT|CTLFLAG_READWRITE,
    162       1.8      elad 		       CTLTYPE_INT, "expiry_timeout",
    163       1.8      elad 		       SYSCTL_DESCR("Entry expiry timeout (in seconds)."),
    164       1.8      elad 		       NULL, 0, &pax_segvguard_expiry, 0,
    165       1.8      elad 		       CTL_CREATE, CTL_EOL);
    166       1.8      elad 	sysctl_createv(clog, 0, &rnode, NULL,
    167       1.8      elad 		       CTLFLAG_PERMANENT|CTLFLAG_READWRITE,
    168       1.8      elad 		       CTLTYPE_INT, "suspend_timeout",
    169       1.8      elad 		       SYSCTL_DESCR("Entry suspension timeout (in seconds)."),
    170       1.8      elad 		       NULL, 0, &pax_segvguard_suspension, 0,
    171       1.8      elad 		       CTL_CREATE, CTL_EOL);
    172       1.8      elad 	sysctl_createv(clog, 0, &rnode, NULL,
    173       1.8      elad 		       CTLFLAG_PERMANENT|CTLFLAG_READWRITE,
    174       1.8      elad 		       CTLTYPE_INT, "max_crashes",
    175       1.8      elad 		       SYSCTL_DESCR("Max number of crashes before expiry."),
    176       1.8      elad 		       NULL, 0, &pax_segvguard_maxcrashes, 0,
    177       1.8      elad 		       CTL_CREATE, CTL_EOL);
    178       1.8      elad #endif /* PAX_SEGVGUARD */
    179       1.1      elad }
    180       1.1      elad 
    181       1.7      elad /*
    182       1.7      elad  * Initialize PaX.
    183       1.7      elad  */
    184       1.1      elad void
    185       1.7      elad pax_init(void)
    186       1.1      elad {
    187       1.9      yamt #ifdef PAX_SEGVGUARD
    188       1.9      yamt 	int error;
    189       1.9      yamt #endif /* PAX_SEGVGUARD */
    190       1.9      yamt 
    191       1.7      elad #ifdef PAX_MPROTECT
    192       1.7      elad 	proc_specific_key_create(&pax_mprotect_key, NULL);
    193       1.7      elad #endif /* PAX_MPROTECT */
    194       1.8      elad 
    195       1.8      elad #ifdef PAX_SEGVGUARD
    196       1.9      yamt 	error = fileassoc_register("segvguard", pax_segvguard_cb,
    197       1.9      yamt 	    &segvguard_id);
    198       1.9      yamt 	if (error) {
    199       1.9      yamt 		panic("pax_init: segvguard_id: error=%d\n", error);
    200       1.9      yamt 	}
    201       1.8      elad 	proc_specific_key_create(&pax_segvguard_key, NULL);
    202       1.8      elad #endif /* PAX_SEGVGUARD */
    203       1.7      elad }
    204       1.1      elad 
    205       1.7      elad void
    206      1.16  christos pax_adjust(struct lwp *l, uint32_t f)
    207       1.7      elad {
    208       1.7      elad #ifdef PAX_MPROTECT
    209       1.7      elad 	if (pax_mprotect_enabled) {
    210      1.16  christos 		if (f & ELF_NOTE_PAX_MPROTECT)
    211       1.7      elad 			proc_setspecific(l->l_proc, pax_mprotect_key,
    212       1.7      elad 			    PAX_MPROTECT_EXPLICIT_ENABLE);
    213      1.16  christos 		if (f & ELF_NOTE_PAX_NOMPROTECT)
    214       1.7      elad 			proc_setspecific(l->l_proc, pax_mprotect_key,
    215       1.7      elad 			    PAX_MPROTECT_EXPLICIT_DISABLE);
    216       1.7      elad 	}
    217       1.7      elad #endif /* PAX_MPROTECT */
    218       1.8      elad 
    219       1.8      elad #ifdef PAX_SEGVGUARD
    220       1.8      elad 	if (pax_segvguard_enabled) {
    221      1.16  christos 		if (f & ELF_NOTE_PAX_GUARD)
    222       1.8      elad 			proc_setspecific(l->l_proc, pax_segvguard_key,
    223       1.8      elad 			    PAX_SEGVGUARD_EXPLICIT_ENABLE);
    224      1.16  christos 		if (f & ELF_NOTE_PAX_NOGUARD)
    225       1.8      elad 			proc_setspecific(l->l_proc, pax_segvguard_key,
    226       1.8      elad 			    PAX_SEGVGUARD_EXPLICIT_DISABLE);
    227       1.8      elad 	}
    228       1.8      elad #endif /* PAX_SEGVGUARD */
    229       1.1      elad }
    230       1.1      elad 
    231       1.7      elad #ifdef PAX_MPROTECT
    232       1.1      elad void
    233       1.3      elad pax_mprotect(struct lwp *l, vm_prot_t *prot, vm_prot_t *maxprot)
    234       1.1      elad {
    235       1.7      elad 	void *t;
    236       1.7      elad 
    237       1.7      elad 	if (!pax_mprotect_enabled)
    238       1.7      elad 		return;
    239       1.7      elad 
    240       1.7      elad 	t = proc_getspecific(l->l_proc, pax_mprotect_key);
    241       1.7      elad 	if ((pax_mprotect_global && t == PAX_MPROTECT_EXPLICIT_DISABLE) ||
    242       1.7      elad 	    (!pax_mprotect_global && t != PAX_MPROTECT_EXPLICIT_ENABLE))
    243       1.1      elad 		return;
    244       1.1      elad 
    245       1.3      elad 	if ((*prot & (VM_PROT_WRITE|VM_PROT_EXECUTE)) != VM_PROT_EXECUTE) {
    246       1.3      elad 		*prot &= ~VM_PROT_EXECUTE;
    247       1.3      elad 		*maxprot &= ~VM_PROT_EXECUTE;
    248       1.1      elad 	} else {
    249       1.3      elad 		*prot &= ~VM_PROT_WRITE;
    250       1.3      elad 		*maxprot &= ~VM_PROT_WRITE;
    251       1.1      elad 	}
    252       1.1      elad }
    253       1.7      elad #endif /* PAX_MPROTECT */
    254       1.8      elad 
    255       1.8      elad #ifdef PAX_SEGVGUARD
    256      1.10      yamt static void
    257      1.10      yamt pax_segvguard_cb(void *v)
    258       1.8      elad {
    259       1.8      elad 	struct pax_segvguard_entry *p;
    260       1.8      elad 	struct pax_segvguard_uid_entry *up;
    261       1.8      elad 
    262       1.8      elad 	if (v == NULL)
    263       1.8      elad 		return;
    264       1.8      elad 
    265      1.10      yamt 	p = v;
    266      1.10      yamt 	while ((up = LIST_FIRST(&p->segv_uids)) != NULL) {
    267      1.10      yamt 		LIST_REMOVE(up, sue_list);
    268      1.10      yamt 		free(up, M_TEMP);
    269       1.8      elad 	}
    270       1.8      elad 
    271       1.8      elad 	free(v, M_TEMP);
    272       1.8      elad }
    273       1.8      elad 
    274       1.8      elad /*
    275       1.8      elad  * Called when a process of image vp generated a segfault.
    276       1.8      elad  */
    277       1.8      elad int
    278       1.8      elad pax_segvguard(struct lwp *l, struct vnode *vp, const char *name,
    279      1.14   thorpej     bool crashed)
    280       1.8      elad {
    281       1.8      elad 	struct pax_segvguard_entry *p;
    282       1.8      elad 	struct pax_segvguard_uid_entry *up;
    283       1.8      elad 	struct timeval tv;
    284       1.8      elad 	uid_t uid;
    285       1.8      elad 	void *t;
    286      1.14   thorpej 	bool have_uid;
    287       1.8      elad 
    288       1.8      elad 	if (!pax_segvguard_enabled)
    289       1.8      elad 		return (0);
    290       1.8      elad 
    291       1.8      elad 	t = proc_getspecific(l->l_proc, pax_segvguard_key);
    292       1.8      elad 	if ((pax_segvguard_global && t == PAX_SEGVGUARD_EXPLICIT_DISABLE) ||
    293       1.8      elad 	    (!pax_segvguard_global && t != PAX_SEGVGUARD_EXPLICIT_ENABLE))
    294       1.8      elad 		return (0);
    295       1.8      elad 
    296       1.9      yamt 	if (vp == NULL)
    297       1.8      elad 		return (EFAULT);
    298       1.8      elad 
    299       1.8      elad 	/* Check if we already monitor the file. */
    300       1.8      elad 	p = fileassoc_lookup(vp, segvguard_id);
    301       1.8      elad 
    302       1.8      elad 	/* Fast-path if starting a program we don't know. */
    303       1.8      elad 	if (p == NULL && !crashed)
    304       1.8      elad 		return (0);
    305       1.8      elad 
    306       1.8      elad 	microtime(&tv);
    307       1.8      elad 
    308       1.8      elad 	/*
    309       1.8      elad 	 * If a program we don't know crashed, we need to create a new entry
    310       1.8      elad 	 * for it.
    311       1.8      elad 	 */
    312       1.8      elad 	if (p == NULL) {
    313       1.8      elad 		p = malloc(sizeof(*p), M_TEMP, M_WAITOK);
    314      1.13      elad 		fileassoc_add(vp, segvguard_id, p);
    315       1.8      elad 		LIST_INIT(&p->segv_uids);
    316       1.8      elad 
    317       1.8      elad 		/*
    318       1.8      elad 		 * Initialize a new entry with "crashes so far" of 1.
    319       1.8      elad 		 * The expiry time is when we purge the entry if it didn't
    320       1.8      elad 		 * reach the limit.
    321       1.8      elad 		 */
    322       1.8      elad 		up = malloc(sizeof(*up), M_TEMP, M_WAITOK);
    323       1.8      elad 		up->sue_uid = kauth_cred_getuid(l->l_cred);
    324       1.8      elad 		up->sue_ncrashes = 1;
    325       1.8      elad 		up->sue_expiry = tv.tv_sec + pax_segvguard_expiry;
    326       1.8      elad 		up->sue_suspended = 0;
    327       1.8      elad 
    328       1.8      elad 		LIST_INSERT_HEAD(&p->segv_uids, up, sue_list);
    329       1.8      elad 
    330       1.8      elad 		return (0);
    331       1.8      elad 	}
    332       1.8      elad 
    333       1.8      elad 	/*
    334       1.8      elad 	 * A program we "know" either executed or crashed again.
    335       1.8      elad 	 * See if it's a culprit we're familiar with.
    336       1.8      elad 	 */
    337       1.8      elad 	uid = kauth_cred_getuid(l->l_cred);
    338      1.15   thorpej 	have_uid = false;
    339       1.8      elad 	LIST_FOREACH(up, &p->segv_uids, sue_list) {
    340       1.8      elad 		if (up->sue_uid == uid) {
    341      1.15   thorpej 			have_uid = true;
    342       1.8      elad 			break;
    343       1.8      elad 		}
    344       1.8      elad 	}
    345       1.8      elad 
    346       1.8      elad 	/*
    347       1.8      elad 	 * It's someone else. Add an entry for him if we crashed.
    348       1.8      elad 	 */
    349       1.8      elad 	if (!have_uid) {
    350       1.8      elad 		if (crashed) {
    351       1.8      elad 			up = malloc(sizeof(*up), M_TEMP, M_WAITOK);
    352       1.8      elad 			up->sue_uid = uid;
    353       1.8      elad 			up->sue_ncrashes = 1;
    354       1.8      elad 			up->sue_expiry = tv.tv_sec + pax_segvguard_expiry;
    355       1.8      elad 			up->sue_suspended = 0;
    356       1.8      elad 
    357       1.8      elad 			LIST_INSERT_HEAD(&p->segv_uids, up, sue_list);
    358       1.8      elad 		}
    359       1.8      elad 
    360       1.8      elad 		return (0);
    361       1.8      elad 	}
    362       1.8      elad 
    363       1.8      elad 	if (crashed) {
    364       1.8      elad 		/* Check if timer on previous crashes expired first. */
    365       1.8      elad 		if (up->sue_expiry < tv.tv_sec) {
    366       1.8      elad 			log(LOG_INFO, "PaX Segvguard: [%s] Suspension"
    367       1.8      elad 			    " expired.\n", name ? name : "unknown");
    368       1.8      elad 
    369       1.8      elad 			up->sue_ncrashes = 1;
    370       1.8      elad 			up->sue_expiry = tv.tv_sec + pax_segvguard_expiry;
    371       1.8      elad 			up->sue_suspended = 0;
    372       1.8      elad 
    373       1.8      elad 			return (0);
    374       1.8      elad 		}
    375       1.8      elad 
    376       1.8      elad 		up->sue_ncrashes++;
    377       1.8      elad 
    378       1.8      elad 		if (up->sue_ncrashes >= pax_segvguard_maxcrashes) {
    379       1.8      elad 			log(LOG_ALERT, "PaX Segvguard: [%s] Suspending "
    380       1.8      elad 			    "execution for %d seconds after %zu crashes.\n",
    381       1.8      elad 			    name ? name : "unknown", pax_segvguard_suspension,
    382       1.8      elad 			    up->sue_ncrashes);
    383       1.8      elad 
    384       1.8      elad 			/* Suspend this program for a while. */
    385       1.8      elad 			up->sue_suspended = tv.tv_sec + pax_segvguard_suspension;
    386       1.8      elad 			up->sue_ncrashes = 0;
    387       1.8      elad 			up->sue_expiry = 0;
    388       1.8      elad 		}
    389       1.8      elad 	} else {
    390       1.8      elad 		/* Are we supposed to be suspended? */
    391       1.8      elad 		if (up->sue_suspended > tv.tv_sec) {
    392       1.8      elad 			log(LOG_ALERT, "PaX Segvguard: [%s] Preventing "
    393       1.8      elad 			    "execution due to repeated segfaults.\n", name ?
    394       1.8      elad 			    name : "unknown");
    395       1.8      elad 
    396       1.8      elad 			return (EPERM);
    397       1.8      elad 		}
    398       1.8      elad 	}
    399       1.8      elad 
    400       1.8      elad 	return (0);
    401       1.8      elad }
    402       1.8      elad #endif /* PAX_SEGVGUARD */
    403