Cleanup, no functional changes. - __set_personality() always changes ->exec_domain/personality, the special case when ->exec_domain remains the same buys nothing but complicates the code. Unify both cases to simplify the code. - The -EINVAL check in sys_personality() was never right. If we assume that set_personality() can fail we should check the value it returns instead of verifying that task->personality was actually changed. Remove it. Before the previous patch it was possible to hit this case due to overflow problems, but this -EINVAL just indicated the kernel bug. OTOH, probably it makes sense to change lookup_exec_domain() to return ERR_PTR() instead of default_exec_domain if the search in exec_domains list fails, and report this error to the user-space. But this means another user-space change, and we have in-kernel users which need fixes. For example, PER_OSF4 falls into PER_MASK for unkown reason and nobody cares to register this domain.
Unified · Split
| @@ -134,23 +134,14 @@ unregister: · 133 unmodified lines | ||
| 134 | 134 | return 0; |
| 135 | 135 | } |
| 136 | 136 | |
| 137 | −int | |
| 138 | −__set_personality(unsigned int personality) | |
| 137 | +int __set_personality(unsigned int personality) | |
| 139 | 138 | { |
| 140 | − struct exec_domain *ep, *oep; | |
| 141 | − | |
| 142 | − ep = lookup_exec_domain(personality); | |
| 143 | − if (ep == current_thread_info()->exec_domain) { | |
| 144 | − current->personality = personality; | |
| 145 | − module_put(ep->module); | |
| 146 | − return 0; | |
| 147 | − } | |
| 139 | + struct exec_domain *oep = current_thread_info()->exec_domain; | |
| 148 | 140 | |
| 141 | + current_thread_info()->exec_domain = lookup_exec_domain(personality); | |
| 149 | 142 | current->personality = personality; |
| 150 | − oep = current_thread_info()->exec_domain; | |
| 151 | − current_thread_info()->exec_domain = ep; | |
| 152 | − | |
| 153 | 143 | module_put(oep->module); |
| 144 | + | |
| 154 | 145 | return 0; |
| 155 | 146 | } |
| 156 | 147 | |
| @@ -192,11 +183,8 @@ SYSCALL_DEFINE1(personality, unsigned int, personality) · 35 unmodified lines | ||
| 192 | 183 | { |
| 193 | 184 | unsigned int old = current->personality; |
| 194 | 185 | |
| 195 | − if (personality != 0xffffffff) { | |
| 186 | + if (personality != 0xffffffff) | |
| 196 | 187 | set_personality(personality); |
| 197 | − if (current->personality != personality) | |
| 198 | − return -EINVAL; | |
| 199 | − } | |
| 200 | 188 | |
| 201 | 189 | return old; |
| 202 | 190 | } |