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