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