blob: 6873bb3e6b7e80adcd9cb638b93d530b81881a43 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
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 Torvalds1da177e2005-04-16 15:20:36 -070010#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 Dobriyan6e627752008-10-04 14:28:09 +040015#include <linux/proc_fs.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070016#include <linux/sched.h>
Alexey Dobriyan6e627752008-10-04 14:28:09 +040017#include <linux/seq_file.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070018#include <linux/syscalls.h>
19#include <linux/sysctl.h>
20#include <linux/types.h>
Al Viro5ad4e532009-03-29 19:50:06 -040021#include <linux/fs_struct.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070022
Alexey Dobriyan6e627752008-10-04 14:28:09 +040023#ifdef CONFIG_PROC_FS
24static int execdomains_proc_show(struct seq_file *m, void *v)
Linus Torvalds1da177e2005-04-16 15:20:36 -070025{
Richard Weinberger973f9112015-03-30 08:14:16 +020026 seq_puts(m, "0-0\tLinux \t[kernel]\n");
Alexey Dobriyan6e627752008-10-04 14:28:09 +040027 return 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -070028}
29
Alexey Dobriyan6e627752008-10-04 14:28:09 +040030static int execdomains_proc_open(struct inode *inode, struct file *file)
31{
32 return single_open(file, execdomains_proc_show, NULL);
33}
34
35static 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
42static int __init proc_execdomains_init(void)
43{
44 proc_create("execdomains", 0, NULL, &execdomains_proc_fops);
45 return 0;
46}
47module_init(proc_execdomains_init);
48#endif
49
Oleg Nesterov485d5272010-06-04 14:14:58 -070050SYSCALL_DEFINE1(personality, unsigned int, personality)
Linus Torvalds1da177e2005-04-16 15:20:36 -070051{
Oleg Nesterov485d5272010-06-04 14:14:58 -070052 unsigned int old = current->personality;
Linus Torvalds1da177e2005-04-16 15:20:36 -070053
Oleg Nesterov2ee7c922010-08-09 17:20:30 -070054 if (personality != 0xffffffff)
Linus Torvalds1da177e2005-04-16 15:20:36 -070055 set_personality(personality);
Linus Torvalds1da177e2005-04-16 15:20:36 -070056
Oleg Nesterov485d5272010-06-04 14:14:58 -070057 return old;
Linus Torvalds1da177e2005-04-16 15:20:36 -070058}