2 * Handling of different ABIs (personalities).
4 * We group personalities into execution domains which have their
5 * own handlers for kernel entry points, signal mapping, etc...
7 * 2001-05-06 Complete rewrite, Christoph Hellwig (hch@infradead.org)
10 #include <linux/init.h>
11 #include <linux/kernel.h>
12 #include <linux/kmod.h>
13 #include <linux/module.h>
14 #include <linux/personality.h>
15 #include <linux/proc_fs.h>
16 #include <linux/sched.h>
17 #include <linux/seq_file.h>
18 #include <linux/syscalls.h>
19 #include <linux/sysctl.h>
20 #include <linux/types.h>
21 #include <linux/fs_struct.h>
23 static void default_handler(int, struct pt_regs *);
24 static unsigned long ident_map[32] = {
25 0, 1, 2, 3, 4, 5, 6, 7,
26 8, 9, 10, 11, 12, 13, 14, 15,
27 16, 17, 18, 19, 20, 21, 22, 23,
28 24, 25, 26, 27, 28, 29, 30, 31
31 struct exec_domain default_exec_domain = {
32 .name = "Linux", /* name */
33 .handler = default_handler, /* lcall7 causes a seg fault. */
34 .pers_low = 0, /* PER_LINUX personality. */
35 .pers_high = 0, /* PER_LINUX personality. */
36 .signal_map = ident_map, /* Identity map signals. */
37 .signal_invmap = ident_map, /* - both ways. */
42 default_handler(int segment, struct pt_regs *regp)
46 if (current_thread_info()->exec_domain->handler != default_handler)
47 current_thread_info()->exec_domain->handler(segment, regp);
49 send_sig(SIGSEGV, current, 1);
52 int __set_personality(unsigned int personality)
54 current->personality = personality;
58 EXPORT_SYMBOL(__set_personality);
61 static int execdomains_proc_show(struct seq_file *m, void *v)
63 seq_puts(m, "0-0\tLinux \t[kernel]\n");
67 static int execdomains_proc_open(struct inode *inode, struct file *file)
69 return single_open(file, execdomains_proc_show, NULL);
72 static const struct file_operations execdomains_proc_fops = {
73 .open = execdomains_proc_open,
76 .release = single_release,
79 static int __init proc_execdomains_init(void)
81 proc_create("execdomains", 0, NULL, &execdomains_proc_fops);
84 module_init(proc_execdomains_init);
87 SYSCALL_DEFINE1(personality, unsigned int, personality)
89 unsigned int old = current->personality;
91 if (personality != 0xffffffff)
92 set_personality(personality);