FreeBSD kernel kern code
|
#include <sys/cdefs.h>
#include "opt_capsicum.h"
#include "opt_compat.h"
#include "opt_core.h"
#include <sys/param.h>
#include <sys/capability.h>
#include <sys/exec.h>
#include <sys/fcntl.h>
#include <sys/filedesc.h>
#include <sys/imgact.h>
#include <sys/imgact_elf.h>
#include <sys/kernel.h>
#include <sys/lock.h>
#include <sys/malloc.h>
#include <sys/mount.h>
#include <sys/mutex.h>
#include <sys/mman.h>
#include <sys/namei.h>
#include <sys/pioctl.h>
#include <sys/proc.h>
#include <sys/procfs.h>
#include <sys/racct.h>
#include <sys/resourcevar.h>
#include <sys/sbuf.h>
#include <sys/sf_buf.h>
#include <sys/smp.h>
#include <sys/systm.h>
#include <sys/signalvar.h>
#include <sys/stat.h>
#include <sys/sx.h>
#include <sys/syscall.h>
#include <sys/sysctl.h>
#include <sys/sysent.h>
#include <sys/vnode.h>
#include <sys/syslog.h>
#include <sys/eventhandler.h>
#include <sys/user.h>
#include <net/zlib.h>
#include <vm/vm.h>
#include <vm/vm_kern.h>
#include <vm/vm_param.h>
#include <vm/pmap.h>
#include <vm/vm_map.h>
#include <vm/vm_object.h>
#include <vm/vm_extern.h>
#include <machine/elf.h>
#include <machine/md_var.h>
Go to the source code of this file.
Data Structures | |
struct | phdr_closure |
struct | sseg_closure |
struct | note_info |
struct | sbuf_drain_core_params |
Macros | |
#define | ELF_NOTE_ROUNDSIZE 4 |
#define | OLD_EI_BRAND 8 |
#define | CORE_BUF_SIZE (16 * 1024) |
#define | trunc_page_ps(va, ps) ((va) & ~(ps - 1)) |
#define | round_page_ps(va, ps) (((va) + (ps - 1)) & ~(ps - 1)) |
#define | aligned(a, t) (trunc_page_ps((u_long)(a), sizeof(t)) == (u_long)(a)) |
#define | suword __CONCAT(suword, __ELF_WORD_SIZE) |
#define | ELF_KERN_PROC_MASK 0 |
Typedefs | |
typedef void(* | segment_callback) (vm_map_entry_t, void *) |
typedef void(* | outfunc_t) (void *, struct sbuf *, size_t *) |
typedef prstatus_t | elf_prstatus_t |
typedef prpsinfo_t | elf_prpsinfo_t |
typedef prfpregset_t | elf_prfpregset_t |
typedef prfpregset_t | elf_fpregset_t |
typedef gregset_t | elf_gregset_t |
typedef thrmisc_t | elf_thrmisc_t |
typedef struct kinfo_proc | elf_kinfo_proc_t |
typedef vm_offset_t | elf_ps_strings_t |
Functions | |
__FBSDID ("$BSDSUniX$") | |
static int __elfN() | check_header (const Elf_Ehdr *hdr) |
static Elf_Brandinfo *__elfN() | get_brandinfo (struct image_params *imgp, const char *interp, int interp_name_len, int32_t *osrel) |
static int __elfN() | load_file (struct proc *p, const char *file, u_long *addr, u_long *entry, size_t pagesize) |
static int __elfN() | load_section (struct vmspace *vmspace, vm_object_t object, vm_offset_t offset, caddr_t vmaddr, size_t memsz, size_t filsz, vm_prot_t prot, size_t pagesize) |
static int | __CONCAT (exec_, __elfN(imgact)) |
static boolean_t __elfN() | bsdsunix_trans_osrel (const Elf_Note *note, int32_t *osrel) |
Elf_Brandnote | __elfN (kbsdsunix_brandnote) |
static boolean_t | kbsdsunix_trans_osrel (const Elf_Note *note, int32_t *osrel) |
int __elfN() | insert_brand_entry (Elf_Brandinfo *entry) |
int __elfN() | remove_brand_entry (Elf_Brandinfo *entry) |
int __elfN() | brand_inuse (Elf_Brandinfo *entry) |
static int __elfN() | map_partial (vm_map_t map, vm_object_t object, vm_ooffset_t offset, vm_offset_t start, vm_offset_t end, vm_prot_t prot) |
static int __elfN() | map_insert (vm_map_t map, vm_object_t object, vm_ooffset_t offset, vm_offset_t start, vm_offset_t end, vm_prot_t prot, int cow) |
int __elfN() | bsdsunix_fixup (register_t **stack_base, struct image_params *imgp) |
TAILQ_HEAD (note_info_list, note_info) | |
static void | cb_put_phdr (vm_map_entry_t, void *) |
static void | cb_size_segment (vm_map_entry_t, void *) |
static void | each_writable_segment (struct thread *, segment_callback, void *) |
static int __elfN() | corehdr (struct thread *, struct vnode *, struct ucred *, int, void *, size_t, struct note_info_list *, size_t, gzFile) |
static void __elfN() | prepare_notes (struct thread *, struct note_info_list *, size_t *) |
static void __elfN() | puthdr (struct thread *, void *, size_t, int, size_t) |
static void __elfN() | putnote (struct note_info *, struct sbuf *) |
static size_t | register_note (struct note_info_list *, int, outfunc_t, void *) |
static int | sbuf_drain_core_output (void *, const char *, int) |
static int | sbuf_drain_count (void *arg, const char *data, int len) |
static void __elfN() | note_fpregset (void *, struct sbuf *, size_t *) |
static void __elfN() | note_prpsinfo (void *, struct sbuf *, size_t *) |
static void __elfN() | note_prstatus (void *, struct sbuf *, size_t *) |
static void __elfN() | note_threadmd (void *, struct sbuf *, size_t *) |
static void __elfN() | note_thrmisc (void *, struct sbuf *, size_t *) |
static void __elfN() | note_procstat_auxv (void *, struct sbuf *, size_t *) |
static void __elfN() | note_procstat_proc (void *, struct sbuf *, size_t *) |
static void __elfN() | note_procstat_psstrings (void *, struct sbuf *, size_t *) |
static void | note_procstat_files (void *, struct sbuf *, size_t *) |
static void | note_procstat_groups (void *, struct sbuf *, size_t *) |
static void | note_procstat_osrel (void *, struct sbuf *, size_t *) |
static void | note_procstat_rlimit (void *, struct sbuf *, size_t *) |
static void | note_procstat_umask (void *, struct sbuf *, size_t *) |
static void | note_procstat_vmmap (void *, struct sbuf *, size_t *) |
static int | core_output (struct vnode *vp, void *base, size_t len, off_t offset, struct ucred *active_cred, struct ucred *file_cred, struct thread *td, char *core_buf, gzFile gzfile) |
static int | sbuf_drain_count (void *arg, const char *data __unused, int len) |
int __elfN() | coredump (struct thread *td, struct vnode *vp, off_t limit, int flags) |
static boolean_t __elfN() | parse_notes (struct image_params *imgp, Elf_Brandnote *checknote, int32_t *osrel, const Elf_Phdr *pnote) |
static boolean_t __elfN() | check_note (struct image_params *imgp, Elf_Brandnote *checknote, int32_t *osrel) |
static struct execsw | __elfN (execsw) |
EXEC_SET (__CONCAT(elf, __ELF_WORD_SIZE), __elfN(execsw)) | |
static vm_prot_t __elfN() | trans_prot (Elf_Word flags) |
static Elf_Word __elfN() | untrans_prot (vm_prot_t prot) |
Variables | |
static const char | GNU_ABI_VENDOR [] = "GNU" |
static int | GNU_KBSDSUNIX_ABI_DESC = 3 |
#define aligned | ( | a, | |
t | |||
) | (trunc_page_ps((u_long)(a), sizeof(t)) == (u_long)(a)) |
Referenced by load_file(), and parse_notes().
#define CORE_BUF_SIZE (16 * 1024) |
Referenced by coredump(), and corehdr().
#define ELF_KERN_PROC_MASK 0 |
Definition at line 1637 of file imgact_elf.c.
Referenced by note_procstat_proc().
#define ELF_NOTE_ROUNDSIZE 4 |
Definition at line 85 of file imgact_elf.c.
Referenced by bsdsunix_trans_osrel(), kbsdsunix_trans_osrel(), parse_notes(), puthdr(), putnote(), and register_note().
#define OLD_EI_BRAND 8 |
Definition at line 86 of file imgact_elf.c.
Referenced by get_brandinfo().
#define round_page_ps | ( | va, | |
ps | |||
) | (((va) + (ps - 1)) & ~(ps - 1)) |
Referenced by load_section().
#define suword __CONCAT(suword, __ELF_WORD_SIZE) |
Definition at line 978 of file imgact_elf.c.
Referenced by aiocb_store_aiocb(), aiocb_store_error(), aiocb_store_kernelinfo(), aiocb_store_status(), bsdsunix_fixup(), do_execve(), exec_copyout_strings(), and start_init().
#define trunc_page_ps | ( | va, | |
ps | |||
) | ((va) & ~(ps - 1)) |
Referenced by load_section().
typedef prfpregset_t elf_fpregset_t |
Definition at line 1634 of file imgact_elf.c.
typedef gregset_t elf_gregset_t |
Definition at line 1635 of file imgact_elf.c.
typedef struct kinfo_proc elf_kinfo_proc_t |
Definition at line 1638 of file imgact_elf.c.
typedef prfpregset_t elf_prfpregset_t |
Definition at line 1633 of file imgact_elf.c.
typedef prpsinfo_t elf_prpsinfo_t |
Definition at line 1632 of file imgact_elf.c.
typedef prstatus_t elf_prstatus_t |
Definition at line 1631 of file imgact_elf.c.
typedef vm_offset_t elf_ps_strings_t |
Definition at line 1639 of file imgact_elf.c.
typedef thrmisc_t elf_thrmisc_t |
Definition at line 1636 of file imgact_elf.c.
typedef void(* outfunc_t) (void *, struct sbuf *, size_t *) |
Definition at line 1047 of file imgact_elf.c.
typedef void(* segment_callback) (vm_map_entry_t, void *) |
Definition at line 1033 of file imgact_elf.c.
|
static |
Definition at line 96 of file imgact_elf.c.
Elf_Brandnote __elfN | ( | kbsdsunix_brandnote | ) |
Referenced by cb_put_phdr(), check_note(), coredump(), corehdr(), get_brandinfo(), load_file(), load_section(), map_insert(), note_threadmd(), and prepare_notes().
__FBSDID | ( | "$BSDSUniX$" | ) |
int __elfN() brand_inuse | ( | Elf_Brandinfo * | entry | ) |
Definition at line 242 of file imgact_elf.c.
References allproc_lock.
int __elfN() bsdsunix_fixup | ( | register_t ** | stack_base, |
struct image_params * | imgp | ||
) |
Definition at line 981 of file imgact_elf.c.
References free(), mp_ncpus, and suword.
|
static |
Definition at line 161 of file imgact_elf.c.
References ELF_NOTE_ROUNDSIZE.
|
static |
Definition at line 1303 of file imgact_elf.c.
References __elfN(), phdr_closure::offset, phdr_closure::phdr, and untrans_prot().
Referenced by puthdr().
|
static |
Definition at line 1329 of file imgact_elf.c.
References sseg_closure::count, and sseg_closure::size.
Referenced by coredump().
|
static |
Definition at line 328 of file imgact_elf.c.
Referenced by load_file().
|
static |
Definition at line 2027 of file imgact_elf.c.
References __elfN(), and parse_notes().
Referenced by get_brandinfo().
|
static |
Definition at line 1093 of file imgact_elf.c.
References panic(), and vn_rdwr_inchunks().
Referenced by coredump().
int __elfN() coredump | ( | struct thread * | td, |
struct vnode * | vp, | ||
off_t | limit, | ||
int | flags | ||
) |
Definition at line 1178 of file imgact_elf.c.
References __elfN(), cb_size_segment(), CORE_BUF_SIZE, core_output(), corehdr(), sseg_closure::count, each_writable_segment(), free(), gz_open(), gzclose(), log(), malloc(), prepare_notes(), racct_add(), and sseg_closure::size.
Referenced by doadump().
|
static |
Definition at line 1411 of file imgact_elf.c.
References __elfN(), sbuf_drain_core_params::active_cred, CORE_BUF_SIZE, sbuf_drain_core_params::file_cred, sbuf_drain_core_params::offset, puthdr(), putnote(), sbuf_bcat(), sbuf_delete(), sbuf_drain_core_output(), sbuf_end_section(), sbuf_finish(), sbuf_new(), sbuf_set_drain(), sbuf_start_section(), sbuf_drain_core_params::td, and sbuf_drain_core_params::vp.
Referenced by coredump().
|
static |
Definition at line 1345 of file imgact_elf.c.
Referenced by coredump(), and puthdr().
EXEC_SET | ( | __CONCAT(elf, __ELF_WORD_SIZE) | , |
__elfN(execsw) | |||
) |
|
static |
Definition at line 260 of file imgact_elf.c.
References __elfN(), check_note(), and OLD_EI_BRAND.
int __elfN() insert_brand_entry | ( | Elf_Brandinfo * | entry | ) |
Definition at line 207 of file imgact_elf.c.
References printf().
|
static |
Definition at line 185 of file imgact_elf.c.
References ELF_NOTE_ROUNDSIZE.
|
static |
Definition at line 584 of file imgact_elf.c.
References __elfN(), aligned, check_header(), exec_check_permissions(), exec_map_first_page(), exec_unmap_first_page(), free(), load_section(), malloc(), namei(), NDFREE(), trans_prot(), and vput().
|
static |
Definition at line 460 of file imgact_elf.c.
References __elfN(), map_insert(), round_page_ps, trunc_page_ps, and uprintf().
Referenced by load_file().
|
static |
Definition at line 392 of file imgact_elf.c.
References __elfN(), map_partial(), and start.
Referenced by load_section().
|
static |
Definition at line 357 of file imgact_elf.c.
Referenced by map_insert().
|
static |
Definition at line 1697 of file imgact_elf.c.
References free(), malloc(), and sbuf_bcat().
Referenced by prepare_notes().
|
static |
Definition at line 1947 of file imgact_elf.c.
References proc_getauxv(), sbuf_bcat(), sbuf_delete(), sbuf_drain_count(), sbuf_finish(), sbuf_new(), and sbuf_set_drain().
Referenced by prepare_notes().
|
static |
Definition at line 1789 of file imgact_elf.c.
References kern_proc_filedesc_out(), sbuf_bcat(), sbuf_delete(), sbuf_drain_count(), sbuf_finish(), sbuf_new(), and sbuf_set_drain().
Referenced by prepare_notes().
|
static |
Definition at line 1845 of file imgact_elf.c.
References sbuf_bcat().
Referenced by prepare_notes().
|
static |
Definition at line 1905 of file imgact_elf.c.
References sbuf_bcat().
Referenced by prepare_notes().
|
static |
Definition at line 1764 of file imgact_elf.c.
References ELF_KERN_PROC_MASK, kern_proc_out(), and sbuf_bcat().
Referenced by prepare_notes().
|
static |
Definition at line 1923 of file imgact_elf.c.
References sbuf_bcat().
Referenced by prepare_notes().
|
static |
Definition at line 1882 of file imgact_elf.c.
References lim_rlimit(), and sbuf_bcat().
Referenced by prepare_notes().
|
static |
Definition at line 1864 of file imgact_elf.c.
References sbuf_bcat().
Referenced by prepare_notes().
|
static |
Definition at line 1819 of file imgact_elf.c.
References kern_proc_vmmap_out(), sbuf_bcat(), sbuf_delete(), sbuf_drain_count(), sbuf_finish(), sbuf_new(), and sbuf_set_drain().
Referenced by prepare_notes().
|
static |
Definition at line 1643 of file imgact_elf.c.
References free(), malloc(), and sbuf_bcat().
Referenced by prepare_notes().
|
static |
Definition at line 1669 of file imgact_elf.c.
References free(), malloc(), and sbuf_bcat().
Referenced by prepare_notes().
|
static |
Definition at line 1738 of file imgact_elf.c.
References __elfN(), buf, free(), malloc(), and sbuf_bcat().
Referenced by prepare_notes().
|
static |
Definition at line 1718 of file imgact_elf.c.
References sbuf_bcat().
Referenced by prepare_notes().
|
static |
Definition at line 1975 of file imgact_elf.c.
References aligned, and ELF_NOTE_ROUNDSIZE.
Referenced by check_note().
|
static |
Definition at line 1447 of file imgact_elf.c.
References __elfN(), note_fpregset(), note_procstat_auxv(), note_procstat_files(), note_procstat_groups(), note_procstat_osrel(), note_procstat_proc(), note_procstat_psstrings(), note_procstat_rlimit(), note_procstat_umask(), note_procstat_vmmap(), note_prpsinfo(), note_prstatus(), note_threadmd(), note_thrmisc(), and register_note().
Referenced by coredump().
|
static |
Definition at line 1505 of file imgact_elf.c.
References cb_put_phdr(), each_writable_segment(), ELF_NOTE_ROUNDSIZE, phdr_closure::offset, and phdr_closure::phdr.
Referenced by corehdr().
Definition at line 1589 of file imgact_elf.c.
References ELF_NOTE_ROUNDSIZE, note_info::outarg, note_info::outfunc, note_info::outsize, sbuf_bcat(), sbuf_end_section(), sbuf_start_section(), and note_info::type.
Referenced by corehdr().
|
static |
Definition at line 1564 of file imgact_elf.c.
References ELF_NOTE_ROUNDSIZE, malloc(), note_info::outarg, note_info::outfunc, note_info::outsize, and note_info::type.
Referenced by prepare_notes().
int __elfN() remove_brand_entry | ( | Elf_Brandinfo * | entry | ) |
Definition at line 226 of file imgact_elf.c.
|
static |
Definition at line 1128 of file imgact_elf.c.
References sbuf_drain_core_params::active_cred, sbuf_drain_core_params::file_cred, sbuf_drain_core_params::offset, sbuf_drain_core_params::td, vn_rdwr_inchunks(), and sbuf_drain_core_params::vp.
Referenced by corehdr().
|
static |
Referenced by note_procstat_auxv(), note_procstat_files(), and note_procstat_vmmap().
|
static |
Definition at line 1168 of file imgact_elf.c.
TAILQ_HEAD | ( | note_info_list | , |
note_info | |||
) |
|
static |
Definition at line 2108 of file imgact_elf.c.
Referenced by load_file().
|
static |
Definition at line 2129 of file imgact_elf.c.
Referenced by cb_put_phdr().
|
static |
Definition at line 172 of file imgact_elf.c.
|
static |
Definition at line 173 of file imgact_elf.c.