There is some work that should be done after setting the personality. Currently it's done in the macro, which is not the best idea. In this patch new arch_setup_new_exec() routine is introduced, and all setup code is moved there, as suggested by Catalin: https://lkml.org/lkml/2017/8/4/494
Unified · Split
| @@ -139,7 +139,6 @@ typedef struct user_fpsimd_state elf_fpregset_t; · 138 unmodified lines | ||
| 139 | 139 | |
| 140 | 140 | #define SET_PERSONALITY(ex) \ |
| 141 | 141 | ({ \ |
| 142 | − current->mm->context.flags = 0; \ | |
| 143 | 142 | clear_thread_flag(TIF_32BIT); \ |
| 144 | 143 | current->personality &= ~READ_IMPLIES_EXEC; \ |
| 145 | 144 | }) |
| @@ -195,7 +194,6 @@ typedef compat_elf_greg_t compat_elf_gregset_t[COMPAT_ELF_NGREG]; · 49 unmodified lines | ||
| 195 | 194 | */ |
| 196 | 195 | #define COMPAT_SET_PERSONALITY(ex) \ |
| 197 | 196 | ({ \ |
| 198 | − current->mm->context.flags = MMCF_AARCH32; \ | |
| 199 | 197 | set_thread_flag(TIF_32BIT); \ |
| 200 | 198 | }) |
| 201 | 199 | #define COMPAT_ARCH_DLINFO |
| @@ -60,6 +60,9 @@ struct thread_info { · 59 unmodified lines | ||
| 60 | 60 | #define thread_saved_fp(tsk) \ |
| 61 | 61 | ((unsigned long)(tsk->thread.cpu_context.fp)) |
| 62 | 62 | |
| 63 | +void arch_setup_new_exec(void); | |
| 64 | +#define arch_setup_new_exec arch_setup_new_exec | |
| 65 | + | |
| 63 | 66 | #endif |
| 64 | 67 | |
| 65 | 68 | /* |
| @@ -414,3 +414,11 @@ unsigned long arch_randomize_brk(struct mm_struct *mm) · 413 unmodified lines | ||
| 414 | 414 | else |
| 415 | 415 | return randomize_page(mm->brk, SZ_1G); |
| 416 | 416 | } |
| 417 | + | |
| 418 | +/* | |
| 419 | + * Called from setup_new_exec() after (COMPAT_)SET_PERSONALITY. | |
| 420 | + */ | |
| 421 | +void arch_setup_new_exec(void) | |
| 422 | +{ | |
| 423 | + current->mm->context.flags = is_compat_task() ? MMCF_AARCH32 : 0; | |
| 424 | +} | |