]>
Commit | Line | Data |
---|---|---|
321d628a FG |
1 | From 34b5c16ae093e5663c398c87569793bfbec1c7ca Mon Sep 17 00:00:00 2001 |
2 | From: Ricardo Neri <ricardo.neri-calderon@linux.intel.com> | |
3 | Date: Fri, 27 Oct 2017 13:25:30 -0700 | |
633c5ed1 | 4 | Subject: [PATCH 085/242] ptrace,x86: Make user_64bit_mode() available to |
321d628a FG |
5 | 32-bit builds |
6 | MIME-Version: 1.0 | |
7 | Content-Type: text/plain; charset=UTF-8 | |
8 | Content-Transfer-Encoding: 8bit | |
9 | ||
10 | CVE-2017-5754 | |
11 | ||
12 | In its current form, user_64bit_mode() can only be used when CONFIG_X86_64 | |
13 | is selected. This implies that code built with CONFIG_X86_64=n cannot use | |
14 | it. If a piece of code needs to be built for both CONFIG_X86_64=y and | |
15 | CONFIG_X86_64=n and wants to use this function, it needs to wrap it in | |
16 | an #ifdef/#endif; potentially, in multiple places. | |
17 | ||
18 | This can be easily avoided with a single #ifdef/#endif pair within | |
19 | user_64bit_mode() itself. | |
20 | ||
21 | Suggested-by: Borislav Petkov <bp@suse.de> | |
22 | Signed-off-by: Ricardo Neri <ricardo.neri-calderon@linux.intel.com> | |
23 | Signed-off-by: Thomas Gleixner <tglx@linutronix.de> | |
24 | Reviewed-by: Borislav Petkov <bp@suse.de> | |
25 | Cc: "Michael S. Tsirkin" <mst@redhat.com> | |
26 | Cc: Peter Zijlstra <peterz@infradead.org> | |
27 | Cc: Dave Hansen <dave.hansen@linux.intel.com> | |
28 | Cc: ricardo.neri@intel.com | |
29 | Cc: Adrian Hunter <adrian.hunter@intel.com> | |
30 | Cc: Paul Gortmaker <paul.gortmaker@windriver.com> | |
31 | Cc: Huang Rui <ray.huang@amd.com> | |
32 | Cc: Qiaowei Ren <qiaowei.ren@intel.com> | |
33 | Cc: Shuah Khan <shuah@kernel.org> | |
34 | Cc: Kees Cook <keescook@chromium.org> | |
35 | Cc: Jonathan Corbet <corbet@lwn.net> | |
36 | Cc: Jiri Slaby <jslaby@suse.cz> | |
37 | Cc: Dmitry Vyukov <dvyukov@google.com> | |
38 | Cc: "Ravi V. Shankar" <ravi.v.shankar@intel.com> | |
39 | Cc: Chris Metcalf <cmetcalf@mellanox.com> | |
40 | Cc: Brian Gerst <brgerst@gmail.com> | |
41 | Cc: Arnaldo Carvalho de Melo <acme@redhat.com> | |
42 | Cc: Andy Lutomirski <luto@kernel.org> | |
43 | Cc: Colin Ian King <colin.king@canonical.com> | |
44 | Cc: Chen Yucong <slaoub@gmail.com> | |
45 | Cc: Adam Buchbinder <adam.buchbinder@gmail.com> | |
46 | Cc: Vlastimil Babka <vbabka@suse.cz> | |
47 | Cc: Lorenzo Stoakes <lstoakes@gmail.com> | |
48 | Cc: Masami Hiramatsu <mhiramat@kernel.org> | |
49 | Cc: Paolo Bonzini <pbonzini@redhat.com> | |
50 | Cc: Andrew Morton <akpm@linux-foundation.org> | |
51 | Cc: Thomas Garnier <thgarnie@google.com> | |
52 | Link: https://lkml.kernel.org/r/1509135945-13762-4-git-send-email-ricardo.neri-calderon@linux.intel.com | |
53 | ||
54 | (cherry picked from commit e27c310af5c05cf876d9cad006928076c27f54d4) | |
55 | Signed-off-by: Andy Whitcroft <apw@canonical.com> | |
56 | Signed-off-by: Kleber Sacilotto de Souza <kleber.souza@canonical.com> | |
57 | (cherry picked from commit 20ddf08f867d3d96788299cd2fb7676590d64250) | |
58 | Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com> | |
59 | --- | |
60 | arch/x86/include/asm/ptrace.h | 6 +++++- | |
61 | 1 file changed, 5 insertions(+), 1 deletion(-) | |
62 | ||
63 | diff --git a/arch/x86/include/asm/ptrace.h b/arch/x86/include/asm/ptrace.h | |
64 | index 2b5d686ea9f3..ea78a8438a8a 100644 | |
65 | --- a/arch/x86/include/asm/ptrace.h | |
66 | +++ b/arch/x86/include/asm/ptrace.h | |
67 | @@ -115,9 +115,9 @@ static inline int v8086_mode(struct pt_regs *regs) | |
68 | #endif | |
69 | } | |
70 | ||
71 | -#ifdef CONFIG_X86_64 | |
72 | static inline bool user_64bit_mode(struct pt_regs *regs) | |
73 | { | |
74 | +#ifdef CONFIG_X86_64 | |
75 | #ifndef CONFIG_PARAVIRT | |
76 | /* | |
77 | * On non-paravirt systems, this is the only long mode CPL 3 | |
78 | @@ -128,8 +128,12 @@ static inline bool user_64bit_mode(struct pt_regs *regs) | |
79 | /* Headers are too twisted for this to go in paravirt.h. */ | |
80 | return regs->cs == __USER_CS || regs->cs == pv_info.extra_user_64bit_cs; | |
81 | #endif | |
82 | +#else /* !CONFIG_X86_64 */ | |
83 | + return false; | |
84 | +#endif | |
85 | } | |
86 | ||
87 | +#ifdef CONFIG_X86_64 | |
88 | #define current_user_stack_pointer() current_pt_regs()->sp | |
89 | #define compat_user_stack_pointer() current_pt_regs()->sp | |
90 | #endif | |
91 | -- | |
92 | 2.14.2 | |
93 |