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