x86/asm/entry, perf: Fix incorrect TIF_IA32 check in code_segment_base()
authorAndy Lutomirski <luto@kernel.org>
Thu, 19 Mar 2015 01:33:28 +0000 (18:33 -0700)
committerIngo Molnar <mingo@kernel.org>
Mon, 23 Mar 2015 09:08:21 +0000 (10:08 +0100)
We want to check whether user code is in 32-bit mode, not
whether the task is nominally 32-bit.

Signed-off-by: Andy Lutomirski <luto@kernel.org>
Cc: Borislav Petkov <bp@alien8.de>
Cc: Brad Spengler <spender@grsecurity.net>
Cc: Denys Vlasenko <dvlasenk@redhat.com>
Cc: H. Peter Anvin <hpa@zytor.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Link: http://lkml.kernel.org/r/33e5107085ce347a8303560302b15c2cadd62c4c.1426728647.git.luto@kernel.org
Signed-off-by: Ingo Molnar <mingo@kernel.org>
arch/x86/kernel/cpu/perf_event.c

index b71a7f86d68aca8ba6dd864e9c8cf15e2b3d28ba..979963bb3977e10194a3ad79a3fda717a9d5786d 100644 (file)
@@ -2161,10 +2161,9 @@ static unsigned long code_segment_base(struct pt_regs *regs)
        if (user_mode(regs) && regs->cs != __USER_CS)
                return get_segment_base(regs->cs);
 #else
-       if (test_thread_flag(TIF_IA32)) {
-               if (user_mode(regs) && regs->cs != __USER32_CS)
-                       return get_segment_base(regs->cs);
-       }
+       if (user_mode(regs) && !user_64bit_mode(regs) &&
+           regs->cs != __USER32_CS)
+               return get_segment_base(regs->cs);
 #endif
        return 0;
 }