Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | #ifndef _LINUX_BINFMTS_H |
| 2 | #define _LINUX_BINFMTS_H |
| 3 | |
| 4 | #include <linux/capability.h> |
| 5 | |
| 6 | struct pt_regs; |
| 7 | |
| 8 | /* |
| 9 | * MAX_ARG_PAGES defines the number of pages allocated for arguments |
| 10 | * and envelope for the new program. 32 should suffice, this gives |
| 11 | * a maximum env+arg of 128kB w/4KB pages! |
| 12 | */ |
| 13 | #define MAX_ARG_PAGES 32 |
| 14 | |
| 15 | /* sizeof(linux_binprm->buf) */ |
| 16 | #define BINPRM_BUF_SIZE 128 |
| 17 | |
| 18 | #ifdef __KERNEL__ |
| 19 | |
Dan Aloni | 71ce92f | 2007-05-16 22:11:16 -0700 | [diff] [blame] | 20 | #define CORENAME_MAX_SIZE 128 |
| 21 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 22 | /* |
| 23 | * This structure is used to hold the arguments that are used when loading binaries. |
| 24 | */ |
| 25 | struct linux_binprm{ |
| 26 | char buf[BINPRM_BUF_SIZE]; |
| 27 | struct page *page[MAX_ARG_PAGES]; |
| 28 | struct mm_struct *mm; |
| 29 | unsigned long p; /* current top of mem */ |
| 30 | int sh_bang; |
| 31 | struct file * file; |
| 32 | int e_uid, e_gid; |
| 33 | kernel_cap_t cap_inheritable, cap_permitted, cap_effective; |
| 34 | void *security; |
| 35 | int argc, envc; |
| 36 | char * filename; /* Name of binary as seen by procps */ |
| 37 | char * interp; /* Name of the binary really executed. Most |
| 38 | of the time same as filename, but could be |
| 39 | different for binfmt_{misc,script} */ |
| 40 | unsigned interp_flags; |
| 41 | unsigned interp_data; |
| 42 | unsigned long loader, exec; |
| 43 | }; |
| 44 | |
| 45 | #define BINPRM_FLAGS_ENFORCE_NONDUMP_BIT 0 |
| 46 | #define BINPRM_FLAGS_ENFORCE_NONDUMP (1 << BINPRM_FLAGS_ENFORCE_NONDUMP_BIT) |
| 47 | |
| 48 | /* fd of the binary should be passed to the interpreter */ |
| 49 | #define BINPRM_FLAGS_EXECFD_BIT 1 |
| 50 | #define BINPRM_FLAGS_EXECFD (1 << BINPRM_FLAGS_EXECFD_BIT) |
| 51 | |
| 52 | |
| 53 | /* |
| 54 | * This structure defines the functions that are used to load the binary formats that |
| 55 | * linux accepts. |
| 56 | */ |
| 57 | struct linux_binfmt { |
| 58 | struct linux_binfmt * next; |
| 59 | struct module *module; |
| 60 | int (*load_binary)(struct linux_binprm *, struct pt_regs * regs); |
| 61 | int (*load_shlib)(struct file *); |
| 62 | int (*core_dump)(long signr, struct pt_regs * regs, struct file * file); |
| 63 | unsigned long min_coredump; /* minimal dump size */ |
Andi Kleen | 9fbbd4d | 2007-02-13 13:26:26 +0100 | [diff] [blame] | 64 | int hasvdso; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 65 | }; |
| 66 | |
| 67 | extern int register_binfmt(struct linux_binfmt *); |
| 68 | extern int unregister_binfmt(struct linux_binfmt *); |
| 69 | |
| 70 | extern int prepare_binprm(struct linux_binprm *); |
| 71 | extern void remove_arg_zero(struct linux_binprm *); |
| 72 | extern int search_binary_handler(struct linux_binprm *,struct pt_regs *); |
| 73 | extern int flush_old_exec(struct linux_binprm * bprm); |
| 74 | |
Alan Cox | d6e7114 | 2005-06-23 00:09:43 -0700 | [diff] [blame] | 75 | extern int suid_dumpable; |
| 76 | #define SUID_DUMP_DISABLE 0 /* No setuid dumping */ |
| 77 | #define SUID_DUMP_USER 1 /* Dump as user of process */ |
| 78 | #define SUID_DUMP_ROOT 2 /* Dump as root */ |
| 79 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 80 | /* Stack area protections */ |
| 81 | #define EXSTACK_DEFAULT 0 /* Whatever the arch defaults to */ |
| 82 | #define EXSTACK_DISABLE_X 1 /* Disable executable stacks */ |
| 83 | #define EXSTACK_ENABLE_X 2 /* Enable executable stacks */ |
| 84 | |
| 85 | extern int setup_arg_pages(struct linux_binprm * bprm, |
| 86 | unsigned long stack_top, |
| 87 | int executable_stack); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 88 | extern int copy_strings_kernel(int argc,char ** argv,struct linux_binprm *bprm); |
| 89 | extern void compute_creds(struct linux_binprm *binprm); |
| 90 | extern int do_coredump(long signr, int exit_code, struct pt_regs * regs); |
| 91 | extern int set_binfmt(struct linux_binfmt *new); |
| 92 | |
| 93 | #endif /* __KERNEL__ */ |
| 94 | #endif /* _LINUX_BINFMTS_H */ |