blob: 33f07c5f25150790bcbbd057171b467b5c0ed2b6 [file] [log] [blame]
Greg Kroah-Hartmanb2441312017-11-01 15:07:57 +01001// SPDX-License-Identifier: GPL-2.0
Linus Torvalds1da177e2005-04-16 15:20:36 -07002/*
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 Torvalds1da177e2005-04-16 15:20:36 -070011#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 Dobriyan6e627752008-10-04 14:28:09 +040016#include <linux/proc_fs.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070017#include <linux/sched.h>
Alexey Dobriyan6e627752008-10-04 14:28:09 +040018#include <linux/seq_file.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070019#include <linux/syscalls.h>
20#include <linux/sysctl.h>
21#include <linux/types.h>
22
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 __init proc_execdomains_init(void)
31{
Christoph Hellwig3f3942a2018-05-15 15:57:23 +020032 proc_create_single("execdomains", 0, NULL, execdomains_proc_show);
Alexey Dobriyan6e627752008-10-04 14:28:09 +040033 return 0;
34}
35module_init(proc_execdomains_init);
36#endif
37
Oleg Nesterov485d5272010-06-04 14:14:58 -070038SYSCALL_DEFINE1(personality, unsigned int, personality)
Linus Torvalds1da177e2005-04-16 15:20:36 -070039{
Oleg Nesterov485d5272010-06-04 14:14:58 -070040 unsigned int old = current->personality;
Linus Torvalds1da177e2005-04-16 15:20:36 -070041
Oleg Nesterov2ee7c922010-08-09 17:20:30 -070042 if (personality != 0xffffffff)
Linus Torvalds1da177e2005-04-16 15:20:36 -070043 set_personality(personality);
Linus Torvalds1da177e2005-04-16 15:20:36 -070044
Oleg Nesterov485d5272010-06-04 14:14:58 -070045 return old;
Linus Torvalds1da177e2005-04-16 15:20:36 -070046}