binfmts.h 2.9 KB

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