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 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} __randomize_layout;
67
68#define BINPRM_FLAGS_ENFORCE_NONDUMP_BIT 0
69#define BINPRM_FLAGS_ENFORCE_NONDUMP (1 << BINPRM_FLAGS_ENFORCE_NONDUMP_BIT)
70
71
72#define BINPRM_FLAGS_EXECFD_BIT 1
73#define BINPRM_FLAGS_EXECFD (1 << BINPRM_FLAGS_EXECFD_BIT)
74
75
76#define BINPRM_FLAGS_PATH_INACCESSIBLE_BIT 2
77#define BINPRM_FLAGS_PATH_INACCESSIBLE (1 << BINPRM_FLAGS_PATH_INACCESSIBLE_BIT)
78
79
80struct coredump_params {
81 const siginfo_t *siginfo;
82 struct pt_regs *regs;
83 struct file *file;
84 unsigned long limit;
85 unsigned long mm_flags;
86 loff_t written;
87 loff_t pos;
88};
89
90
91
92
93
94struct linux_binfmt {
95 struct list_head lh;
96 struct module *module;
97 int (*load_binary)(struct linux_binprm *);
98 int (*load_shlib)(struct file *);
99 int (*core_dump)(struct coredump_params *cprm);
100 unsigned long min_coredump;
101} __randomize_layout;
102
103extern void __register_binfmt(struct linux_binfmt *fmt, int insert);
104
105
106static inline void register_binfmt(struct linux_binfmt *fmt)
107{
108 __register_binfmt(fmt, 0);
109}
110
111static inline void insert_binfmt(struct linux_binfmt *fmt)
112{
113 __register_binfmt(fmt, 1);
114}
115
116extern void unregister_binfmt(struct linux_binfmt *);
117
118extern int prepare_binprm(struct linux_binprm *);
119extern int __must_check remove_arg_zero(struct linux_binprm *);
120extern int search_binary_handler(struct linux_binprm *);
121extern int flush_old_exec(struct linux_binprm * bprm);
122extern void setup_new_exec(struct linux_binprm * bprm);
123extern void finalize_exec(struct linux_binprm *bprm);
124extern void would_dump(struct linux_binprm *, struct file *);
125
126extern int suid_dumpable;
127
128
129#define EXSTACK_DEFAULT 0
130#define EXSTACK_DISABLE_X 1
131#define EXSTACK_ENABLE_X 2
132
133extern int setup_arg_pages(struct linux_binprm * bprm,
134 unsigned long stack_top,
135 int executable_stack);
136extern int transfer_args_to_stack(struct linux_binprm *bprm,
137 unsigned long *sp_location);
138extern int bprm_change_interp(const char *interp, struct linux_binprm *bprm);
139extern int copy_strings_kernel(int argc, const char *const *argv,
140 struct linux_binprm *bprm);
141extern int prepare_bprm_creds(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);
153
154#endif
155