aboutsummaryrefslogtreecommitdiffstats
path: root/kernel
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2015-04-15 16:53:55 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2015-04-15 16:53:55 -0400
commitfa2e5c073a355465a2a8c9a2fbecf404f9857c3a (patch)
tree771be75e5436031ad53649634dffa67f6667b083 /kernel
parente44740c1a94b5d39b093045920f543a7bc135584 (diff)
parent97b2f0dc331474fb80ba4f4e4aee1d8e9ffbf7ce (diff)
Merge branch 'exec_domain_rip_v2' of git://git.kernel.org/pub/scm/linux/kernel/git/rw/misc
Pull exec domain removal from Richard Weinberger: "This series removes execution domain support from Linux. The idea behind exec domains was to support different ABIs. The feature was never complete nor stable. Let's rip it out and make the kernel signal handling code less complicated" * 'exec_domain_rip_v2' of git://git.kernel.org/pub/scm/linux/kernel/git/rw/misc: (27 commits) arm64: Removed unused variable sparc: Fix execution domain removal Remove rest of exec domains. arch: Remove exec_domain from remaining archs arc: Remove signal translation and exec_domain xtensa: Remove signal translation and exec_domain xtensa: Autogenerate offsets in struct thread_info x86: Remove signal translation and exec_domain unicore32: Remove signal translation and exec_domain um: Remove signal translation and exec_domain tile: Remove signal translation and exec_domain sparc: Remove signal translation and exec_domain sh: Remove signal translation and exec_domain s390: Remove signal translation and exec_domain mn10300: Remove signal translation and exec_domain microblaze: Remove signal translation and exec_domain m68k: Remove signal translation and exec_domain m32r: Remove signal translation and exec_domain m32r: Autogenerate offsets in struct thread_info frv: Remove signal translation and exec_domain ...
Diffstat (limited to 'kernel')
-rw-r--r--kernel/exec_domain.c137
-rw-r--r--kernel/exit.c2
-rw-r--r--kernel/fork.c4
3 files changed, 1 insertions, 142 deletions
diff --git a/kernel/exec_domain.c b/kernel/exec_domain.c
index 83d4382f5699..6873bb3e6b7e 100644
--- a/kernel/exec_domain.c
+++ b/kernel/exec_domain.c
@@ -20,145 +20,10 @@
20#include <linux/types.h> 20#include <linux/types.h>
21#include <linux/fs_struct.h> 21#include <linux/fs_struct.h>
22 22
23
24static void default_handler(int, struct pt_regs *);
25
26static struct exec_domain *exec_domains = &default_exec_domain;
27static DEFINE_RWLOCK(exec_domains_lock);
28
29
30static unsigned long ident_map[32] = {
31 0, 1, 2, 3, 4, 5, 6, 7,
32 8, 9, 10, 11, 12, 13, 14, 15,
33 16, 17, 18, 19, 20, 21, 22, 23,
34 24, 25, 26, 27, 28, 29, 30, 31
35};
36
37struct exec_domain default_exec_domain = {
38 .name = "Linux", /* name */
39 .handler = default_handler, /* lcall7 causes a seg fault. */
40 .pers_low = 0, /* PER_LINUX personality. */
41 .pers_high = 0, /* PER_LINUX personality. */
42 .signal_map = ident_map, /* Identity map signals. */
43 .signal_invmap = ident_map, /* - both ways. */
44};
45
46
47static void
48default_handler(int segment, struct pt_regs *regp)
49{
50 set_personality(0);
51
52 if (current_thread_info()->exec_domain->handler != default_handler)
53 current_thread_info()->exec_domain->handler(segment, regp);
54 else
55 send_sig(SIGSEGV, current, 1);
56}
57
58static struct exec_domain *
59lookup_exec_domain(unsigned int personality)
60{
61 unsigned int pers = personality(personality);
62 struct exec_domain *ep;
63
64 read_lock(&exec_domains_lock);
65 for (ep = exec_domains; ep; ep = ep->next) {
66 if (pers >= ep->pers_low && pers <= ep->pers_high)
67 if (try_module_get(ep->module))
68 goto out;
69 }
70
71#ifdef CONFIG_MODULES
72 read_unlock(&exec_domains_lock);
73 request_module("personality-%d", pers);
74 read_lock(&exec_domains_lock);
75
76 for (ep = exec_domains; ep; ep = ep->next) {
77 if (pers >= ep->pers_low && pers <= ep->pers_high)
78 if (try_module_get(ep->module))
79 goto out;
80 }
81#endif
82
83 ep = &default_exec_domain;
84out:
85 read_unlock(&exec_domains_lock);
86 return ep;
87}
88
89int
90register_exec_domain(struct exec_domain *ep)
91{
92 struct exec_domain *tmp;
93 int err = -EBUSY;
94
95 if (ep == NULL)
96 return -EINVAL;
97
98 if (ep->next != NULL)
99 return -EBUSY;
100
101 write_lock(&exec_domains_lock);
102 for (tmp = exec_domains; tmp; tmp = tmp->next) {
103 if (tmp == ep)
104 goto out;
105 }
106
107 ep->next = exec_domains;
108 exec_domains = ep;
109 err = 0;
110
111out:
112 write_unlock(&exec_domains_lock);
113 return err;
114}
115EXPORT_SYMBOL(register_exec_domain);
116
117int
118unregister_exec_domain(struct exec_domain *ep)
119{
120 struct exec_domain **epp;
121
122 epp = &exec_domains;
123 write_lock(&exec_domains_lock);
124 for (epp = &exec_domains; *epp; epp = &(*epp)->next) {
125 if (ep == *epp)
126 goto unregister;
127 }
128 write_unlock(&exec_domains_lock);
129 return -EINVAL;
130
131unregister:
132 *epp = ep->next;
133 ep->next = NULL;
134 write_unlock(&exec_domains_lock);
135 return 0;
136}
137EXPORT_SYMBOL(unregister_exec_domain);
138
139int __set_personality(unsigned int personality)
140{
141 struct exec_domain *oep = current_thread_info()->exec_domain;
142
143 current_thread_info()->exec_domain = lookup_exec_domain(personality);
144 current->personality = personality;
145 module_put(oep->module);
146
147 return 0;
148}
149EXPORT_SYMBOL(__set_personality);
150
151#ifdef CONFIG_PROC_FS 23#ifdef CONFIG_PROC_FS
152static int execdomains_proc_show(struct seq_file *m, void *v) 24static int execdomains_proc_show(struct seq_file *m, void *v)
153{ 25{
154 struct exec_domain *ep; 26 seq_puts(m, "0-0\tLinux \t[kernel]\n");
155
156 read_lock(&exec_domains_lock);
157 for (ep = exec_domains; ep; ep = ep->next)
158 seq_printf(m, "%d-%d\t%-16s\t[%s]\n",
159 ep->pers_low, ep->pers_high, ep->name,
160 module_name(ep->module));
161 read_unlock(&exec_domains_lock);
162 return 0; 27 return 0;
163} 28}
164 29
diff --git a/kernel/exit.c b/kernel/exit.c
index feff10bbb307..22fcc05dec40 100644
--- a/kernel/exit.c
+++ b/kernel/exit.c
@@ -756,8 +756,6 @@ void do_exit(long code)
756 756
757 cgroup_exit(tsk); 757 cgroup_exit(tsk);
758 758
759 module_put(task_thread_info(tsk)->exec_domain->module);
760
761 /* 759 /*
762 * FIXME: do that only when needed, using sched_exit tracepoint 760 * FIXME: do that only when needed, using sched_exit tracepoint
763 */ 761 */
diff --git a/kernel/fork.c b/kernel/fork.c
index cf65139615a0..f2c1e7352298 100644
--- a/kernel/fork.c
+++ b/kernel/fork.c
@@ -1279,9 +1279,6 @@ static struct task_struct *copy_process(unsigned long clone_flags,
1279 if (nr_threads >= max_threads) 1279 if (nr_threads >= max_threads)
1280 goto bad_fork_cleanup_count; 1280 goto bad_fork_cleanup_count;
1281 1281
1282 if (!try_module_get(task_thread_info(p)->exec_domain->module))
1283 goto bad_fork_cleanup_count;
1284
1285 delayacct_tsk_init(p); /* Must remain after dup_task_struct() */ 1282 delayacct_tsk_init(p); /* Must remain after dup_task_struct() */
1286 p->flags &= ~(PF_SUPERPRIV | PF_WQ_WORKER); 1283 p->flags &= ~(PF_SUPERPRIV | PF_WQ_WORKER);
1287 p->flags |= PF_FORKNOEXEC; 1284 p->flags |= PF_FORKNOEXEC;
@@ -1590,7 +1587,6 @@ bad_fork_cleanup_threadgroup_lock:
1590 if (clone_flags & CLONE_THREAD) 1587 if (clone_flags & CLONE_THREAD)
1591 threadgroup_change_end(current); 1588 threadgroup_change_end(current);
1592 delayacct_tsk_free(p); 1589 delayacct_tsk_free(p);
1593 module_put(task_thread_info(p)->exec_domain->module);
1594bad_fork_cleanup_count: 1590bad_fork_cleanup_count:
1595 atomic_dec(&p->cred->user->processes); 1591 atomic_dec(&p->cred->user->processes);
1596 exit_creds(p); 1592 exit_creds(p);