From 973f911f55a0e510dd6db8bbb29cd82ff138d3c0 Mon Sep 17 00:00:00 2001 From: Richard Weinberger Date: Mon, 30 Mar 2015 08:14:16 +0200 Subject: Remove execution domain support All users of exec_domain are gone, now we can get rid of that abandoned feature. To not break existing userspace we keep a dummy /proc/execdomains file which will always contain "0-0 Linux [kernel]". Signed-off-by: Richard Weinberger --- kernel/exec_domain.c | 100 +-------------------------------------------------- kernel/exit.c | 2 -- kernel/fork.c | 4 --- 3 files changed, 1 insertion(+), 105 deletions(-) (limited to 'kernel') diff --git a/kernel/exec_domain.c b/kernel/exec_domain.c index 83d4382f5699..b2fb57d6b9b2 100644 --- a/kernel/exec_domain.c +++ b/kernel/exec_domain.c @@ -20,13 +20,7 @@ #include #include - static void default_handler(int, struct pt_regs *); - -static struct exec_domain *exec_domains = &default_exec_domain; -static DEFINE_RWLOCK(exec_domains_lock); - - static unsigned long ident_map[32] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, @@ -55,94 +49,9 @@ default_handler(int segment, struct pt_regs *regp) send_sig(SIGSEGV, current, 1); } -static struct exec_domain * -lookup_exec_domain(unsigned int personality) -{ - unsigned int pers = personality(personality); - struct exec_domain *ep; - - read_lock(&exec_domains_lock); - for (ep = exec_domains; ep; ep = ep->next) { - if (pers >= ep->pers_low && pers <= ep->pers_high) - if (try_module_get(ep->module)) - goto out; - } - -#ifdef CONFIG_MODULES - read_unlock(&exec_domains_lock); - request_module("personality-%d", pers); - read_lock(&exec_domains_lock); - - for (ep = exec_domains; ep; ep = ep->next) { - if (pers >= ep->pers_low && pers <= ep->pers_high) - if (try_module_get(ep->module)) - goto out; - } -#endif - - ep = &default_exec_domain; -out: - read_unlock(&exec_domains_lock); - return ep; -} - -int -register_exec_domain(struct exec_domain *ep) -{ - struct exec_domain *tmp; - int err = -EBUSY; - - if (ep == NULL) - return -EINVAL; - - if (ep->next != NULL) - return -EBUSY; - - write_lock(&exec_domains_lock); - for (tmp = exec_domains; tmp; tmp = tmp->next) { - if (tmp == ep) - goto out; - } - - ep->next = exec_domains; - exec_domains = ep; - err = 0; - -out: - write_unlock(&exec_domains_lock); - return err; -} -EXPORT_SYMBOL(register_exec_domain); - -int -unregister_exec_domain(struct exec_domain *ep) -{ - struct exec_domain **epp; - - epp = &exec_domains; - write_lock(&exec_domains_lock); - for (epp = &exec_domains; *epp; epp = &(*epp)->next) { - if (ep == *epp) - goto unregister; - } - write_unlock(&exec_domains_lock); - return -EINVAL; - -unregister: - *epp = ep->next; - ep->next = NULL; - write_unlock(&exec_domains_lock); - return 0; -} -EXPORT_SYMBOL(unregister_exec_domain); - int __set_personality(unsigned int personality) { - struct exec_domain *oep = current_thread_info()->exec_domain; - - current_thread_info()->exec_domain = lookup_exec_domain(personality); current->personality = personality; - module_put(oep->module); return 0; } @@ -151,14 +60,7 @@ EXPORT_SYMBOL(__set_personality); #ifdef CONFIG_PROC_FS static int execdomains_proc_show(struct seq_file *m, void *v) { - struct exec_domain *ep; - - read_lock(&exec_domains_lock); - for (ep = exec_domains; ep; ep = ep->next) - seq_printf(m, "%d-%d\t%-16s\t[%s]\n", - ep->pers_low, ep->pers_high, ep->name, - module_name(ep->module)); - read_unlock(&exec_domains_lock); + seq_puts(m, "0-0\tLinux \t[kernel]\n"); return 0; } 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) cgroup_exit(tsk); - module_put(task_thread_info(tsk)->exec_domain->module); - /* * FIXME: do that only when needed, using sched_exit tracepoint */ 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, if (nr_threads >= max_threads) goto bad_fork_cleanup_count; - if (!try_module_get(task_thread_info(p)->exec_domain->module)) - goto bad_fork_cleanup_count; - delayacct_tsk_init(p); /* Must remain after dup_task_struct() */ p->flags &= ~(PF_SUPERPRIV | PF_WQ_WORKER); p->flags |= PF_FORKNOEXEC; @@ -1590,7 +1587,6 @@ bad_fork_cleanup_threadgroup_lock: if (clone_flags & CLONE_THREAD) threadgroup_change_end(current); delayacct_tsk_free(p); - module_put(task_thread_info(p)->exec_domain->module); bad_fork_cleanup_count: atomic_dec(&p->cred->user->processes); exit_creds(p); -- cgit v1.2.3 From 9058f3b326dbe8cd2ebea7f3cfe367b0d101039b Mon Sep 17 00:00:00 2001 From: Richard Weinberger Date: Sat, 11 Apr 2015 21:45:22 +0200 Subject: Remove rest of exec domains. It is gone from all archs, now we can remove the final bits. Signed-off-by: Richard Weinberger --- include/linux/personality.h | 40 +--------------------------------------- include/linux/sched.h | 6 ------ kernel/exec_domain.c | 37 ------------------------------------- 3 files changed, 1 insertion(+), 82 deletions(-) (limited to 'kernel') diff --git a/include/linux/personality.h b/include/linux/personality.h index 646c0a7d50fa..aeb7892b2468 100644 --- a/include/linux/personality.h +++ b/include/linux/personality.h @@ -3,52 +3,14 @@ #include - -/* - * Handling of different ABIs (personalities). - */ - -struct exec_domain; -struct pt_regs; - -extern int register_exec_domain(struct exec_domain *); -extern int unregister_exec_domain(struct exec_domain *); -extern int __set_personality(unsigned int); - - -/* - * Description of an execution domain. - * - * The first two members are refernced from assembly source - * and should stay where they are unless explicitly needed. - */ -typedef void (*handler_t)(int, struct pt_regs *); - -struct exec_domain { - const char *name; /* name of the execdomain */ - handler_t handler; /* handler for syscalls */ - unsigned char pers_low; /* lowest personality */ - unsigned char pers_high; /* highest personality */ - unsigned long *signal_map; /* signal mapping */ - unsigned long *signal_invmap; /* reverse signal mapping */ - struct map_segment *err_map; /* error mapping */ - struct map_segment *socktype_map; /* socket type mapping */ - struct map_segment *sockopt_map; /* socket option mapping */ - struct map_segment *af_map; /* address family mapping */ - struct module *module; /* module context of the ed. */ - struct exec_domain *next; /* linked list (internal) */ -}; - /* * Return the base personality without flags. */ #define personality(pers) (pers & PER_MASK) - /* * Change personality of the currently running process. */ -#define set_personality(pers) \ - ((current->personality == (pers)) ? 0 : __set_personality(pers)) +#define set_personality(pers) (current->personality = (pers)) #endif /* _LINUX_PERSONALITY_H */ diff --git a/include/linux/sched.h b/include/linux/sched.h index a419b65770d6..14d9117ac463 100644 --- a/include/linux/sched.h +++ b/include/linux/sched.h @@ -125,7 +125,6 @@ struct sched_attr { u64 sched_period; }; -struct exec_domain; struct futex_pi_state; struct robust_list_head; struct bio_list; @@ -2288,11 +2287,6 @@ extern void set_curr_task(int cpu, struct task_struct *p); void yield(void); -/* - * The default (Linux) execution domain. - */ -extern struct exec_domain default_exec_domain; - union thread_union { struct thread_info thread_info; unsigned long stack[THREAD_SIZE/sizeof(long)]; diff --git a/kernel/exec_domain.c b/kernel/exec_domain.c index b2fb57d6b9b2..6873bb3e6b7e 100644 --- a/kernel/exec_domain.c +++ b/kernel/exec_domain.c @@ -20,43 +20,6 @@ #include #include -static void default_handler(int, struct pt_regs *); -static unsigned long ident_map[32] = { - 0, 1, 2, 3, 4, 5, 6, 7, - 8, 9, 10, 11, 12, 13, 14, 15, - 16, 17, 18, 19, 20, 21, 22, 23, - 24, 25, 26, 27, 28, 29, 30, 31 -}; - -struct exec_domain default_exec_domain = { - .name = "Linux", /* name */ - .handler = default_handler, /* lcall7 causes a seg fault. */ - .pers_low = 0, /* PER_LINUX personality. */ - .pers_high = 0, /* PER_LINUX personality. */ - .signal_map = ident_map, /* Identity map signals. */ - .signal_invmap = ident_map, /* - both ways. */ -}; - - -static void -default_handler(int segment, struct pt_regs *regp) -{ - set_personality(0); - - if (current_thread_info()->exec_domain->handler != default_handler) - current_thread_info()->exec_domain->handler(segment, regp); - else - send_sig(SIGSEGV, current, 1); -} - -int __set_personality(unsigned int personality) -{ - current->personality = personality; - - return 0; -} -EXPORT_SYMBOL(__set_personality); - #ifdef CONFIG_PROC_FS static int execdomains_proc_show(struct seq_file *m, void *v) { -- cgit v1.2.3