FreeBSD kernel kern code
imgact_elf.c File Reference
#include <sys/cdefs.h>
#include "opt_capsicum.h"
#include <sys/param.h>
#include <sys/capsicum.h>
#include <sys/compressor.h>
#include <sys/exec.h>
#include <sys/fcntl.h>
#include <sys/imgact.h>
#include <sys/imgact_elf.h>
#include <sys/jail.h>
#include <sys/kernel.h>
#include <sys/lock.h>
#include <sys/malloc.h>
#include <sys/mount.h>
#include <sys/mman.h>
#include <sys/namei.h>
#include <sys/proc.h>
#include <sys/procfs.h>
#include <sys/ptrace.h>
#include <sys/racct.h>
#include <sys/reg.h>
#include <sys/resourcevar.h>
#include <sys/rwlock.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 <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>
Include dependency graph for imgact_elf.c:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  phdr_closure
 
struct  note_info
 
struct  brandnote_cb_arg
 
struct  fctl_cb_arg
 

Macros

#define ELF_NOTE_ROUNDSIZE   4
 
#define OLD_EI_BRAND   8
 
#define ASLR_NODE_OID   __CONCAT(__CONCAT(_kern_elf, __ELF_WORD_SIZE), _aslr)
 
#define aligned(a, t)   (rounddown2((u_long)(a), sizeof(t)) == (u_long)(a))
 
#define ET_DYN_ADDR_RAND   1
 
#define elf_suword   __CONCAT(suword, __ELF_WORD_SIZE)
 
#define ELF_KERN_PROC_MASK   0
 

Typedefs

typedef void(* segment_callback) (vm_map_entry_t, void *)
 
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 ("$FreeBSD$")
 
static int __elfN() check_header (const Elf_Ehdr *hdr)
 
static Elf_Brandinfo *__elfN() get_brandinfo (struct image_params *imgp, const char *interp, int32_t *osrel, uint32_t *fctl0)
 
static int __elfN() load_file (struct proc *p, const char *file, u_long *addr, u_long *entry)
 
static int __elfN() load_section (struct image_params *imgp, vm_ooffset_t offset, caddr_t vmaddr, size_t memsz, size_t filsz, vm_prot_t prot)
 
static int __CONCAT (exec_, __elfN(imgact))
 
 SYSCTL_PROC (__CONCAT(_kern_elf, __ELF_WORD_SIZE), OID_AUTO, pie_base, CTLTYPE_ULONG|CTLFLAG_MPSAFE|CTLFLAG_RW, NULL, 0, sysctl_pie_base, "LU", "PIE load base without randomization")
 
 SYSCTL_NODE (__CONCAT(_kern_elf, __ELF_WORD_SIZE), OID_AUTO, aslr, CTLFLAG_RW|CTLFLAG_MPSAFE, 0, "")
 
static int __elfN (aslr_enabled)
 
 SYSCTL_INT (ASLR_NODE_OID, OID_AUTO, enable, CTLFLAG_RWTUN, &__elfN(aslr_enabled), 0, ": enable address map randomization")
 
static int __elfN (pie_aslr_enabled)
 
 SYSCTL_INT (ASLR_NODE_OID, OID_AUTO, pie_enable, CTLFLAG_RWTUN, &__elfN(pie_aslr_enabled), 0, ": enable address map randomization for PIE binaries")
 
static int __elfN (aslr_honor_sbrk)=0
 
 SYSCTL_INT (ASLR_NODE_OID, OID_AUTO, honor_sbrk, CTLFLAG_RW, &__elfN(aslr_honor_sbrk), 0, __XSTRING(__CONCAT(ELF, __ELF_WORD_SIZE)) ": assume sbrk is used")
 
static int __elfN (aslr_stack)
 
 SYSCTL_INT (ASLR_NODE_OID, OID_AUTO, stack, CTLFLAG_RWTUN, &__elfN(aslr_stack), 0, ": enable stack address randomization")
 
static int __elfN (sigfastblock)
 
 SYSCTL_INT (__CONCAT(_kern_elf, __ELF_WORD_SIZE), OID_AUTO, sigfastblock, CTLFLAG_RWTUN, &__elfN(sigfastblock), 0, "enable sigfastblock for new processes")
 
static bool __elfN (allow_wx)
 
 SYSCTL_BOOL (__CONCAT(_kern_elf, __ELF_WORD_SIZE), OID_AUTO, allow_wx, CTLFLAG_RWTUN, &__elfN(allow_wx), 0, "Allow pages to be mapped simultaneously writable and executable")
 
Elf_Brandnote __elfN (freebsd_brandnote)
 
static bool __elfN() freebsd_trans_osrel (const Elf_Note *note, int32_t *osrel)
 
Elf_Brandnote __elfN (kfreebsd_brandnote)
 
static bool kfreebsd_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)
 
bool __elfN() brand_inuse (Elf_Brandinfo *entry)
 
static bool __elfN() phdr_in_zero_page (const Elf_Ehdr *hdr)
 
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 (struct image_params *imgp, 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)
 
static int __elfN() load_sections (struct image_params *imgp, const Elf_Ehdr *hdr, const Elf_Phdr *phdr, u_long rbase, u_long *base_addrp)
 
static int __CONCAT (rnd_, __elfN(base))
 
static int __elfN() enforce_limits (struct image_params *imgp, const Elf_Ehdr *hdr, const Elf_Phdr *phdr, u_long et_dyn_addr)
 
static int __elfN() get_interp (struct image_params *imgp, const Elf_Phdr *phdr, char **interpp, bool *free_interpp)
 
static int __elfN() load_interp (struct image_params *imgp, const Elf_Brandinfo *brand_info, const char *interp, u_long *addr, u_long *entry)
 
int __elfN() freebsd_copyout_auxargs (struct image_params *imgp, uintptr_t base)
 
int __elfN() freebsd_fixup (uintptr_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_dumpable_segment (struct thread *, segment_callback, void *, int)
 
static int __elfN() corehdr (struct coredump_params *, int, void *, size_t, struct note_info_list *, size_t, int)
 
static void __elfN() putnote (struct thread *td, struct note_info *, struct sbuf *)
 
static void __elfN() note_prpsinfo (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_ptlwpinfo (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_compressed_write (void *base, size_t len, off_t offset, void *arg)
 
int __elfN() coredump (struct thread *td, struct vnode *vp, off_t limit, int flags)
 
void __elfN() size_segments (struct thread *td, struct sseg_closure *seginfo, int flags)
 
void __elfN() prepare_notes (struct thread *td, struct note_info_list *list, size_t *sizep)
 
void __elfN() puthdr (struct thread *td, void *hdr, size_t hdrsize, int numsegs, size_t notesz, int flags)
 
static size_t __elfN() register_regset_note (struct thread *td, struct note_info_list *list, struct regset *regset, struct thread *target_td)
 
size_t __elfN() register_note (struct thread *td, struct note_info_list *list, int type, outfunc_t out, void *arg)
 
static size_t append_note_data (const void *src, void *dst, size_t len)
 
size_t __elfN() populate_note (int type, void *src, void *dst, size_t size, void **descp)
 
static bool __elfN() get_prstatus (struct regset *rs, struct thread *td, void *buf, size_t *sizep)
 
static bool __elfN() set_prstatus (struct regset *rs, struct thread *td, void *buf, size_t size)
 
static struct regset __elfN (regset_prstatus)
 
 ELF_REGSET (__elfN(regset_prstatus))
 
static bool __elfN() get_fpregset (struct regset *rs, struct thread *td, void *buf, size_t *sizep)
 
static bool __elfN() set_fpregset (struct regset *rs, struct thread *td, void *buf, size_t size)
 
static struct regset __elfN (regset_fpregset)
 
 ELF_REGSET (__elfN(regset_fpregset))
 
static size_t __elfN() prepare_register_notes (struct thread *td, struct note_info_list *list, struct thread *target_td)
 
static bool __elfN() parse_notes (struct image_params *imgp, Elf_Note *checknote, const char *note_vendor, const Elf_Phdr *pnote, bool(*cb)(const Elf_Note *, void *, bool *), void *cb_arg)
 
static bool brandnote_cb (const Elf_Note *note, void *arg0, bool *res)
 
static bool note_fctl_cb (const Elf_Note *note, void *arg0, bool *res)
 
static bool __elfN() check_note (struct image_params *imgp, Elf_Brandnote *brandnote, int32_t *osrel, bool *has_fctl0, uint32_t *fctl0)
 
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 Elf_Brandinfo * elf_brand_list [MAX_BRANDS]
 
static const char GNU_ABI_VENDOR [] = "GNU"
 
static int GNU_KFREEBSD_ABI_DESC = 3
 
int compress_user_cores
 
int compress_user_cores_level
 
static Elf_Note fctl_note
 

Macro Definition Documentation

◆ aligned

#define aligned (   a,
 
)    (rounddown2((u_long)(a), sizeof(t)) == (u_long)(a))

Definition at line 224 of file imgact_elf.c.

◆ ASLR_NODE_OID

#define ASLR_NODE_OID   __CONCAT(__CONCAT(_kern_elf, __ELF_WORD_SIZE), _aslr)

Definition at line 173 of file imgact_elf.c.

◆ ELF_KERN_PROC_MASK

#define ELF_KERN_PROC_MASK   0

Definition at line 2159 of file imgact_elf.c.

◆ ELF_NOTE_ROUNDSIZE

#define ELF_NOTE_ROUNDSIZE   4

Definition at line 86 of file imgact_elf.c.

◆ elf_suword

#define elf_suword   __CONCAT(suword, __ELF_WORD_SIZE)

Definition at line 1429 of file imgact_elf.c.

◆ ET_DYN_ADDR_RAND

#define ET_DYN_ADDR_RAND   1

Definition at line 1102 of file imgact_elf.c.

◆ OLD_EI_BRAND

#define OLD_EI_BRAND   8

Definition at line 87 of file imgact_elf.c.

Typedef Documentation

◆ elf_fpregset_t

typedef prfpregset_t elf_fpregset_t

Definition at line 2156 of file imgact_elf.c.

◆ elf_gregset_t

typedef gregset_t elf_gregset_t

Definition at line 2157 of file imgact_elf.c.

◆ elf_kinfo_proc_t

typedef struct kinfo_proc elf_kinfo_proc_t

Definition at line 2160 of file imgact_elf.c.

◆ elf_prfpregset_t

typedef prfpregset_t elf_prfpregset_t

Definition at line 2155 of file imgact_elf.c.

◆ elf_prpsinfo_t

typedef prpsinfo_t elf_prpsinfo_t

Definition at line 2154 of file imgact_elf.c.

◆ elf_prstatus_t

typedef prstatus_t elf_prstatus_t

Definition at line 2153 of file imgact_elf.c.

◆ elf_ps_strings_t

typedef vm_offset_t elf_ps_strings_t

Definition at line 2161 of file imgact_elf.c.

◆ elf_thrmisc_t

typedef thrmisc_t elf_thrmisc_t

Definition at line 2158 of file imgact_elf.c.

◆ segment_callback

typedef void(* segment_callback) (vm_map_entry_t, void *)

Definition at line 1514 of file imgact_elf.c.

Function Documentation

◆ __CONCAT() [1/2]

static int __CONCAT ( exec_  ,
__elfN(imgact)   
)
static

Definition at line 96 of file imgact_elf.c.

Referenced by __elfN().

Here is the caller graph for this function:

◆ __CONCAT() [2/2]

static int __CONCAT ( rnd_  ,
__elfN(base)   
)
static

Definition at line 891 of file imgact_elf.c.

References res, and uprintf().

Here is the call graph for this function:

◆ __elfN() [1/11]

static bool __elfN ( allow_wx  )
static

◆ __elfN() [2/11]

◆ __elfN() [3/11]

static int __elfN ( aslr_honor_sbrk  )
staticpure virtual

◆ __elfN() [4/11]

static int __elfN ( aslr_stack  )
static

◆ __elfN() [5/11]

static struct execsw __elfN ( execsw  )
static

References __CONCAT(), __ELF_WORD_SIZE, and __elfN().

Here is the call graph for this function:

◆ __elfN() [6/11]

Elf_Brandnote __elfN ( freebsd_brandnote  )

References __elfN(), and freebsd_trans_osrel().

Here is the call graph for this function:

◆ __elfN() [7/11]

Elf_Brandnote __elfN ( kfreebsd_brandnote  )

References GNU_ABI_VENDOR, and kfreebsd_trans_osrel().

Here is the call graph for this function:

◆ __elfN() [8/11]

static int __elfN ( pie_aslr_enabled  )
static

◆ __elfN() [9/11]

static struct regset __elfN ( regset_fpregset  )
static

References __elfN(), get, get_fpregset(), and set_fpregset().

Here is the call graph for this function:

◆ __elfN() [10/11]

static struct regset __elfN ( regset_prstatus  )
static

References __elfN(), get, get_prstatus(), and set_prstatus().

Here is the call graph for this function:

◆ __elfN() [11/11]

static int __elfN ( sigfastblock  )
static

◆ __FBSDID()

__FBSDID ( "$FreeBSD$"  )

◆ append_note_data()

static size_t append_note_data ( const void *  src,
void *  dst,
size_t  len 
)
static

Definition at line 2028 of file imgact_elf.c.

References ELF_NOTE_ROUNDSIZE, and src.

Referenced by populate_note().

Here is the caller graph for this function:

◆ brand_inuse()

bool __elfN() brand_inuse ( Elf_Brandinfo *  entry)

Definition at line 317 of file imgact_elf.c.

References allproc_lock.

◆ brandnote_cb()

static bool brandnote_cb ( const Elf_Note *  note,
void *  arg0,
bool *  res 
)
static

Definition at line 2754 of file imgact_elf.c.

References brandnote_cb_arg::brandnote, brandnote_cb_arg::osrel, and res.

Referenced by check_note().

Here is the caller graph for this function:

◆ cb_put_phdr()

static void cb_put_phdr ( vm_map_entry_t  entry,
void *  closure 
)
static

Definition at line 1686 of file imgact_elf.c.

References __elfN(), phdr_closure::offset, phdr_closure::phdr, and untrans_prot().

Referenced by puthdr().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ cb_size_segment()

static void cb_size_segment ( vm_map_entry_t  entry,
void *  closure 
)
static

Definition at line 1710 of file imgact_elf.c.

Referenced by size_segments().

Here is the caller graph for this function:

◆ check_header()

static int __elfN() check_header ( const Elf_Ehdr *  hdr)
static

Definition at line 486 of file imgact_elf.c.

References elf_brand_list.

Referenced by load_file().

Here is the caller graph for this function:

◆ check_note()

static bool __elfN() check_note ( struct image_params *  imgp,
Elf_Brandnote *  brandnote,
int32_t *  osrel,
bool *  has_fctl0,
uint32_t *  fctl0 
)
static

Definition at line 2806 of file imgact_elf.c.

References __elfN(), brandnote_cb_arg::brandnote, brandnote_cb(), fctl_cb_arg::fctl0, fctl_note, fctl_cb_arg::has_fctl0, note_fctl_cb(), brandnote_cb_arg::osrel, and parse_notes().

Referenced by get_brandinfo().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ core_compressed_write()

static int core_compressed_write ( void *  base,
size_t  len,
off_t  offset,
void *  arg 
)
static

Definition at line 1559 of file imgact_elf.c.

References core_write().

Referenced by coredump().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ coredump()

int __elfN() coredump ( struct thread *  td,
struct vnode *  vp,
off_t  limit,
int  flags 
)

Definition at line 1567 of file imgact_elf.c.

References __elfN(), compress_user_cores, compress_user_cores_level, compressor_fini(), compressor_flush(), compressor_init(), core_compressed_write(), core_output(), corehdr(), flags, free(), log(), malloc(), and size_segments().

Referenced by doadump().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ corehdr()

static int __elfN() corehdr ( struct coredump_params *  p,
int  numsegs,
void *  hdr,
size_t  hdrsize,
struct note_info_list *  notelst,
size_t  notesz,
int  flags 
)
static

Definition at line 1800 of file imgact_elf.c.

References __elfN(), flags, puthdr(), putnote(), sbuf_bcat(), sbuf_delete(), sbuf_drain_core_output(), sbuf_end_section(), sbuf_finish(), sbuf_new(), sbuf_set_drain(), and sbuf_start_section().

Referenced by coredump().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ each_dumpable_segment()

static void each_dumpable_segment ( struct thread *  td,
segment_callback  func,
void *  closure,
int  flags 
)
static

Definition at line 1734 of file imgact_elf.c.

References flags.

Referenced by puthdr(), and size_segments().

Here is the caller graph for this function:

◆ ELF_REGSET() [1/2]

ELF_REGSET ( __elfN(regset_fpregset)  )

◆ ELF_REGSET() [2/2]

ELF_REGSET ( __elfN(regset_prstatus)  )

◆ enforce_limits()

static int __elfN() enforce_limits ( struct image_params *  imgp,
const Elf_Ehdr *  hdr,
const Elf_Phdr *  phdr,
u_long  et_dyn_addr 
)
static

Definition at line 921 of file imgact_elf.c.

References lim_cur_proc(), maxtsiz, and uprintf().

Here is the call graph for this function:

◆ EXEC_SET()

EXEC_SET ( __CONCAT(elf, __ELF_WORD_SIZE ,
__elfN(execsw  
)

◆ freebsd_copyout_auxargs()

int __elfN() freebsd_copyout_auxargs ( struct image_params *  imgp,
uintptr_t  base 
)

Definition at line 1432 of file imgact_elf.c.

References __elfN(), free(), malloc(), and mp_ncpus.

Here is the call graph for this function:

◆ freebsd_fixup()

int __elfN() freebsd_fixup ( uintptr_t *  stack_base,
struct image_params *  imgp 
)

Definition at line 1498 of file imgact_elf.c.

References elf_suword.

◆ freebsd_trans_osrel()

static bool __elfN() freebsd_trans_osrel ( const Elf_Note *  note,
int32_t *  osrel 
)
static

Definition at line 236 of file imgact_elf.c.

References ELF_NOTE_ROUNDSIZE.

Referenced by __elfN().

Here is the caller graph for this function:

◆ get_brandinfo()

static Elf_Brandinfo *__elfN() get_brandinfo ( struct image_params *  imgp,
const char *  interp,
int32_t *  osrel,
uint32_t *  fctl0 
)
static

Definition at line 335 of file imgact_elf.c.

References __elfN(), check_note(), elf_brand_list, and OLD_EI_BRAND.

Here is the call graph for this function:

◆ get_fpregset()

static bool __elfN() get_fpregset ( struct regset *  rs,
struct thread *  td,
void *  buf,
size_t *  sizep 
)
static

Definition at line 2277 of file imgact_elf.c.

References buf.

Referenced by __elfN().

Here is the caller graph for this function:

◆ get_interp()

static int __elfN() get_interp ( struct image_params *  imgp,
const Elf_Phdr *  phdr,
char **  interpp,
bool *  free_interpp 
)
static

Definition at line 998 of file imgact_elf.c.

References free(), malloc(), uprintf(), and vn_rdwr().

Here is the call graph for this function:

◆ get_prstatus()

static bool __elfN() get_prstatus ( struct regset *  rs,
struct thread *  td,
void *  buf,
size_t *  sizep 
)
static

Definition at line 2226 of file imgact_elf.c.

References buf.

Referenced by __elfN().

Here is the caller graph for this function:

◆ insert_brand_entry()

int __elfN() insert_brand_entry ( Elf_Brandinfo *  entry)

Definition at line 282 of file imgact_elf.c.

References elf_brand_list, and printf().

Here is the call graph for this function:

◆ kfreebsd_trans_osrel()

static bool kfreebsd_trans_osrel ( const Elf_Note *  note,
int32_t *  osrel 
)
static

Definition at line 260 of file imgact_elf.c.

References ELF_NOTE_ROUNDSIZE, and GNU_KFREEBSD_ABI_DESC.

Referenced by __elfN().

Here is the caller graph for this function:

◆ load_file()

static int __elfN() load_file ( struct proc *  p,
const char *  file,
u_long *  addr,
u_long *  entry 
)
static

Definition at line 776 of file imgact_elf.c.

References __elfN(), addr, aligned, check_header(), exec_check_permissions(), exec_map_first_page(), exec_unmap_first_page(), free(), load_sections(), malloc(), namei(), NDFREE(), phdr_in_zero_page(), and vput().

Referenced by load_interp().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ load_interp()

static int __elfN() load_interp ( struct image_params *  imgp,
const Elf_Brandinfo *  brand_info,
const char *  interp,
u_long *  addr,
u_long *  entry 
)
static

Definition at line 1064 of file imgact_elf.c.

References __elfN(), addr, free(), load_file(), malloc(), path, snprintf(), and uprintf().

Here is the call graph for this function:

◆ load_section()

static int __elfN() load_section ( struct image_params *  imgp,
vm_ooffset_t  offset,
caddr_t  vmaddr,
size_t  memsz,
size_t  filsz,
vm_prot_t  prot 
)
static

Definition at line 619 of file imgact_elf.c.

References __elfN(), map_insert(), and uprintf().

Referenced by load_sections().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ load_sections()

static int __elfN() load_sections ( struct image_params *  imgp,
const Elf_Ehdr *  hdr,
const Elf_Phdr *  phdr,
u_long  rbase,
u_long *  base_addrp 
)
static

Definition at line 723 of file imgact_elf.c.

References __elfN(), load_section(), and trans_prot().

Referenced by load_file().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ map_insert()

static int __elfN() map_insert ( struct image_params *  imgp,
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 
)
static

Definition at line 547 of file imgact_elf.c.

References __elfN(), map_partial(), and start.

Referenced by load_section().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ map_partial()

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

Definition at line 515 of file imgact_elf.c.

References start.

Referenced by map_insert().

Here is the caller graph for this function:

◆ note_fctl_cb()

static bool note_fctl_cb ( const Elf_Note *  note,
void *  arg0,
bool *  res 
)
static

Definition at line 2783 of file imgact_elf.c.

References ELF_NOTE_ROUNDSIZE, fctl_cb_arg::fctl0, fctl_cb_arg::has_fctl0, and res.

Referenced by check_note().

Here is the caller graph for this function:

◆ note_procstat_auxv()

static void __elfN() note_procstat_auxv ( void *  arg,
struct sbuf *  sb,
size_t *  sizep 
)
static

Definition at line 2652 of file imgact_elf.c.

References proc_getauxv(), sbuf_bcat(), sbuf_count_drain(), sbuf_delete(), sbuf_finish(), sbuf_new(), and sbuf_set_drain().

Referenced by prepare_notes().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ note_procstat_files()

static void note_procstat_files ( void *  arg,
struct sbuf *  sb,
size_t *  sizep 
)
static

Definition at line 2466 of file imgact_elf.c.

References coredump_pack_fileinfo, kern_proc_filedesc_out(), sbuf_bcat(), sbuf_count_drain(), sbuf_delete(), sbuf_end_section(), sbuf_finish(), sbuf_new(), sbuf_putc(), sbuf_set_drain(), and sbuf_start_section().

Referenced by prepare_notes().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ note_procstat_groups()

static void note_procstat_groups ( void *  arg,
struct sbuf *  sb,
size_t *  sizep 
)
static

Definition at line 2550 of file imgact_elf.c.

References sbuf_bcat().

Referenced by prepare_notes().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ note_procstat_osrel()

static void note_procstat_osrel ( void *  arg,
struct sbuf *  sb,
size_t *  sizep 
)
static

Definition at line 2610 of file imgact_elf.c.

References sbuf_bcat().

Referenced by prepare_notes().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ note_procstat_proc()

static void __elfN() note_procstat_proc ( void *  arg,
struct sbuf *  sb,
size_t *  sizep 
)
static

Definition at line 2439 of file imgact_elf.c.

References ELF_KERN_PROC_MASK, kern_proc_out(), proctree_lock, and sbuf_bcat().

Referenced by prepare_notes().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ note_procstat_psstrings()

static void __elfN() note_procstat_psstrings ( void *  arg,
struct sbuf *  sb,
size_t *  sizep 
)
static

Definition at line 2628 of file imgact_elf.c.

References sbuf_bcat().

Referenced by prepare_notes().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ note_procstat_rlimit()

static void note_procstat_rlimit ( void *  arg,
struct sbuf *  sb,
size_t *  sizep 
)
static

Definition at line 2587 of file imgact_elf.c.

References lim_rlimit_proc(), and sbuf_bcat().

Referenced by prepare_notes().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ note_procstat_umask()

static void note_procstat_umask ( void *  arg,
struct sbuf *  sb,
size_t *  sizep 
)
static

Definition at line 2569 of file imgact_elf.c.

References sbuf_bcat().

Referenced by prepare_notes().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ note_procstat_vmmap()

static void note_procstat_vmmap ( void *  arg,
struct sbuf *  sb,
size_t *  sizep 
)
static

Definition at line 2518 of file imgact_elf.c.

References coredump_pack_vmmapinfo, kern_proc_vmmap_out(), sbuf_bcat(), sbuf_count_drain(), sbuf_delete(), sbuf_finish(), sbuf_new(), and sbuf_set_drain().

Referenced by prepare_notes().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ note_prpsinfo()

static void __elfN() note_prpsinfo ( void *  arg,
struct sbuf *  sb,
size_t *  sizep 
)
static

Definition at line 2165 of file imgact_elf.c.

References free(), malloc(), proc_getargv(), sbuf_bcat(), sbuf_delete(), sbuf_finish(), sbuf_len(), and sbuf_new().

Referenced by prepare_notes().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ note_ptlwpinfo()

static void __elfN() note_ptlwpinfo ( void *  arg,
struct sbuf *  sb,
size_t *  sizep 
)
static

Definition at line 2370 of file imgact_elf.c.

References sbuf_bcat().

Referenced by prepare_notes().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ note_threadmd()

static void __elfN() note_threadmd ( void *  arg,
struct sbuf *  sb,
size_t *  sizep 
)
static

Definition at line 2413 of file imgact_elf.c.

References __elfN(), buf, free(), malloc(), and sbuf_bcat().

Referenced by prepare_notes().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ note_thrmisc()

static void __elfN() note_thrmisc ( void *  arg,
struct sbuf *  sb,
size_t *  sizep 
)
static

Definition at line 2354 of file imgact_elf.c.

References sbuf_bcat().

Referenced by prepare_notes().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ parse_notes()

static bool __elfN() parse_notes ( struct image_params *  imgp,
Elf_Note *  checknote,
const char *  note_vendor,
const Elf_Phdr *  pnote,
bool(*)(const Elf_Note *, void *, bool *)  cb,
void *  cb_arg 
)
static

Definition at line 2681 of file imgact_elf.c.

References aligned, buf, ELF_NOTE_ROUNDSIZE, free(), malloc(), res, uprintf(), and vn_rdwr().

Referenced by check_note().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ phdr_in_zero_page()

static bool __elfN() phdr_in_zero_page ( const Elf_Ehdr *  hdr)
static

Definition at line 479 of file imgact_elf.c.

Referenced by load_file().

Here is the caller graph for this function:

◆ populate_note()

size_t __elfN() populate_note ( int  type,
void *  src,
void *  dst,
size_t  size,
void **  descp 
)

Definition at line 2041 of file imgact_elf.c.

References append_note_data(), buf, ELF_NOTE_ROUNDSIZE, src, and type.

Here is the call graph for this function:

◆ prepare_notes()

void __elfN() prepare_notes ( struct thread *  td,
struct note_info_list *  list,
size_t *  sizep 
)

◆ prepare_register_notes()

static size_t __elfN() prepare_register_notes ( struct thread *  td,
struct note_info_list *  list,
struct thread *  target_td 
)
static

Definition at line 2321 of file imgact_elf.c.

References __elfN(), and register_regset_note().

Referenced by prepare_notes().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ puthdr()

void __elfN() puthdr ( struct thread *  td,
void *  hdr,
size_t  hdrsize,
int  numsegs,
size_t  notesz,
int  flags 
)

Definition at line 1885 of file imgact_elf.c.

References cb_put_phdr(), each_dumpable_segment(), ELF_NOTE_ROUNDSIZE, flags, phdr_closure::offset, and phdr_closure::phdr.

Referenced by corehdr().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ putnote()

static void __elfN() putnote ( struct thread *  td,
struct note_info ninfo,
struct sbuf *  sb 
)
static

Definition at line 2070 of file imgact_elf.c.

References buf, ELF_NOTE_ROUNDSIZE, free(), malloc(), note_info::outarg, note_info::outfunc, note_info::outsize, note_info::regset, sbuf_bcat(), sbuf_end_section(), sbuf_putc(), sbuf_start_section(), and note_info::type.

Referenced by corehdr().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ register_note()

size_t __elfN() register_note ( struct thread *  td,
struct note_info_list *  list,
int  type,
outfunc_t  out,
void *  arg 
)

Definition at line 1999 of file imgact_elf.c.

References ELF_NOTE_ROUNDSIZE, malloc(), note_info::outarg, note_info::outfunc, note_info::outsize, type, and note_info::type.

Referenced by prepare_notes().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ register_regset_note()

static size_t __elfN() register_regset_note ( struct thread *  td,
struct note_info_list *  list,
struct regset *  regset,
struct thread *  target_td 
)
static

Definition at line 1971 of file imgact_elf.c.

References ELF_NOTE_ROUNDSIZE, malloc(), note_info::outarg, note_info::outsize, note_info::regset, and note_info::type.

Referenced by prepare_register_notes().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ remove_brand_entry()

int __elfN() remove_brand_entry ( Elf_Brandinfo *  entry)

Definition at line 301 of file imgact_elf.c.

References elf_brand_list.

◆ set_fpregset()

static bool __elfN() set_fpregset ( struct regset *  rs,
struct thread *  td,
void *  buf,
size_t  size 
)
static

Definition at line 2297 of file imgact_elf.c.

References buf.

Referenced by __elfN().

Here is the caller graph for this function:

◆ set_prstatus()

static bool __elfN() set_prstatus ( struct regset *  rs,
struct thread *  td,
void *  buf,
size_t  size 
)
static

Definition at line 2253 of file imgact_elf.c.

References buf.

Referenced by __elfN().

Here is the caller graph for this function:

◆ size_segments()

void __elfN() size_segments ( struct thread *  td,
struct sseg_closure *  seginfo,
int  flags 
)

Definition at line 1719 of file imgact_elf.c.

References cb_size_segment(), each_dumpable_segment(), and flags.

Referenced by coredump().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ SYSCTL_BOOL()

SYSCTL_BOOL ( __CONCAT(_kern_elf, __ELF_WORD_SIZE ,
OID_AUTO  ,
allow_wx  ,
CTLFLAG_RWTUN  ,
__elfNallow_wx,
,
"Allow pages to be mapped simultaneously writable and executable"   
)

◆ SYSCTL_INT() [1/5]

SYSCTL_INT ( __CONCAT(_kern_elf, __ELF_WORD_SIZE ,
OID_AUTO  ,
sigfastblock  ,
CTLFLAG_RWTUN  ,
__elfNsigfastblock,
,
"enable sigfastblock for new processes"   
)

◆ SYSCTL_INT() [2/5]

SYSCTL_INT ( ASLR_NODE_OID  ,
OID_AUTO  ,
enable  ,
CTLFLAG_RWTUN  ,
__elfNaslr_enabled,
,
": enable address map randomization"   
)

◆ SYSCTL_INT() [3/5]

SYSCTL_INT ( ASLR_NODE_OID  ,
OID_AUTO  ,
honor_sbrk  ,
CTLFLAG_RW  ,
__elfNaslr_honor_sbrk,
,
__XSTRING(__CONCAT(ELF, __ELF_WORD_SIZE)) ": assume sbrk is used"   
)

◆ SYSCTL_INT() [4/5]

SYSCTL_INT ( ASLR_NODE_OID  ,
OID_AUTO  ,
pie_enable  ,
CTLFLAG_RWTUN  ,
__elfNpie_aslr_enabled,
,
": enable address map randomization for PIE binaries"   
)

◆ SYSCTL_INT() [5/5]

SYSCTL_INT ( ASLR_NODE_OID  ,
OID_AUTO  ,
stack  ,
CTLFLAG_RWTUN  ,
__elfNaslr_stack,
,
": enable stack address randomization"   
)

◆ SYSCTL_NODE()

SYSCTL_NODE ( __CONCAT(_kern_elf, __ELF_WORD_SIZE ,
OID_AUTO  ,
aslr  ,
CTLFLAG_RW|  CTLFLAG_MPSAFE,
,
""   
)

◆ SYSCTL_PROC()

SYSCTL_PROC ( __CONCAT(_kern_elf, __ELF_WORD_SIZE ,
OID_AUTO  ,
pie_base  ,
CTLTYPE_ULONG|CTLFLAG_MPSAFE|  CTLFLAG_RW,
NULL  ,
,
sysctl_pie_base  ,
"LU"  ,
"PIE load base without randomization"   
)

◆ TAILQ_HEAD()

TAILQ_HEAD ( note_info_list  ,
note_info   
)

Referenced by turnstile_unpend().

Here is the caller graph for this function:

◆ trans_prot()

static vm_prot_t __elfN() trans_prot ( Elf_Word  flags)
static

Definition at line 2850 of file imgact_elf.c.

References flags.

Referenced by load_sections().

Here is the caller graph for this function:

◆ untrans_prot()

static Elf_Word __elfN() untrans_prot ( vm_prot_t  prot)
static

Definition at line 2869 of file imgact_elf.c.

References flags.

Referenced by cb_put_phdr().

Here is the caller graph for this function:

Variable Documentation

◆ compress_user_cores

int compress_user_cores
extern

Definition at line 3572 of file kern_sig.c.

Referenced by coredump(), and sysctl_compress_user_cores().

◆ compress_user_cores_level

int compress_user_cores_level
extern

Definition at line 3595 of file kern_sig.c.

Referenced by coredump().

◆ elf_brand_list

Elf_Brandinfo* elf_brand_list[MAX_BRANDS]
static

Definition at line 222 of file imgact_elf.c.

Referenced by check_header(), get_brandinfo(), insert_brand_entry(), and remove_brand_entry().

◆ fctl_note

Elf_Note fctl_note
static
Initial value:
= {
.n_namesz = sizeof(FREEBSD_ABI_VENDOR),
.n_descsz = sizeof(uint32_t),
.n_type = NT_FREEBSD_FEATURE_CTL,
}

Definition at line 2771 of file imgact_elf.c.

Referenced by check_note().

◆ GNU_ABI_VENDOR

const char GNU_ABI_VENDOR[] = "GNU"
static

Definition at line 247 of file imgact_elf.c.

Referenced by __elfN().

◆ GNU_KFREEBSD_ABI_DESC

int GNU_KFREEBSD_ABI_DESC = 3
static

Definition at line 248 of file imgact_elf.c.

Referenced by kfreebsd_trans_osrel().