binfmts.h 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  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. unsigned long argv_len;
  37. };
  38. #define BINPRM_FLAGS_ENFORCE_NONDUMP_BIT 0
  39. #define BINPRM_FLAGS_ENFORCE_NONDUMP (1 << BINPRM_FLAGS_ENFORCE_NONDUMP_BIT)
  40. /* fd of the binary should be passed to the interpreter */
  41. #define BINPRM_FLAGS_EXECFD_BIT 1
  42. #define BINPRM_FLAGS_EXECFD (1 << BINPRM_FLAGS_EXECFD_BIT)
  43. /*
  44. * This structure defines the functions that are used to load the binary formats that
  45. * linux accepts.
  46. */
  47. struct linux_binfmt {
  48. struct linux_binfmt * next;
  49. struct module *module;
  50. int (*load_binary)(struct linux_binprm *, struct pt_regs * regs);
  51. int (*load_shlib)(struct file *);
  52. int (*core_dump)(long signr, struct pt_regs * regs, struct file * file);
  53. unsigned long min_coredump; /* minimal dump size */
  54. int hasvdso;
  55. };
  56. extern int register_binfmt(struct linux_binfmt *);
  57. extern int unregister_binfmt(struct linux_binfmt *);
  58. extern int prepare_binprm(struct linux_binprm *);
  59. extern void remove_arg_zero(struct linux_binprm *);
  60. extern int search_binary_handler(struct linux_binprm *,struct pt_regs *);
  61. extern int flush_old_exec(struct linux_binprm * bprm);
  62. extern int suid_dumpable;
  63. #define SUID_DUMP_DISABLE 0 /* No setuid dumping */
  64. #define SUID_DUMP_USER 1 /* Dump as user of process */
  65. #define SUID_DUMP_ROOT 2 /* Dump as root */
  66. /* Stack area protections */
  67. #define EXSTACK_DEFAULT 0 /* Whatever the arch defaults to */
  68. #define EXSTACK_DISABLE_X 1 /* Disable executable stacks */
  69. #define EXSTACK_ENABLE_X 2 /* Enable executable stacks */
  70. extern int setup_arg_pages(struct linux_binprm * bprm,
  71. unsigned long stack_top,
  72. int executable_stack);
  73. extern int copy_strings_kernel(int argc,char ** argv,struct linux_binprm *bprm);
  74. extern void compute_creds(struct linux_binprm *binprm);
  75. extern int do_coredump(long signr, int exit_code, struct pt_regs * regs);
  76. extern int set_binfmt(struct linux_binfmt *new);
  77. #endif /* __KERNEL__ */
  78. #endif /* _LINUX_BINFMTS_H */