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