1
2#ifndef _LINUX_BINFMTS_H
3#define _LINUX_BINFMTS_H
4
5#include <linux/sched.h>
6#include <linux/unistd.h>
7#include <asm/exec.h>
8#include <uapi/linux/binfmts.h>
9
10struct filename;
11
12#define CORENAME_MAX_SIZE 128
13
14
15
16
17struct linux_binprm {
18#ifdef CONFIG_MMU
19 struct vm_area_struct *vma;
20 unsigned long vma_pages;
21#else
22# define MAX_ARG_PAGES 32
23 struct page *page[MAX_ARG_PAGES];
24#endif
25 struct mm_struct *mm;
26 unsigned long p;
27 unsigned long argmin;
28 unsigned int
29
30
31
32
33
34 called_set_creds:1,
35
36
37
38
39
40
41 cap_elevated:1,
42
43
44
45
46
47 secureexec:1;
48#ifdef __alpha__
49 unsigned int taso:1;
50#endif
51 unsigned int recursion_depth;
52 struct file * file;
53 struct cred *cred;
54 int unsafe;
55 unsigned int per_clear;
56 int argc, envc;
57 const char * filename;
58 const char * interp;
59
60
61 unsigned interp_flags;
62 unsigned interp_data;
63 unsigned long loader, exec;
64
65 struct rlimit rlim_stack;
66
67 char buf[BINPRM_BUF_SIZE];
68} __randomize_layout;
69
70#define BINPRM_FLAGS_ENFORCE_NONDUMP_BIT 0
71#define BINPRM_FLAGS_ENFORCE_NONDUMP (1 << BINPRM_FLAGS_ENFORCE_NONDUMP_BIT)
72
73
74#define BINPRM_FLAGS_EXECFD_BIT 1
75#define BINPRM_FLAGS_EXECFD (1 << BINPRM_FLAGS_EXECFD_BIT)
76
77
78#define BINPRM_FLAGS_PATH_INACCESSIBLE_BIT 2
79#define BINPRM_FLAGS_PATH_INACCESSIBLE (1 << BINPRM_FLAGS_PATH_INACCESSIBLE_BIT)
80
81
82struct coredump_params {
83 const kernel_siginfo_t *siginfo;
84 struct pt_regs *regs;
85 struct file *file;
86 unsigned long limit;
87 unsigned long mm_flags;
88 loff_t written;
89 loff_t pos;
90};
91
92
93
94
95
96struct linux_binfmt {
97 struct list_head lh;
98 struct module *module;
99 int (*load_binary)(struct linux_binprm *);
100 int (*load_shlib)(struct file *);
101 int (*core_dump)(struct coredump_params *cprm);
102 unsigned long min_coredump;
103} __randomize_layout;
104
105extern void __register_binfmt(struct linux_binfmt *fmt, int insert);
106
107
108static inline void register_binfmt(struct linux_binfmt *fmt)
109{
110 __register_binfmt(fmt, 0);
111}
112
113static inline void insert_binfmt(struct linux_binfmt *fmt)
114{
115 __register_binfmt(fmt, 1);
116}
117
118extern void unregister_binfmt(struct linux_binfmt *);
119
120extern int prepare_binprm(struct linux_binprm *);
121extern int __must_check remove_arg_zero(struct linux_binprm *);
122extern int search_binary_handler(struct linux_binprm *);
123extern int flush_old_exec(struct linux_binprm * bprm);
124extern void setup_new_exec(struct linux_binprm * bprm);
125extern void finalize_exec(struct linux_binprm *bprm);
126extern void would_dump(struct linux_binprm *, struct file *);
127
128extern int suid_dumpable;
129
130
131#define EXSTACK_DEFAULT 0
132#define EXSTACK_DISABLE_X 1
133#define EXSTACK_ENABLE_X 2
134
135extern int setup_arg_pages(struct linux_binprm * bprm,
136 unsigned long stack_top,
137 int executable_stack);
138extern int transfer_args_to_stack(struct linux_binprm *bprm,
139 unsigned long *sp_location);
140extern int bprm_change_interp(const char *interp, struct linux_binprm *bprm);
141extern int copy_strings_kernel(int argc, const char *const *argv,
142 struct linux_binprm *bprm);
143extern void install_exec_creds(struct linux_binprm *bprm);
144extern void set_binfmt(struct linux_binfmt *new);
145extern ssize_t read_code(struct file *, unsigned long, loff_t, size_t);
146
147extern int do_execve(struct filename *,
148 const char __user * const __user *,
149 const char __user * const __user *);
150extern int do_execveat(int, struct filename *,
151 const char __user * const __user *,
152 const char __user * const __user *,
153 int);
154int do_execve_file(struct file *file, void *__argv, void *__envp);
155
156#endif
157