binfmts.h 2.9 KB

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