The Design and Implementation of the FreeBSD Operating System, Second Edition
Now available: The Design and Implementation of the FreeBSD Operating System (Second Edition)


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]

FreeBSD/Linux Kernel Cross Reference
sys/sys/pax.h

Version: -  FREEBSD  -  FREEBSD-13-STABLE  -  FREEBSD-13-0  -  FREEBSD-12-STABLE  -  FREEBSD-12-0  -  FREEBSD-11-STABLE  -  FREEBSD-11-0  -  FREEBSD-10-STABLE  -  FREEBSD-10-0  -  FREEBSD-9-STABLE  -  FREEBSD-9-0  -  FREEBSD-8-STABLE  -  FREEBSD-8-0  -  FREEBSD-7-STABLE  -  FREEBSD-7-0  -  FREEBSD-6-STABLE  -  FREEBSD-6-0  -  FREEBSD-5-STABLE  -  FREEBSD-5-0  -  FREEBSD-4-STABLE  -  FREEBSD-3-STABLE  -  FREEBSD22  -  l41  -  OPENBSD  -  linux-2.6  -  MK84  -  PLAN9  -  xnu-8792 
SearchContext: -  none  -  3  -  10 

    1 /* $NetBSD: pax.h,v 1.27 2020/01/23 10:21:14 ad Exp $ */
    2 
    3 /*-
    4  * Copyright (c) 2006 Elad Efrat <elad@NetBSD.org>
    5  * All rights reserved.
    6  *
    7  * Redistribution and use in source and binary forms, with or without
    8  * modification, are permitted provided that the following conditions
    9  * are met:
   10  * 1. Redistributions of source code must retain the above copyright
   11  *    notice, this list of conditions and the following disclaimer.
   12  * 2. Redistributions in binary form must reproduce the above copyright
   13  *    notice, this list of conditions and the following disclaimer in the
   14  *    documentation and/or other materials provided with the distribution.
   15  * 3. The name of the author may not be used to endorse or promote products
   16  *    derived from this software without specific prior written permission.
   17  *
   18  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
   19  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   20  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
   21  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
   22  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
   23  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
   24  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
   25  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
   26  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
   27  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
   28  */
   29 
   30 #ifndef _SYS_PAX_H_
   31 #define _SYS_PAX_H_
   32 
   33 #include <uvm/uvm_extern.h>
   34 
   35 #define P_PAX_ASLR      0x01    /* Enable ASLR */
   36 #define P_PAX_MPROTECT  0x02    /* Enable Mprotect */
   37 #define P_PAX_GUARD     0x04    /* Enable Segvguard */
   38 
   39 struct lwp;
   40 struct proc;
   41 struct exec_package;
   42 struct vmspace;
   43 
   44 #ifdef PAX_ASLR
   45 /*
   46  * We stick this here because we need it in kern/exec_elf.c for now.
   47  */
   48 #ifndef PAX_ASLR_DELTA_EXEC_LEN
   49 #define PAX_ASLR_DELTA_EXEC_LEN 12
   50 #endif
   51 #endif /* PAX_ASLR */
   52 #ifdef PAX_ASLR_DEBUG
   53 extern int pax_aslr_debug;
   54 #endif
   55 
   56 void    pax_segvguard_cleanup(struct vnode *);
   57 
   58 #if defined(PAX_MPROTECT) || defined(PAX_SEGVGUARD) || defined(PAX_ASLR)
   59 void pax_init(void);
   60 void pax_set_flags(struct exec_package *, struct proc *);
   61 void pax_setup_elf_flags(struct exec_package *, uint32_t);
   62 #else
   63 # define pax_init()
   64 # define pax_set_flags(e, p)
   65 # define pax_setup_elf_flags(e, flags) __USE(flags)
   66 #endif
   67 
   68 vm_prot_t pax_mprotect_maxprotect(
   69 #ifdef PAX_MPROTECT_DEBUG
   70     const char *, size_t,
   71 #endif
   72     struct lwp *, vm_prot_t, vm_prot_t, vm_prot_t);
   73 int pax_mprotect_validate(
   74 #ifdef PAX_MPROTECT_DEBUG
   75     const char *, size_t,
   76 #endif
   77     struct lwp *, vm_prot_t);
   78 
   79 #ifndef PAX_MPROTECT
   80 # define PAX_MPROTECT_MAXPROTECT(l, active, extra, max) (max)
   81 # define PAX_MPROTECT_VALIDATE(l, prot) (0)
   82 # define pax_mprotect_prot(l)   0
   83 #else
   84 # ifdef PAX_MPROTECT_DEBUG
   85 #  define PAX_MPROTECT_MAXPROTECT(l, active, extra, max) \
   86     pax_mprotect_maxprotect(__FILE__, __LINE__, (l), (active), (extra), (max))
   87 #  define PAX_MPROTECT_VALIDATE(l, prot) \
   88     pax_mprotect_validate(__FILE__, __LINE__, (l), (prot))
   89 # else
   90 #  define PAX_MPROTECT_MAXPROTECT(l, active, extra, max) \
   91     pax_mprotect_maxprotect((l), (active), (extra), (max))
   92 #  define PAX_MPROTECT_VALIDATE(l, prot) \
   93     pax_mprotect_validate((l), (prot))
   94 # endif
   95 int pax_mprotect_prot(struct lwp *);
   96 #endif
   97 int pax_segvguard(struct lwp *, struct vnode *, const char *, bool);
   98 
   99 #define PAX_ASLR_DELTA(delta, lsb, len) \
  100     (((delta) & ((1UL << (len)) - 1)) << (lsb))
  101 
  102 #ifdef PAX_ASLR
  103 void pax_aslr_init_vm(struct lwp *, struct vmspace *, struct exec_package *);
  104 void pax_aslr_stack(struct exec_package *, vsize_t *);
  105 uint32_t pax_aslr_stack_gap(struct exec_package *);
  106 vaddr_t pax_aslr_exec_offset(struct exec_package *, vaddr_t);
  107 voff_t pax_aslr_rtld_offset(struct exec_package *, vaddr_t, int);
  108 void pax_aslr_mmap(struct lwp *, vaddr_t *, vaddr_t, int);
  109 #else
  110 # define pax_aslr_init_vm(l, v, e)
  111 # define pax_aslr_stack(e, o)
  112 # define pax_aslr_stack_gap(e)  0
  113 # define pax_aslr_exec_offset(e, a) MAX(a, PAGE_SIZE)
  114 # define pax_aslr_rtld_offset(e, a, u) 0
  115 # define pax_aslr_mmap(l, a, b, c)
  116 #endif
  117 
  118 #endif /* !_SYS_PAX_H_ */

Cache object: 1f07c7ecbc2a486a3dee7ff1986f1a2b


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]


This page is part of the FreeBSD/Linux Linux Kernel Cross-Reference, and was automatically generated using a modified version of the LXR engine.