0001
0002 #ifndef _LINUX_BINFMTS_H
0003 #define _LINUX_BINFMTS_H
0004
0005 #include <linux/sched.h>
0006 #include <linux/unistd.h>
0007 #include <asm/exec.h>
0008 #include <uapi/linux/binfmts.h>
0009
0010 struct filename;
0011 struct coredump_params;
0012
0013 #define CORENAME_MAX_SIZE 128
0014
0015
0016
0017
0018 struct linux_binprm {
0019 #ifdef CONFIG_MMU
0020 struct vm_area_struct *vma;
0021 unsigned long vma_pages;
0022 #else
0023 # define MAX_ARG_PAGES 32
0024 struct page *page[MAX_ARG_PAGES];
0025 #endif
0026 struct mm_struct *mm;
0027 unsigned long p;
0028 unsigned long argmin;
0029 unsigned int
0030
0031 have_execfd:1,
0032
0033
0034 execfd_creds:1,
0035
0036
0037
0038
0039
0040 secureexec:1,
0041
0042
0043
0044
0045 point_of_no_return:1;
0046 #ifdef __alpha__
0047 unsigned int taso:1;
0048 #endif
0049 struct file *executable;
0050 struct file *interpreter;
0051 struct file *file;
0052 struct cred *cred;
0053 int unsafe;
0054 unsigned int per_clear;
0055 int argc, envc;
0056 const char *filename;
0057 const char *interp;
0058
0059
0060 const char *fdpath;
0061 unsigned interp_flags;
0062 int execfd;
0063 unsigned long loader, exec;
0064
0065 struct rlimit rlim_stack;
0066
0067 char buf[BINPRM_BUF_SIZE];
0068 } __randomize_layout;
0069
0070 #define BINPRM_FLAGS_ENFORCE_NONDUMP_BIT 0
0071 #define BINPRM_FLAGS_ENFORCE_NONDUMP (1 << BINPRM_FLAGS_ENFORCE_NONDUMP_BIT)
0072
0073
0074 #define BINPRM_FLAGS_PATH_INACCESSIBLE_BIT 2
0075 #define BINPRM_FLAGS_PATH_INACCESSIBLE (1 << BINPRM_FLAGS_PATH_INACCESSIBLE_BIT)
0076
0077
0078 #define BINPRM_FLAGS_PRESERVE_ARGV0_BIT 3
0079 #define BINPRM_FLAGS_PRESERVE_ARGV0 (1 << BINPRM_FLAGS_PRESERVE_ARGV0_BIT)
0080
0081
0082
0083
0084
0085 struct linux_binfmt {
0086 struct list_head lh;
0087 struct module *module;
0088 int (*load_binary)(struct linux_binprm *);
0089 int (*load_shlib)(struct file *);
0090 #ifdef CONFIG_COREDUMP
0091 int (*core_dump)(struct coredump_params *cprm);
0092 unsigned long min_coredump;
0093 #endif
0094 } __randomize_layout;
0095
0096 extern void __register_binfmt(struct linux_binfmt *fmt, int insert);
0097
0098
0099 static inline void register_binfmt(struct linux_binfmt *fmt)
0100 {
0101 __register_binfmt(fmt, 0);
0102 }
0103
0104 static inline void insert_binfmt(struct linux_binfmt *fmt)
0105 {
0106 __register_binfmt(fmt, 1);
0107 }
0108
0109 extern void unregister_binfmt(struct linux_binfmt *);
0110
0111 extern int __must_check remove_arg_zero(struct linux_binprm *);
0112 extern int begin_new_exec(struct linux_binprm * bprm);
0113 extern void setup_new_exec(struct linux_binprm * bprm);
0114 extern void finalize_exec(struct linux_binprm *bprm);
0115 extern void would_dump(struct linux_binprm *, struct file *);
0116
0117 extern int suid_dumpable;
0118
0119
0120 #define EXSTACK_DEFAULT 0
0121 #define EXSTACK_DISABLE_X 1
0122 #define EXSTACK_ENABLE_X 2
0123
0124 extern int setup_arg_pages(struct linux_binprm * bprm,
0125 unsigned long stack_top,
0126 int executable_stack);
0127 extern int transfer_args_to_stack(struct linux_binprm *bprm,
0128 unsigned long *sp_location);
0129 extern int bprm_change_interp(const char *interp, struct linux_binprm *bprm);
0130 int copy_string_kernel(const char *arg, struct linux_binprm *bprm);
0131 extern void set_binfmt(struct linux_binfmt *new);
0132 extern ssize_t read_code(struct file *, unsigned long, loff_t, size_t);
0133
0134 int kernel_execve(const char *filename,
0135 const char *const *argv, const char *const *envp);
0136
0137 #endif