FreeBSD kernel kern code
|
#include <sys/cdefs.h>
#include <sys/param.h>
#include <sys/ctype.h>
#include <sys/exec.h>
#include <sys/imgact.h>
#include <sys/imgact_binmisc.h>
#include <sys/kernel.h>
#include <sys/lock.h>
#include <sys/malloc.h>
#include <sys/mutex.h>
#include <sys/sbuf.h>
#include <sys/sysctl.h>
#include <sys/sx.h>
#include <machine/atomic.h>
Go to the source code of this file.
Data Structures | |
struct | imgact_binmisc_entry |
Macros | |
#define | IBC_ADD 1 /* Add given entry. */ |
#define | IBC_REMOVE 2 /* Remove entry for a given name. */ |
#define | IBC_DISABLE 3 /* Disable entry for a given name. */ |
#define | IBC_ENABLE 4 /* Enable entry for a given name. */ |
#define | IBC_LOOKUP 5 /* Lookup and return entry for given name. */ |
#define | IBC_LIST 6 /* Get a snapshot of the interpretor list. */ |
#define | ISM_POUND '#' /* "##" is the escape sequence for single #. */ |
#define | ISM_OLD_ARGV0 'a' /* "#a" is replaced with the old argv0. */ |
#define | INTERP_LIST_WLOCK() sx_xlock(&interp_list_sx) |
#define | INTERP_LIST_RLOCK() sx_slock(&interp_list_sx) |
#define | INTERP_LIST_WUNLOCK() sx_xunlock(&interp_list_sx) |
#define | INTERP_LIST_RUNLOCK() sx_sunlock(&interp_list_sx) |
#define | INTERP_LIST_LOCK_INIT() sx_init(&interp_list_sx, KMOD_NAME) |
#define | INTERP_LIST_LOCK_DESTROY() sx_destroy(&interp_list_sx) |
#define | INTERP_LIST_ASSERT_LOCKED() sx_assert(&interp_list_sx, SA_LOCKED) |
Typedefs | |
typedef struct imgact_binmisc_entry | imgact_binmisc_entry_t |
Functions | |
__FBSDID ("$FreeBSD$") | |
MALLOC_DEFINE (M_BINMISC, KMOD_NAME, "misc binary image activator") | |
static | SLIST_HEAD (imgact_binmisc_entry) |
static imgact_binmisc_entry_t * | imgact_binmisc_new_entry (ximgact_binmisc_entry_t *xbe, ssize_t interp_offset, int argv0_cnt) |
static void | imgact_binmisc_destroy_entry (imgact_binmisc_entry_t *ibe) |
static imgact_binmisc_entry_t * | imgact_binmisc_find_entry (char *name) |
static int | imgact_binmisc_add_entry (ximgact_binmisc_entry_t *xbe) |
static int | imgact_binmisc_remove_entry (char *name) |
static int | imgact_binmisc_disable_entry (char *name) |
static int | imgact_binmisc_enable_entry (char *name) |
static int | imgact_binmisc_populate_xbe (ximgact_binmisc_entry_t *xbe, imgact_binmisc_entry_t *ibe) |
static int | imgact_binmisc_lookup_entry (char *name, ximgact_binmisc_entry_t *xbe) |
static int | imgact_binmisc_get_all_entries (struct sysctl_req *req) |
static int | sysctl_kern_binmisc (SYSCTL_HANDLER_ARGS) |
SYSCTL_NODE (_kern, OID_AUTO, binmisc, CTLFLAG_RW|CTLFLAG_MPSAFE, 0, "Image activator for miscellaneous binaries") | |
SYSCTL_PROC (_kern_binmisc, OID_AUTO, add, CTLFLAG_MPSAFE|CTLTYPE_STRUCT|CTLFLAG_WR, NULL, IBC_ADD, sysctl_kern_binmisc, "S,ximgact_binmisc_entry", "Add an activator entry") | |
SYSCTL_PROC (_kern_binmisc, OID_AUTO, remove, CTLFLAG_MPSAFE|CTLTYPE_STRUCT|CTLFLAG_WR, NULL, IBC_REMOVE, sysctl_kern_binmisc, "S,ximgact_binmisc_entry", "Remove an activator entry") | |
SYSCTL_PROC (_kern_binmisc, OID_AUTO, disable, CTLFLAG_MPSAFE|CTLTYPE_STRUCT|CTLFLAG_WR, NULL, IBC_DISABLE, sysctl_kern_binmisc, "S,ximgact_binmisc_entry", "Disable an activator entry") | |
SYSCTL_PROC (_kern_binmisc, OID_AUTO, enable, CTLFLAG_MPSAFE|CTLTYPE_STRUCT|CTLFLAG_WR, NULL, IBC_ENABLE, sysctl_kern_binmisc, "S,ximgact_binmisc_entry", "Enable an activator entry") | |
SYSCTL_PROC (_kern_binmisc, OID_AUTO, lookup, CTLFLAG_MPSAFE|CTLTYPE_STRUCT|CTLFLAG_RW|CTLFLAG_ANYBODY, NULL, IBC_LOOKUP, sysctl_kern_binmisc, "S,ximgact_binmisc_entry", "Lookup an activator entry") | |
SYSCTL_PROC (_kern_binmisc, OID_AUTO, list, CTLFLAG_MPSAFE|CTLTYPE_STRUCT|CTLFLAG_RD|CTLFLAG_ANYBODY, NULL, IBC_LIST, sysctl_kern_binmisc, "S,ximgact_binmisc_entry", "Get snapshot of all the activator entries") | |
static imgact_binmisc_entry_t * | imgact_binmisc_find_interpreter (const char *image_header) |
static int | imgact_binmisc_exec (struct image_params *imgp) |
static void | imgact_binmisc_init (void *arg) |
static void | imgact_binmisc_fini (void *arg) |
SYSINIT (imgact_binmisc, SI_SUB_EXEC, SI_ORDER_MIDDLE, imgact_binmisc_init, NULL) | |
SYSUNINIT (imgact_binmisc, SI_SUB_EXEC, SI_ORDER_MIDDLE, imgact_binmisc_fini, NULL) | |
EXEC_SET (imgact_binmisc, imgact_binmisc_execsw) | |
Variables | |
static struct execsw | imgact_binmisc_execsw |
#define IBC_ADD 1 /* Add given entry. */ |
Definition at line 78 of file imgact_binmisc.c.
#define IBC_DISABLE 3 /* Disable entry for a given name. */ |
Definition at line 80 of file imgact_binmisc.c.
#define IBC_ENABLE 4 /* Enable entry for a given name. */ |
Definition at line 81 of file imgact_binmisc.c.
#define IBC_LIST 6 /* Get a snapshot of the interpretor list. */ |
Definition at line 83 of file imgact_binmisc.c.
#define IBC_LOOKUP 5 /* Lookup and return entry for given name. */ |
Definition at line 82 of file imgact_binmisc.c.
#define IBC_REMOVE 2 /* Remove entry for a given name. */ |
Definition at line 79 of file imgact_binmisc.c.
#define INTERP_LIST_ASSERT_LOCKED | ( | ) | sx_assert(&interp_list_sx, SA_LOCKED) |
#define INTERP_LIST_LOCK_DESTROY | ( | ) | sx_destroy(&interp_list_sx) |
#define INTERP_LIST_LOCK_INIT | ( | ) | sx_init(&interp_list_sx, KMOD_NAME) |
#define INTERP_LIST_RLOCK | ( | ) | sx_slock(&interp_list_sx) |
#define INTERP_LIST_RUNLOCK | ( | ) | sx_sunlock(&interp_list_sx) |
#define INTERP_LIST_WLOCK | ( | ) | sx_xlock(&interp_list_sx) |
#define INTERP_LIST_WUNLOCK | ( | ) | sx_xunlock(&interp_list_sx) |
#define ISM_OLD_ARGV0 'a' /* "#a" is replaced with the old argv0. */ |
Definition at line 91 of file imgact_binmisc.c.
#define ISM_POUND '#' /* "##" is the escape sequence for single #. */ |
Definition at line 90 of file imgact_binmisc.c.
typedef struct imgact_binmisc_entry imgact_binmisc_entry_t |
Miscellaneous binary interpreter image activator.
If the given target executable's header matches 'xbe_magic' field in the 'interpreter_list' then it will use the user-level interpreter specified in the 'xbe_interpreter' field to execute the binary. The 'xbe_magic' field may be adjusted to a given offset using the value in the 'xbe_moffset' field and bits of the header may be masked using the 'xbe_mask' field. The 'interpreter_list' entries are managed using sysctl(3) as described in the <sys/imgact_binmisc.h> file.
__FBSDID | ( | "$FreeBSD$" | ) |
EXEC_SET | ( | imgact_binmisc | , |
imgact_binmisc_execsw | |||
) |
|
static |
Definition at line 230 of file imgact_binmisc.c.
References imgact_binmisc_find_entry(), imgact_binmisc_new_entry(), INTERP_LIST_WLOCK, INTERP_LIST_WUNLOCK, ISM_OLD_ARGV0, and ISM_POUND.
Referenced by sysctl_kern_binmisc().
|
static |
Definition at line 190 of file imgact_binmisc.c.
References free().
Referenced by imgact_binmisc_fini(), and imgact_binmisc_remove_entry().
|
static |
Definition at line 318 of file imgact_binmisc.c.
References imgact_binmisc_find_entry(), INTERP_LIST_WLOCK, INTERP_LIST_WUNLOCK, and name.
Referenced by sysctl_kern_binmisc().
|
static |
Definition at line 339 of file imgact_binmisc.c.
References imgact_binmisc_find_entry(), INTERP_LIST_WLOCK, INTERP_LIST_WUNLOCK, and name.
Referenced by sysctl_kern_binmisc().
|
static |
Definition at line 589 of file imgact_binmisc.c.
References exec_args_adjust_args(), imgact_binmisc_find_interpreter(), INTERP_LIST_RLOCK, INTERP_LIST_RUNLOCK, ISM_OLD_ARGV0, ISM_POUND, sbuf_data(), sbuf_delete(), sbuf_finish(), and sbuf_printf().
|
static |
Definition at line 211 of file imgact_binmisc.c.
References INTERP_LIST_ASSERT_LOCKED, and name.
Referenced by imgact_binmisc_add_entry(), imgact_binmisc_disable_entry(), imgact_binmisc_enable_entry(), imgact_binmisc_lookup_entry(), and imgact_binmisc_remove_entry().
|
static |
Definition at line 556 of file imgact_binmisc.c.
References INTERP_LIST_ASSERT_LOCKED.
Referenced by imgact_binmisc_exec().
|
static |
Definition at line 717 of file imgact_binmisc.c.
References imgact_binmisc_destroy_entry(), INTERP_LIST_LOCK_DESTROY, INTERP_LIST_WLOCK, and INTERP_LIST_WUNLOCK.
|
static |
Definition at line 408 of file imgact_binmisc.c.
References count, free(), imgact_binmisc_populate_xbe(), INTERP_LIST_RLOCK, INTERP_LIST_RUNLOCK, and malloc().
Referenced by sysctl_kern_binmisc().
|
static |
Definition at line 710 of file imgact_binmisc.c.
References INTERP_LIST_LOCK_INIT.
|
static |
Definition at line 387 of file imgact_binmisc.c.
References imgact_binmisc_find_entry(), imgact_binmisc_populate_xbe(), INTERP_LIST_RLOCK, INTERP_LIST_RUNLOCK, and name.
Referenced by sysctl_kern_binmisc().
|
static |
Definition at line 159 of file imgact_binmisc.c.
References malloc().
Referenced by imgact_binmisc_add_entry().
|
static |
Definition at line 356 of file imgact_binmisc.c.
References INTERP_LIST_ASSERT_LOCKED.
Referenced by imgact_binmisc_get_all_entries(), and imgact_binmisc_lookup_entry().
|
static |
Definition at line 295 of file imgact_binmisc.c.
References imgact_binmisc_destroy_entry(), imgact_binmisc_find_entry(), INTERP_LIST_WLOCK, INTERP_LIST_WUNLOCK, and name.
Referenced by sysctl_kern_binmisc().
MALLOC_DEFINE | ( | M_BINMISC | , |
KMOD_NAME | , | ||
"misc binary image activator" | |||
) |
|
static |
Definition at line 96 of file imgact_binmisc.c.
|
static |
Definition at line 438 of file imgact_binmisc.c.
References IBC_ADD, IBC_DISABLE, IBC_ENABLE, IBC_LIST, IBC_LOOKUP, IBC_REMOVE, imgact_binmisc_add_entry(), imgact_binmisc_disable_entry(), imgact_binmisc_enable_entry(), imgact_binmisc_get_all_entries(), imgact_binmisc_lookup_entry(), and imgact_binmisc_remove_entry().
SYSCTL_NODE | ( | _kern | , |
OID_AUTO | , | ||
binmisc | , | ||
CTLFLAG_RW| | CTLFLAG_MPSAFE, | ||
0 | , | ||
"Image activator for miscellaneous binaries" | |||
) |
SYSCTL_PROC | ( | _kern_binmisc | , |
OID_AUTO | , | ||
add | , | ||
CTLFLAG_MPSAFE|CTLTYPE_STRUCT| | CTLFLAG_WR, | ||
NULL | , | ||
IBC_ADD | , | ||
sysctl_kern_binmisc | , | ||
" | S, | ||
ximgact_binmisc_entry" | , | ||
"Add an activator entry" | |||
) |
SYSCTL_PROC | ( | _kern_binmisc | , |
OID_AUTO | , | ||
disable | , | ||
CTLFLAG_MPSAFE|CTLTYPE_STRUCT| | CTLFLAG_WR, | ||
NULL | , | ||
IBC_DISABLE | , | ||
sysctl_kern_binmisc | , | ||
" | S, | ||
ximgact_binmisc_entry" | , | ||
"Disable an activator entry" | |||
) |
SYSCTL_PROC | ( | _kern_binmisc | , |
OID_AUTO | , | ||
enable | , | ||
CTLFLAG_MPSAFE|CTLTYPE_STRUCT| | CTLFLAG_WR, | ||
NULL | , | ||
IBC_ENABLE | , | ||
sysctl_kern_binmisc | , | ||
" | S, | ||
ximgact_binmisc_entry" | , | ||
"Enable an activator entry" | |||
) |
SYSCTL_PROC | ( | _kern_binmisc | , |
OID_AUTO | , | ||
list | , | ||
CTLFLAG_MPSAFE|CTLTYPE_STRUCT|CTLFLAG_RD| | CTLFLAG_ANYBODY, | ||
NULL | , | ||
IBC_LIST | , | ||
sysctl_kern_binmisc | , | ||
" | S, | ||
ximgact_binmisc_entry" | , | ||
"Get snapshot of all the activator entries" | |||
) |
SYSCTL_PROC | ( | _kern_binmisc | , |
OID_AUTO | , | ||
lookup | , | ||
CTLFLAG_MPSAFE|CTLTYPE_STRUCT|CTLFLAG_RW| | CTLFLAG_ANYBODY, | ||
NULL | , | ||
IBC_LOOKUP | , | ||
sysctl_kern_binmisc | , | ||
" | S, | ||
ximgact_binmisc_entry" | , | ||
"Lookup an activator entry" | |||
) |
SYSCTL_PROC | ( | _kern_binmisc | , |
OID_AUTO | , | ||
remove | , | ||
CTLFLAG_MPSAFE|CTLTYPE_STRUCT| | CTLFLAG_WR, | ||
NULL | , | ||
IBC_REMOVE | , | ||
sysctl_kern_binmisc | , | ||
" | S, | ||
ximgact_binmisc_entry" | , | ||
"Remove an activator entry" | |||
) |
SYSINIT | ( | imgact_binmisc | , |
SI_SUB_EXEC | , | ||
SI_ORDER_MIDDLE | , | ||
imgact_binmisc_init | , | ||
NULL | |||
) |
SYSUNINIT | ( | imgact_binmisc | , |
SI_SUB_EXEC | , | ||
SI_ORDER_MIDDLE | , | ||
imgact_binmisc_fini | , | ||
NULL | |||
) |
|
static |
Definition at line 741 of file imgact_binmisc.c.