uprobes/x86: Fix is_64bit_mm() with CONFIG_X86_X32
authorOleg Nesterov <oleg@redhat.com>
Sat, 19 Apr 2014 16:10:09 +0000 (18:10 +0200)
committerOleg Nesterov <oleg@redhat.com>
Wed, 30 Apr 2014 17:10:35 +0000 (19:10 +0200)
is_64bit_mm() assumes that mm->context.ia32_compat means the 32-bit
instruction set, this is not true if the task is TIF_X32.

Change set_personality_ia32() to initialize mm->context.ia32_compat
by TIF_X32 or TIF_IA32 instead of 1. This allows to fix is_64bit_mm()
without affecting other users, they all treat ia32_compat as "bool".

TIF_ in ->ia32_compat looks a bit strange, but this is grep-friendly
and avoids the new define's.

Signed-off-by: Oleg Nesterov <oleg@redhat.com>
Reviewed-by: Jim Keniston <jkenisto@us.ibm.com>
Acked-by: Srikar Dronamraju <srikar@linux.vnet.ibm.com>
arch/x86/kernel/process_64.c
arch/x86/kernel/uprobes.c

index 9c0280f93d05dbf9b644abd040b472b9c69d4f55..9b53940981b7c9e434ea48ad374eae11dc846fd3 100644 (file)
@@ -413,12 +413,11 @@ void set_personality_ia32(bool x32)
        set_thread_flag(TIF_ADDR32);
 
        /* Mark the associated mm as containing 32-bit tasks. */
-       if (current->mm)
-               current->mm->context.ia32_compat = 1;
-
        if (x32) {
                clear_thread_flag(TIF_IA32);
                set_thread_flag(TIF_X32);
+               if (current->mm)
+                       current->mm->context.ia32_compat = TIF_X32;
                current->personality &= ~READ_IMPLIES_EXEC;
                /* is_compat_task() uses the presence of the x32
                   syscall bit flag to determine compat status */
@@ -426,6 +425,8 @@ void set_personality_ia32(bool x32)
        } else {
                set_thread_flag(TIF_IA32);
                clear_thread_flag(TIF_X32);
+               if (current->mm)
+                       current->mm->context.ia32_compat = TIF_IA32;
                current->personality |= force_personality32;
                /* Prepare the first "return" to user space */
                current_thread_info()->status |= TS_COMPAT;
index 892975b3c99c5cd5318885c7fa45783f8a2bef4a..ecbffd16d09057c058e3b4f52432d2397ff7c02c 100644 (file)
@@ -245,7 +245,7 @@ static int uprobe_init_insn(struct arch_uprobe *auprobe, struct insn *insn, bool
 static inline bool is_64bit_mm(struct mm_struct *mm)
 {
        return  !config_enabled(CONFIG_IA32_EMULATION) ||
-               !mm->context.ia32_compat;
+               !(mm->context.ia32_compat == TIF_IA32);
 }
 /*
  * If arch_uprobe->insn doesn't use rip-relative addressing, return