| Greg Kroah-Hartman | b244131 | 2017-11-01 15:07:57 +0100 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0 | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2 | /* | 
|  | 3 | * Handling of different ABIs (personalities). | 
|  | 4 | * | 
|  | 5 | * We group personalities into execution domains which have their | 
|  | 6 | * own handlers for kernel entry points, signal mapping, etc... | 
|  | 7 | * | 
|  | 8 | * 2001-05-06	Complete rewrite,  Christoph Hellwig (hch@infradead.org) | 
|  | 9 | */ | 
|  | 10 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 11 | #include <linux/init.h> | 
|  | 12 | #include <linux/kernel.h> | 
|  | 13 | #include <linux/kmod.h> | 
|  | 14 | #include <linux/module.h> | 
|  | 15 | #include <linux/personality.h> | 
| Alexey Dobriyan | 6e62775 | 2008-10-04 14:28:09 +0400 | [diff] [blame] | 16 | #include <linux/proc_fs.h> | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 17 | #include <linux/sched.h> | 
| Alexey Dobriyan | 6e62775 | 2008-10-04 14:28:09 +0400 | [diff] [blame] | 18 | #include <linux/seq_file.h> | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 19 | #include <linux/syscalls.h> | 
|  | 20 | #include <linux/sysctl.h> | 
|  | 21 | #include <linux/types.h> | 
|  | 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 __init proc_execdomains_init(void) | 
|  | 31 | { | 
| Christoph Hellwig | 3f3942a | 2018-05-15 15:57:23 +0200 | [diff] [blame] | 32 | proc_create_single("execdomains", 0, NULL, execdomains_proc_show); | 
| Alexey Dobriyan | 6e62775 | 2008-10-04 14:28:09 +0400 | [diff] [blame] | 33 | return 0; | 
|  | 34 | } | 
|  | 35 | module_init(proc_execdomains_init); | 
|  | 36 | #endif | 
|  | 37 |  | 
| Oleg Nesterov | 485d527 | 2010-06-04 14:14:58 -0700 | [diff] [blame] | 38 | SYSCALL_DEFINE1(personality, unsigned int, personality) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 39 | { | 
| Oleg Nesterov | 485d527 | 2010-06-04 14:14:58 -0700 | [diff] [blame] | 40 | unsigned int old = current->personality; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 41 |  | 
| Oleg Nesterov | 2ee7c92 | 2010-08-09 17:20:30 -0700 | [diff] [blame] | 42 | if (personality != 0xffffffff) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 43 | set_personality(personality); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 44 |  | 
| Oleg Nesterov | 485d527 | 2010-06-04 14:14:58 -0700 | [diff] [blame] | 45 | return old; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 46 | } |