personality.h 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. #ifndef _LINUX_PERSONALITY_H
  2. #define _LINUX_PERSONALITY_H
  3. #ifdef __KERNEL__
  4. /*
  5. * Handling of different ABIs (personalities).
  6. */
  7. struct exec_domain;
  8. struct pt_regs;
  9. extern int register_exec_domain(struct exec_domain *);
  10. extern int unregister_exec_domain(struct exec_domain *);
  11. extern int __set_personality(unsigned long);
  12. #endif /* __KERNEL__ */
  13. /*
  14. * Flags for bug emulation.
  15. *
  16. * These occupy the top three bytes.
  17. */
  18. enum {
  19. ADDR_NO_RANDOMIZE = 0x0040000, /* disable randomization of VA space */
  20. FDPIC_FUNCPTRS = 0x0080000, /* userspace function ptrs point to descriptors
  21. * (signal handling)
  22. */
  23. MMAP_PAGE_ZERO = 0x0100000,
  24. ADDR_COMPAT_LAYOUT = 0x0200000,
  25. READ_IMPLIES_EXEC = 0x0400000,
  26. ADDR_LIMIT_32BIT = 0x0800000,
  27. SHORT_INODE = 0x1000000,
  28. WHOLE_SECONDS = 0x2000000,
  29. STICKY_TIMEOUTS = 0x4000000,
  30. ADDR_LIMIT_3GB = 0x8000000,
  31. };
  32. /*
  33. * Security-relevant compatibility flags that must be
  34. * cleared upon setuid or setgid exec:
  35. */
  36. #define PER_CLEAR_ON_SETID (READ_IMPLIES_EXEC|ADDR_NO_RANDOMIZE)
  37. /*
  38. * Personality types.
  39. *
  40. * These go in the low byte. Avoid using the top bit, it will
  41. * conflict with error returns.
  42. */
  43. enum {
  44. PER_LINUX = 0x0000,
  45. PER_LINUX_32BIT = 0x0000 | ADDR_LIMIT_32BIT,
  46. PER_LINUX_FDPIC = 0x0000 | FDPIC_FUNCPTRS,
  47. PER_SVR4 = 0x0001 | STICKY_TIMEOUTS | MMAP_PAGE_ZERO,
  48. PER_SVR3 = 0x0002 | STICKY_TIMEOUTS | SHORT_INODE,
  49. PER_SCOSVR3 = 0x0003 | STICKY_TIMEOUTS |
  50. WHOLE_SECONDS | SHORT_INODE,
  51. PER_OSR5 = 0x0003 | STICKY_TIMEOUTS | WHOLE_SECONDS,
  52. PER_WYSEV386 = 0x0004 | STICKY_TIMEOUTS | SHORT_INODE,
  53. PER_ISCR4 = 0x0005 | STICKY_TIMEOUTS,
  54. PER_BSD = 0x0006,
  55. PER_SUNOS = 0x0006 | STICKY_TIMEOUTS,
  56. PER_XENIX = 0x0007 | STICKY_TIMEOUTS | SHORT_INODE,
  57. PER_LINUX32 = 0x0008,
  58. PER_LINUX32_3GB = 0x0008 | ADDR_LIMIT_3GB,
  59. PER_IRIX32 = 0x0009 | STICKY_TIMEOUTS,/* IRIX5 32-bit */
  60. PER_IRIXN32 = 0x000a | STICKY_TIMEOUTS,/* IRIX6 new 32-bit */
  61. PER_IRIX64 = 0x000b | STICKY_TIMEOUTS,/* IRIX6 64-bit */
  62. PER_RISCOS = 0x000c,
  63. PER_SOLARIS = 0x000d | STICKY_TIMEOUTS,
  64. PER_UW7 = 0x000e | STICKY_TIMEOUTS | MMAP_PAGE_ZERO,
  65. PER_OSF4 = 0x000f, /* OSF/1 v4 */
  66. PER_HPUX = 0x0010,
  67. PER_MASK = 0x00ff,
  68. };
  69. #ifdef __KERNEL__
  70. /*
  71. * Description of an execution domain.
  72. *
  73. * The first two members are refernced from assembly source
  74. * and should stay where they are unless explicitly needed.
  75. */
  76. typedef void (*handler_t)(int, struct pt_regs *);
  77. struct exec_domain {
  78. const char *name; /* name of the execdomain */
  79. handler_t handler; /* handler for syscalls */
  80. unsigned char pers_low; /* lowest personality */
  81. unsigned char pers_high; /* highest personality */
  82. unsigned long *signal_map; /* signal mapping */
  83. unsigned long *signal_invmap; /* reverse signal mapping */
  84. struct map_segment *err_map; /* error mapping */
  85. struct map_segment *socktype_map; /* socket type mapping */
  86. struct map_segment *sockopt_map; /* socket option mapping */
  87. struct map_segment *af_map; /* address family mapping */
  88. struct module *module; /* module context of the ed. */
  89. struct exec_domain *next; /* linked list (internal) */
  90. };
  91. /*
  92. * Return the base personality without flags.
  93. */
  94. #define personality(pers) (pers & PER_MASK)
  95. /*
  96. * Personality of the currently running process.
  97. */
  98. #define get_personality (current->personality)
  99. /*
  100. * Change personality of the currently running process.
  101. */
  102. #define set_personality(pers) \
  103. ((current->personality == (pers)) ? 0 : __set_personality(pers))
  104. #endif /* __KERNEL__ */
  105. #endif /* _LINUX_PERSONALITY_H */