diff options
Diffstat (limited to 'kernel/exec_domain.c')
| -rw-r--r-- | kernel/exec_domain.c | 100 |
1 files changed, 1 insertions, 99 deletions
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 @@ | |||
| 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 | |||
| 24 | static void default_handler(int, struct pt_regs *); | 23 | static void default_handler(int, struct pt_regs *); |
| 25 | |||
| 26 | static struct exec_domain *exec_domains = &default_exec_domain; | ||
| 27 | static DEFINE_RWLOCK(exec_domains_lock); | ||
| 28 | |||
| 29 | |||
| 30 | static unsigned long ident_map[32] = { | 24 | static unsigned long ident_map[32] = { |
| 31 | 0, 1, 2, 3, 4, 5, 6, 7, | 25 | 0, 1, 2, 3, 4, 5, 6, 7, |
| 32 | 8, 9, 10, 11, 12, 13, 14, 15, | 26 | 8, 9, 10, 11, 12, 13, 14, 15, |
| @@ -55,94 +49,9 @@ default_handler(int segment, struct pt_regs *regp) | |||
| 55 | send_sig(SIGSEGV, current, 1); | 49 | send_sig(SIGSEGV, current, 1); |
| 56 | } | 50 | } |
| 57 | 51 | ||
| 58 | static struct exec_domain * | ||
| 59 | lookup_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; | ||
| 84 | out: | ||
| 85 | read_unlock(&exec_domains_lock); | ||
| 86 | return ep; | ||
| 87 | } | ||
| 88 | |||
| 89 | int | ||
| 90 | register_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 | |||
| 111 | out: | ||
| 112 | write_unlock(&exec_domains_lock); | ||
| 113 | return err; | ||
| 114 | } | ||
| 115 | EXPORT_SYMBOL(register_exec_domain); | ||
| 116 | |||
| 117 | int | ||
| 118 | unregister_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 | |||
| 131 | unregister: | ||
| 132 | *epp = ep->next; | ||
| 133 | ep->next = NULL; | ||
| 134 | write_unlock(&exec_domains_lock); | ||
| 135 | return 0; | ||
| 136 | } | ||
| 137 | EXPORT_SYMBOL(unregister_exec_domain); | ||
| 138 | |||
| 139 | int __set_personality(unsigned int personality) | 52 | int __set_personality(unsigned int personality) |
| 140 | { | 53 | { |
| 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; | 54 | current->personality = personality; |
| 145 | module_put(oep->module); | ||
| 146 | 55 | ||
| 147 | return 0; | 56 | return 0; |
| 148 | } | 57 | } |
| @@ -151,14 +60,7 @@ EXPORT_SYMBOL(__set_personality); | |||
| 151 | #ifdef CONFIG_PROC_FS | 60 | #ifdef CONFIG_PROC_FS |
| 152 | static int execdomains_proc_show(struct seq_file *m, void *v) | 61 | static int execdomains_proc_show(struct seq_file *m, void *v) |
| 153 | { | 62 | { |
| 154 | struct exec_domain *ep; | 63 | 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; | 64 | return 0; |
| 163 | } | 65 | } |
| 164 | 66 | ||
