| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | /* $NetBSD: kern_pax.c,v 1.27 2014/02/25 18:30:11 pooka Exp $ */ | | 1 | /* $NetBSD: kern_pax.c,v 1.28 2015/04/13 16:36:12 riastradh Exp $ */ |
2 | | | 2 | |
3 | /*- | | 3 | /*- |
4 | * Copyright (c) 2006 Elad Efrat <elad@NetBSD.org> | | 4 | * Copyright (c) 2006 Elad Efrat <elad@NetBSD.org> |
5 | * All rights reserved. | | 5 | * All rights reserved. |
6 | * | | 6 | * |
7 | * Redistribution and use in source and binary forms, with or without | | 7 | * Redistribution and use in source and binary forms, with or without |
8 | * modification, are permitted provided that the following conditions | | 8 | * modification, are permitted provided that the following conditions |
9 | * are met: | | 9 | * are met: |
10 | * 1. Redistributions of source code must retain the above copyright | | 10 | * 1. Redistributions of source code must retain the above copyright |
11 | * notice, this list of conditions and the following disclaimer. | | 11 | * notice, this list of conditions and the following disclaimer. |
12 | * 2. Redistributions in binary form must reproduce the above copyright | | 12 | * 2. Redistributions in binary form must reproduce the above copyright |
13 | * notice, this list of conditions and the following disclaimer in the | | 13 | * notice, this list of conditions and the following disclaimer in the |
14 | * documentation and/or other materials provided with the distribution. | | 14 | * documentation and/or other materials provided with the distribution. |
| @@ -18,46 +18,45 @@ | | | @@ -18,46 +18,45 @@ |
18 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR | | 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 | | 19 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES |
20 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. | | 20 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. |
21 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, | | 21 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, |
22 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT | | 22 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT |
23 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | | 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 | | 24 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
25 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | | 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 | | 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. | | 27 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
28 | */ | | 28 | */ |
29 | | | 29 | |
30 | #include <sys/cdefs.h> | | 30 | #include <sys/cdefs.h> |
31 | __KERNEL_RCSID(0, "$NetBSD: kern_pax.c,v 1.27 2014/02/25 18:30:11 pooka Exp $"); | | 31 | __KERNEL_RCSID(0, "$NetBSD: kern_pax.c,v 1.28 2015/04/13 16:36:12 riastradh Exp $"); |
32 | | | 32 | |
33 | #include "opt_pax.h" | | 33 | #include "opt_pax.h" |
34 | | | 34 | |
35 | #include <sys/param.h> | | 35 | #include <sys/param.h> |
36 | #include <sys/proc.h> | | 36 | #include <sys/proc.h> |
37 | #include <sys/exec_elf.h> | | 37 | #include <sys/exec_elf.h> |
38 | #include <sys/pax.h> | | 38 | #include <sys/pax.h> |
39 | #include <sys/sysctl.h> | | 39 | #include <sys/sysctl.h> |
40 | #include <sys/kmem.h> | | 40 | #include <sys/kmem.h> |
41 | #include <sys/fileassoc.h> | | 41 | #include <sys/fileassoc.h> |
42 | #include <sys/syslog.h> | | 42 | #include <sys/syslog.h> |
43 | #include <sys/vnode.h> | | 43 | #include <sys/vnode.h> |
44 | #include <sys/queue.h> | | 44 | #include <sys/queue.h> |
45 | #include <sys/kauth.h> | | 45 | #include <sys/kauth.h> |
46 | #include <sys/cprng.h> | | 46 | #include <sys/cprng.h> |
47 | | | 47 | |
48 | #ifdef PAX_ASLR | | 48 | #ifdef PAX_ASLR |
49 | #include <sys/mman.h> | | 49 | #include <sys/mman.h> |
50 | #include <sys/rnd.h> | | | |
51 | #include <sys/exec.h> | | 50 | #include <sys/exec.h> |
52 | | | 51 | |
53 | int pax_aslr_enabled = 1; | | 52 | int pax_aslr_enabled = 1; |
54 | int pax_aslr_global = PAX_ASLR; | | 53 | int pax_aslr_global = PAX_ASLR; |
55 | | | 54 | |
56 | #ifndef PAX_ASLR_DELTA_MMAP_LSB | | 55 | #ifndef PAX_ASLR_DELTA_MMAP_LSB |
57 | #define PAX_ASLR_DELTA_MMAP_LSB PGSHIFT | | 56 | #define PAX_ASLR_DELTA_MMAP_LSB PGSHIFT |
58 | #endif | | 57 | #endif |
59 | #ifndef PAX_ASLR_DELTA_MMAP_LEN | | 58 | #ifndef PAX_ASLR_DELTA_MMAP_LEN |
60 | #define PAX_ASLR_DELTA_MMAP_LEN ((sizeof(void *) * NBBY) / 2) | | 59 | #define PAX_ASLR_DELTA_MMAP_LEN ((sizeof(void *) * NBBY) / 2) |
61 | #endif | | 60 | #endif |
62 | #ifndef PAX_ASLR_DELTA_STACK_LSB | | 61 | #ifndef PAX_ASLR_DELTA_STACK_LSB |
63 | #define PAX_ASLR_DELTA_STACK_LSB PGSHIFT | | 62 | #define PAX_ASLR_DELTA_STACK_LSB PGSHIFT |