| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | /* $NetBSD: kern_exec.c,v 1.319 2011/08/25 19:54:30 reinoud Exp $ */ | | 1 | /* $NetBSD: kern_exec.c,v 1.320 2011/08/26 06:56:11 christos Exp $ */ |
2 | | | 2 | |
3 | /*- | | 3 | /*- |
4 | * Copyright (c) 2008 The NetBSD Foundation, Inc. | | 4 | * Copyright (c) 2008 The NetBSD Foundation, Inc. |
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. |
| @@ -49,27 +49,27 @@ | | | @@ -49,27 +49,27 @@ |
49 | * THIS SOFTWARE IS PROVIDED BY TOOLS GMBH ``AS IS'' AND ANY EXPRESS OR | | 49 | * THIS SOFTWARE IS PROVIDED BY TOOLS GMBH ``AS IS'' AND ANY EXPRESS OR |
50 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES | | 50 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES |
51 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. | | 51 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. |
52 | * IN NO EVENT SHALL TOOLS GMBH BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | | 52 | * IN NO EVENT SHALL TOOLS GMBH BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
53 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, | | 53 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, |
54 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; | | 54 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; |
55 | * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, | | 55 | * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, |
56 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR | | 56 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR |
57 | * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF | | 57 | * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF |
58 | * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | | 58 | * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
59 | */ | | 59 | */ |
60 | | | 60 | |
61 | #include <sys/cdefs.h> | | 61 | #include <sys/cdefs.h> |
62 | __KERNEL_RCSID(0, "$NetBSD: kern_exec.c,v 1.319 2011/08/25 19:54:30 reinoud Exp $"); | | 62 | __KERNEL_RCSID(0, "$NetBSD: kern_exec.c,v 1.320 2011/08/26 06:56:11 christos Exp $"); |
63 | | | 63 | |
64 | #include "opt_ktrace.h" | | 64 | #include "opt_ktrace.h" |
65 | #include "opt_modular.h" | | 65 | #include "opt_modular.h" |
66 | #include "opt_syscall_debug.h" | | 66 | #include "opt_syscall_debug.h" |
67 | #include "veriexec.h" | | 67 | #include "veriexec.h" |
68 | #include "opt_pax.h" | | 68 | #include "opt_pax.h" |
69 | #include "opt_sa.h" | | 69 | #include "opt_sa.h" |
70 | | | 70 | |
71 | #include <sys/param.h> | | 71 | #include <sys/param.h> |
72 | #include <sys/systm.h> | | 72 | #include <sys/systm.h> |
73 | #include <sys/filedesc.h> | | 73 | #include <sys/filedesc.h> |
74 | #include <sys/kernel.h> | | 74 | #include <sys/kernel.h> |
75 | #include <sys/proc.h> | | 75 | #include <sys/proc.h> |
| @@ -367,33 +367,35 @@ check_exec(struct lwp *l, struct exec_pa | | | @@ -367,33 +367,35 @@ check_exec(struct lwp *l, struct exec_pa |
367 | int newerror; | | 367 | int newerror; |
368 | | | 368 | |
369 | epp->ep_esch = execsw[i]; | | 369 | epp->ep_esch = execsw[i]; |
370 | newerror = (*execsw[i]->es_makecmds)(l, epp); | | 370 | newerror = (*execsw[i]->es_makecmds)(l, epp); |
371 | | | 371 | |
372 | if (!newerror) { | | 372 | if (!newerror) { |
373 | /* Seems ok: check that entry point is not too high */ | | 373 | /* Seems ok: check that entry point is not too high */ |
374 | if (epp->ep_entry > VM_MAXUSER_ADDRESS) { | | 374 | if (epp->ep_entry > VM_MAXUSER_ADDRESS) { |
375 | aprint_verbose("check_exec: rejecting due to " | | 375 | aprint_verbose("check_exec: rejecting due to " |
376 | "too high entry address\n"); | | 376 | "too high entry address\n"); |
377 | error = ENOEXEC; | | 377 | error = ENOEXEC; |
378 | break; | | 378 | break; |
379 | } | | 379 | } |
| | | 380 | #if VM_MIN_ADDRESS > 0 |
380 | /* Seems ok: check that entry point is not too low */ | | 381 | /* Seems ok: check that entry point is not too low */ |
381 | if (epp->ep_entry < VM_MIN_ADDRESS) { | | 382 | if (epp->ep_entry < VM_MIN_ADDRESS) { |
382 | aprint_verbose("check_exec: rejecting due to " | | 383 | aprint_verbose("check_exec: rejecting due to " |
383 | "too low entry address\n"); | | 384 | "too low entry address\n"); |
384 | error = ENOEXEC; | | 385 | error = ENOEXEC; |
385 | break; | | 386 | break; |
386 | } | | 387 | } |
| | | 388 | #endif |
387 | | | 389 | |
388 | /* check limits */ | | 390 | /* check limits */ |
389 | if ((epp->ep_tsize > MAXTSIZ) || | | 391 | if ((epp->ep_tsize > MAXTSIZ) || |
390 | (epp->ep_dsize > (u_quad_t)l->l_proc->p_rlimit | | 392 | (epp->ep_dsize > (u_quad_t)l->l_proc->p_rlimit |
391 | [RLIMIT_DATA].rlim_cur)) { | | 393 | [RLIMIT_DATA].rlim_cur)) { |
392 | aprint_verbose("check_exec: rejecting due to " | | 394 | aprint_verbose("check_exec: rejecting due to " |
393 | "limits\n"); | | 395 | "limits\n"); |
394 | error = ENOMEM; | | 396 | error = ENOMEM; |
395 | break; | | 397 | break; |
396 | } | | 398 | } |
397 | return 0; | | 399 | return 0; |
398 | } | | 400 | } |
399 | | | 401 | |