FreeBSD kernel kern code
|
#include <sys/cdefs.h>
#include "opt_capsicum.h"
#include "opt_hwpmc_hooks.h"
#include "opt_kdtrace.h"
#include "opt_ktrace.h"
#include "opt_vm.h"
#include <sys/param.h>
#include <sys/capability.h>
#include <sys/systm.h>
#include <sys/eventhandler.h>
#include <sys/lock.h>
#include <sys/mutex.h>
#include <sys/sysproto.h>
#include <sys/signalvar.h>
#include <sys/kernel.h>
#include <sys/mount.h>
#include <sys/filedesc.h>
#include <sys/fcntl.h>
#include <sys/acct.h>
#include <sys/exec.h>
#include <sys/imgact.h>
#include <sys/imgact_elf.h>
#include <sys/wait.h>
#include <sys/malloc.h>
#include <sys/priv.h>
#include <sys/proc.h>
#include <sys/pioctl.h>
#include <sys/namei.h>
#include <sys/resourcevar.h>
#include <sys/sched.h>
#include <sys/sdt.h>
#include <sys/sf_buf.h>
#include <sys/syscallsubr.h>
#include <sys/sysent.h>
#include <sys/shm.h>
#include <sys/sysctl.h>
#include <sys/vnode.h>
#include <sys/stat.h>
#include <vm/vm.h>
#include <vm/vm_param.h>
#include <vm/pmap.h>
#include <vm/vm_page.h>
#include <vm/vm_map.h>
#include <vm/vm_kern.h>
#include <vm/vm_extern.h>
#include <vm/vm_object.h>
#include <vm/vm_pager.h>
#include <machine/reg.h>
#include <security/audit/audit.h>
#include <security/mac/mac_framework.h>
Go to the source code of this file.
Data Structures | |
struct | execve_args |
struct | fexecve_args |
struct | __mac_execve_args |
Functions | |
__FBSDID ("$BSDSUniX$") | |
SDT_PROVIDER_DECLARE (proc) | |
SDT_PROBE_DEFINE1 (proc, kernel,, exec,"char *") | |
SDT_PROBE_DEFINE1 (proc, kernel,, exec__failure,"int") | |
SDT_PROBE_DEFINE1 (proc, kernel,, exec__success,"char *") | |
MALLOC_DEFINE (M_PARGS,"proc-args","Process arguments") | |
static int | sysctl_kern_ps_strings (SYSCTL_HANDLER_ARGS) |
static int | sysctl_kern_usrstack (SYSCTL_HANDLER_ARGS) |
static int | sysctl_kern_stackprot (SYSCTL_HANDLER_ARGS) |
static int | do_execve (struct thread *td, struct image_args *args, struct mac *mac_p) |
SYSCTL_PROC (_kern, KERN_PS_STRINGS, ps_strings, CTLTYPE_ULONG|CTLFLAG_RD, NULL, 0, sysctl_kern_ps_strings,"LU","") | |
SYSCTL_PROC (_kern, KERN_USRSTACK, usrstack, CTLTYPE_ULONG|CTLFLAG_RD|CTLFLAG_CAPRD, NULL, 0, sysctl_kern_usrstack,"LU","") | |
SYSCTL_PROC (_kern, OID_AUTO, stackprot, CTLTYPE_INT|CTLFLAG_RD, NULL, 0, sysctl_kern_stackprot,"I","") | |
SYSCTL_ULONG (_kern, OID_AUTO, ps_arg_cache_limit, CTLFLAG_RW,&ps_arg_cache_limit, 0,"") | |
SYSCTL_INT (_kern, OID_AUTO, disallow_high_osrel, CTLFLAG_RW,&disallow_high_osrel, 0,"Disallow execution of binaries built for higher version of the world") | |
TUNABLE_INT ("security.bsd.map_at_zero",&map_at_zero) | |
SYSCTL_INT (_security_bsd, OID_AUTO, map_at_zero, CTLFLAG_RW,&map_at_zero, 0,"Permit processes to map an object at virtual address 0.") | |
int | sys_execve (struct thread *td, struct execve_args *uap) |
struct fexecve_args | sys_fexecve (struct thread *td, struct fexecve_args *uap) |
int | sys___mac_execve (struct thread *td, struct __mac_execve_args *uap) |
int | kern_execve (struct thread *td, struct image_args *args, struct mac *mac_p) |
int | exec_map_first_page (struct image_params *imgp) |
void | exec_unmap_first_page (struct image_params *imgp) |
int | exec_new_vmspace (struct image_params *imgp, struct sysentvec *sv) |
int | exec_copyin_args (struct image_args *args, char *fname, enum uio_seg segflg, char **argv, char **envv) |
int | exec_alloc_args (struct image_args *args) |
void | exec_free_args (struct image_args *args) |
register_t * | exec_copyout_strings (struct image_params *imgp) |
int | exec_check_permissions (struct image_params *imgp) |
int | exec_register (struct execsw *execsw_arg) const |
int | exec_unregister (struct execsw *execsw_arg) const |
Variables | |
u_long | ps_arg_cache_limit = PAGE_SIZE / 16 |
static int | disallow_high_osrel |
static int | map_at_zero = 0 |
static const struct execsw ** | execsw |
int | fd |
char ** | argv |
char ** | envv |
struct __mac_execve_args | sys_fexecve |
__FBSDID | ( | "$BSDSUniX$" | ) |
|
static |
Definition at line 333 of file kern_exec.c.
References change_egid(), change_euid(), change_svgid(), change_svuid(), crcopysafe(), crfree(), crget(), disallow_high_osrel, exec_check_permissions(), exec_copyout_strings(), exec_free_args(), exec_map_first_page(), exec_unmap_first_page(), execsigs(), execsw, exit1(), fdcheckstd(), fdcloseexec(), fdunshare(), fgetvp_exec(), free(), namei(), NDFREE(), pargs_alloc(), pargs_drop(), priv_check_cred(), ps_arg_cache_limit, setsugid(), setugidsafety(), sigacts_alloc(), sigacts_copy(), sigacts_free(), sigacts_shared(), stopprofclock(), suword, uifind(), uifree(), uprintf(), vfs_mark_atime(), vn_commname(), vn_fullpath(), vput(), and vrele().
Referenced by kern_execve().
int exec_alloc_args | ( | struct image_args * | args | ) |
Definition at line 1229 of file kern_exec.c.
Referenced by exec_copyin_args().
int exec_check_permissions | ( | struct image_params * | imgp | ) |
Definition at line 1414 of file kern_exec.c.
Referenced by do_execve(), and load_file().
int exec_copyin_args | ( | struct image_args * | args, |
char * | fname, | ||
enum uio_seg | segflg, | ||
char ** | argv, | ||
char ** | envv | ||
) |
Definition at line 1138 of file kern_exec.c.
References exec_alloc_args(), and exec_free_args().
Referenced by sys___mac_execve(), and sys_fexecve().
register_t* exec_copyout_strings | ( | struct image_params * | imgp | ) |
Definition at line 1257 of file kern_exec.c.
References pagesizes, and suword.
Referenced by do_execve().
void exec_free_args | ( | struct image_args * | args | ) |
Definition at line 1237 of file kern_exec.c.
References free().
Referenced by do_execve(), exec_copyin_args(), and kern_execve().
int exec_map_first_page | ( | struct image_params * | imgp | ) |
Definition at line 958 of file kern_exec.c.
References busy, and exec_unmap_first_page().
Referenced by do_execve(), and load_file().
int exec_new_vmspace | ( | struct image_params * | imgp, |
struct sysentvec * | sv | ||
) |
Definition at line 1045 of file kern_exec.c.
References map_at_zero, maxssiz, sgrowsiz, and shmexit().
Referenced by do_aout_hdr(), and exec_aout_imgact().
int exec_register | ( | struct execsw * | execsw_arg | ) | const |
void exec_unmap_first_page | ( | struct image_params * | imgp | ) |
Definition at line 1024 of file kern_exec.c.
Referenced by do_execve(), exec_map_first_page(), and load_file().
int exec_unregister | ( | struct execsw * | execsw_arg | ) | const |
int kern_execve | ( | struct thread * | td, |
struct image_args * | args, | ||
struct mac * | mac_p | ||
) |
Definition at line 279 of file kern_exec.c.
References do_execve(), exec_free_args(), thread_single(), and thread_single_end().
Referenced by sys___mac_execve(), and sys_fexecve().
MALLOC_DEFINE | ( | M_PARGS | , |
"proc-args" | , | ||
"Process arguments" | |||
) |
SDT_PROBE_DEFINE1 | ( | proc | , |
kernel | , | ||
exec | , | ||
"char *" | |||
) |
SDT_PROBE_DEFINE1 | ( | proc | , |
kernel | , | ||
exec__failure | , | ||
"int" | |||
) |
SDT_PROBE_DEFINE1 | ( | proc | , |
kernel | , | ||
exec__success | , | ||
"char *" | |||
) |
SDT_PROVIDER_DECLARE | ( | proc | ) |
int sys___mac_execve | ( | struct thread * | td, |
struct __mac_execve_args * | uap | ||
) |
Definition at line 248 of file kern_exec.c.
References __mac_execve_args::argv, __mac_execve_args::envv, exec_copyin_args(), __mac_execve_args::fname, kern_execve(), and __mac_execve_args::mac_p.
int sys_execve | ( | struct thread * | td, |
struct execve_args * | uap | ||
) |
Definition at line 198 of file kern_exec.c.
Referenced by start_init().
struct fexecve_args sys_fexecve | ( | struct thread * | td, |
struct fexecve_args * | uap | ||
) |
Definition at line 224 of file kern_exec.c.
References fexecve_args::argv, fexecve_args::envv, exec_copyin_args(), fexecve_args::fd, and kern_execve().
SYSCTL_INT | ( | _kern | , |
OID_AUTO | , | ||
disallow_high_osrel | , | ||
CTLFLAG_RW | , | ||
& | disallow_high_osrel, | ||
0 | , | ||
"Disallow execution of binaries built for higher version of the world" | |||
) |
SYSCTL_INT | ( | _security_bsd | , |
OID_AUTO | , | ||
map_at_zero | , | ||
CTLFLAG_RW | , | ||
& | map_at_zero, | ||
0 | , | ||
"Permit processes to map an object at virtual address 0." | |||
) |
|
static |
Definition at line 136 of file kern_exec.c.
|
static |
Definition at line 174 of file kern_exec.c.
|
static |
Definition at line 155 of file kern_exec.c.
SYSCTL_PROC | ( | _kern | , |
KERN_PS_STRINGS | , | ||
ps_strings | , | ||
CTLTYPE_ULONG| | CTLFLAG_RD, | ||
NULL | , | ||
0 | , | ||
sysctl_kern_ps_strings | , | ||
"LU" | , | ||
"" | |||
) |
SYSCTL_PROC | ( | _kern | , |
KERN_USRSTACK | , | ||
usrstack | , | ||
CTLTYPE_ULONG|CTLFLAG_RD| | CTLFLAG_CAPRD, | ||
NULL | , | ||
0 | , | ||
sysctl_kern_usrstack | , | ||
"LU" | , | ||
"" | |||
) |
SYSCTL_PROC | ( | _kern | , |
OID_AUTO | , | ||
stackprot | , | ||
CTLTYPE_INT| | CTLFLAG_RD, | ||
NULL | , | ||
0 | , | ||
sysctl_kern_stackprot | , | ||
"I" | , | ||
"" | |||
) |
SYSCTL_ULONG | ( | _kern | , |
OID_AUTO | , | ||
ps_arg_cache_limit | , | ||
CTLFLAG_RW | , | ||
& | ps_arg_cache_limit, | ||
0 | , | ||
"" | |||
) |
TUNABLE_INT | ( | "security.bsd.map_at_zero" | , |
& | map_at_zero | ||
) |
char** argv |
Definition at line 200 of file kern_exec.c.
|
static |
Definition at line 125 of file kern_exec.c.
Referenced by do_execve().
char** envv |
Definition at line 201 of file kern_exec.c.
|
static |
Definition at line 187 of file kern_exec.c.
Referenced by do_execve(), exec_register(), and exec_unregister().
int fd |
Definition at line 199 of file kern_exec.c.
Referenced by aio_aqueue(), do_fork(), do_pipe(), export_fd_to_sb(), falloc(), fdalloc(), fdunused(), fdused(), fget_unlocked(), finstall(), kern_accept(), kern_close(), kern_fcntl(), kern_ioctl(), kern_kmq_open(), kern_socketpair(), kqueue_expand(), ksem_create(), ksem_create_copyout_semid(), parse_dir_md(), pollrescan(), selrescan(), selscan(), sys_closefrom(), sys_kqueue(), sys_pdfork(), sys_posix_openpt(), sys_sctp_peeloff(), sys_shm_open(), sys_socket(), and unp_internalize().
|
static |
Definition at line 130 of file kern_exec.c.
Referenced by exec_new_vmspace().
u_long ps_arg_cache_limit = PAGE_SIZE / 16 |
Definition at line 121 of file kern_exec.c.
Referenced by do_execve(), and sysctl_kern_proc_args().
struct __mac_execve_args sys_fexecve |