binfmts.h 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. #ifndef _LINUX_BINFMTS_H
  2. #define _LINUX_BINFMTS_H
  3. #include <linux/capability.h>
  4. struct pt_regs;
  5. /*
  6. * These are the maximum length and maximum number of strings passed to the
  7. * execve() system call. MAX_ARG_STRLEN is essentially random but serves to
  8. * prevent the kernel from being unduly impacted by misaddressed pointers.
  9. * MAX_ARG_STRINGS is chosen to fit in a signed 32-bit integer.
  10. */
  11. #define MAX_ARG_STRLEN (PAGE_SIZE * 32)
  12. #define MAX_ARG_STRINGS 0x7FFFFFFF
  13. /* sizeof(linux_binprm->buf) */
  14. #define BINPRM_BUF_SIZE 128
  15. #ifdef __KERNEL__
  16. #define CORENAME_MAX_SIZE 128
  17. /*
  18. * This structure is used to hold the arguments that are used when loading binaries.
  19. */
  20. struct linux_binprm{
  21. char buf[BINPRM_BUF_SIZE];
  22. #ifdef CONFIG_MMU
  23. struct vm_area_struct *vma;
  24. #else
  25. # define MAX_ARG_PAGES 32
  26. struct page *page[MAX_ARG_PAGES];
  27. #endif
  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. unsigned long argv_len;
  44. };
  45. #define BINPRM_FLAGS_ENFORCE_NONDUMP_BIT 0
  46. #define BINPRM_FLAGS_ENFORCE_NONDUMP (1 << BINPRM_FLAGS_ENFORCE_NONDUMP_BIT)
  47. /* fd of the binary should be passed to the interpreter */
  48. #define BINPRM_FLAGS_EXECFD_BIT 1
  49. #define BINPRM_FLAGS_EXECFD (1 << BINPRM_FLAGS_EXECFD_BIT)
  50. /*
  51. * This structure defines the functions that are used to load the binary formats that
  52. * linux accepts.
  53. */
  54. struct linux_binfmt {
  55. struct list_head lh;
  56. struct module *module;
  57. int (*load_binary)(struct linux_binprm *, struct pt_regs * regs);
  58. int (*load_shlib)(struct file *);
  59. int (*core_dump)(long signr, struct pt_regs *regs, struct file *file, unsigned long limit);
  60. unsigned long min_coredump; /* minimal dump size */
  61. int hasvdso;
  62. };
  63. extern int register_binfmt(struct linux_binfmt *);
  64. extern void unregister_binfmt(struct linux_binfmt *);
  65. extern int prepare_binprm(struct linux_binprm *);
  66. extern int __must_check remove_arg_zero(struct linux_binprm *);
  67. extern int search_binary_handler(struct linux_binprm *,struct pt_regs *);
  68. extern int flush_old_exec(struct linux_binprm * bprm);
  69. extern int suid_dumpable;
  70. #define SUID_DUMP_DISABLE 0 /* No setuid dumping */
  71. #define SUID_DUMP_USER 1 /* Dump as user of process */
  72. #define SUID_DUMP_ROOT 2 /* Dump as root */
  73. /* Stack area protections */
  74. #define EXSTACK_DEFAULT 0 /* Whatever the arch defaults to */
  75. #define EXSTACK_DISABLE_X 1 /* Disable executable stacks */
  76. #define EXSTACK_ENABLE_X 2 /* Enable executable stacks */
  77. extern int setup_arg_pages(struct linux_binprm * bprm,
  78. unsigned long stack_top,
  79. int executable_stack);
  80. extern int bprm_mm_init(struct linux_binprm *bprm);
  81. extern int copy_strings_kernel(int argc,char ** argv,struct linux_binprm *bprm);
  82. extern void compute_creds(struct linux_binprm *binprm);
  83. extern int do_coredump(long signr, int exit_code, struct pt_regs * regs);
  84. extern int set_binfmt(struct linux_binfmt *new);
  85. #endif /* __KERNEL__ */
  86. #endif /* _LINUX_BINFMTS_H */