Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Handling of different ABIs (personalities). |
| 3 | * |
| 4 | * We group personalities into execution domains which have their |
| 5 | * own handlers for kernel entry points, signal mapping, etc... |
| 6 | * |
| 7 | * 2001-05-06 Complete rewrite, Christoph Hellwig (hch@infradead.org) |
| 8 | */ |
| 9 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 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> |
Alexey Dobriyan | 6e62775 | 2008-10-04 14:28:09 +0400 | [diff] [blame] | 15 | #include <linux/proc_fs.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 16 | #include <linux/sched.h> |
Alexey Dobriyan | 6e62775 | 2008-10-04 14:28:09 +0400 | [diff] [blame] | 17 | #include <linux/seq_file.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 18 | #include <linux/syscalls.h> |
| 19 | #include <linux/sysctl.h> |
| 20 | #include <linux/types.h> |
Al Viro | 5ad4e53 | 2009-03-29 19:50:06 -0400 | [diff] [blame] | 21 | #include <linux/fs_struct.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 22 | |
Alexey Dobriyan | 6e62775 | 2008-10-04 14:28:09 +0400 | [diff] [blame] | 23 | #ifdef CONFIG_PROC_FS |
| 24 | static int execdomains_proc_show(struct seq_file *m, void *v) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 25 | { |
Richard Weinberger | 973f911 | 2015-03-30 08:14:16 +0200 | [diff] [blame] | 26 | seq_puts(m, "0-0\tLinux \t[kernel]\n"); |
Alexey Dobriyan | 6e62775 | 2008-10-04 14:28:09 +0400 | [diff] [blame] | 27 | return 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 28 | } |
| 29 | |
Alexey Dobriyan | 6e62775 | 2008-10-04 14:28:09 +0400 | [diff] [blame] | 30 | static int execdomains_proc_open(struct inode *inode, struct file *file) |
| 31 | { |
| 32 | return single_open(file, execdomains_proc_show, NULL); |
| 33 | } |
| 34 | |
| 35 | static const struct file_operations execdomains_proc_fops = { |
| 36 | .open = execdomains_proc_open, |
| 37 | .read = seq_read, |
| 38 | .llseek = seq_lseek, |
| 39 | .release = single_release, |
| 40 | }; |
| 41 | |
| 42 | static int __init proc_execdomains_init(void) |
| 43 | { |
| 44 | proc_create("execdomains", 0, NULL, &execdomains_proc_fops); |
| 45 | return 0; |
| 46 | } |
| 47 | module_init(proc_execdomains_init); |
| 48 | #endif |
| 49 | |
Oleg Nesterov | 485d527 | 2010-06-04 14:14:58 -0700 | [diff] [blame] | 50 | SYSCALL_DEFINE1(personality, unsigned int, personality) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 51 | { |
Oleg Nesterov | 485d527 | 2010-06-04 14:14:58 -0700 | [diff] [blame] | 52 | unsigned int old = current->personality; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 53 | |
Oleg Nesterov | 2ee7c92 | 2010-08-09 17:20:30 -0700 | [diff] [blame] | 54 | if (personality != 0xffffffff) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 55 | set_personality(personality); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 56 | |
Oleg Nesterov | 485d527 | 2010-06-04 14:14:58 -0700 | [diff] [blame] | 57 | return old; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 58 | } |