aboutsummaryrefslogtreecommitdiffstats
path: root/arch/x86/kernel
diff options
context:
space:
mode:
authorAndy Lutomirski <luto@MIT.EDU>2011-06-05 13:50:19 -0400
committerIngo Molnar <mingo@elte.hu>2011-06-05 15:30:32 -0400
commit9fd67b4ed0714ab718f1f9bd14c344af336a6df7 (patch)
tree7dae7e978b68479b6ee316d92b81d703cee3a894 /arch/x86/kernel
parent8b4777a4b50cb0c84c1152eac85d24415fb6ff7d (diff)
x86-64: Give vvars their own page
Move vvars out of the vsyscall page into their own page and mark it NX. Without this patch, an attacker who can force a daemon to call some fixed address could wait until the time contains, say, 0xCD80, and then execute the current time. Signed-off-by: Andy Lutomirski <luto@mit.edu> Cc: Jesper Juhl <jj@chaosbits.net> Cc: Borislav Petkov <bp@alien8.de> Cc: Linus Torvalds <torvalds@linux-foundation.org> Cc: Arjan van de Ven <arjan@infradead.org> Cc: Jan Beulich <JBeulich@novell.com> Cc: richard -rw- weinberger <richard.weinberger@gmail.com> Cc: Mikael Pettersson <mikpe@it.uu.se> Cc: Andi Kleen <andi@firstfloor.org> Cc: Brian Gerst <brgerst@gmail.com> Cc: Louis Rilling <Louis.Rilling@kerlabs.com> Cc: Valdis.Kletnieks@vt.edu Cc: pageexec@freemail.hu Link: http://lkml.kernel.org/r/b1460f81dc4463d66ea3f2b5ce240f58d48effec.1307292171.git.luto@mit.edu Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'arch/x86/kernel')
-rw-r--r--arch/x86/kernel/vmlinux.lds.S28
-rw-r--r--arch/x86/kernel/vsyscall_64.c5
2 files changed, 22 insertions, 11 deletions
diff --git a/arch/x86/kernel/vmlinux.lds.S b/arch/x86/kernel/vmlinux.lds.S
index 89aed99aafce..98b378dc7f86 100644
--- a/arch/x86/kernel/vmlinux.lds.S
+++ b/arch/x86/kernel/vmlinux.lds.S
@@ -161,12 +161,6 @@ SECTIONS
161 161
162#define VVIRT_OFFSET (VSYSCALL_ADDR - __vsyscall_0) 162#define VVIRT_OFFSET (VSYSCALL_ADDR - __vsyscall_0)
163#define VVIRT(x) (ADDR(x) - VVIRT_OFFSET) 163#define VVIRT(x) (ADDR(x) - VVIRT_OFFSET)
164#define EMIT_VVAR(x, offset) .vsyscall_var_ ## x \
165 ADDR(.vsyscall_0) + offset \
166 : AT(VLOAD(.vsyscall_var_ ## x)) { \
167 *(.vsyscall_var_ ## x) \
168 } \
169 x = VVIRT(.vsyscall_var_ ## x);
170 164
171 . = ALIGN(4096); 165 . = ALIGN(4096);
172 __vsyscall_0 = .; 166 __vsyscall_0 = .;
@@ -192,19 +186,31 @@ SECTIONS
192 *(.vsyscall_3) 186 *(.vsyscall_3)
193 } 187 }
194 188
195#define __VVAR_KERNEL_LDS 189 . = ALIGN(__vsyscall_0 + PAGE_SIZE, PAGE_SIZE);
196#include <asm/vvar.h>
197#undef __VVAR_KERNEL_LDS
198
199 . = __vsyscall_0 + PAGE_SIZE;
200 190
201#undef VSYSCALL_ADDR 191#undef VSYSCALL_ADDR
202#undef VLOAD_OFFSET 192#undef VLOAD_OFFSET
203#undef VLOAD 193#undef VLOAD
204#undef VVIRT_OFFSET 194#undef VVIRT_OFFSET
205#undef VVIRT 195#undef VVIRT
196
197 __vvar_page = .;
198
199 .vvar : AT(ADDR(.vvar) - LOAD_OFFSET) {
200
201 /* Place all vvars at the offsets in asm/vvar.h. */
202#define EMIT_VVAR(name, offset) \
203 . = offset; \
204 *(.vvar_ ## name)
205#define __VVAR_KERNEL_LDS
206#include <asm/vvar.h>
207#undef __VVAR_KERNEL_LDS
206#undef EMIT_VVAR 208#undef EMIT_VVAR
207 209
210 } :data
211
212 . = ALIGN(__vvar_page + PAGE_SIZE, PAGE_SIZE);
213
208#endif /* CONFIG_X86_64 */ 214#endif /* CONFIG_X86_64 */
209 215
210 /* Init code and data - will be freed after init */ 216 /* Init code and data - will be freed after init */
diff --git a/arch/x86/kernel/vsyscall_64.c b/arch/x86/kernel/vsyscall_64.c
index 3e682184d76c..3cf1cef75a6a 100644
--- a/arch/x86/kernel/vsyscall_64.c
+++ b/arch/x86/kernel/vsyscall_64.c
@@ -284,9 +284,14 @@ void __init map_vsyscall(void)
284{ 284{
285 extern char __vsyscall_0; 285 extern char __vsyscall_0;
286 unsigned long physaddr_page0 = __pa_symbol(&__vsyscall_0); 286 unsigned long physaddr_page0 = __pa_symbol(&__vsyscall_0);
287 extern char __vvar_page;
288 unsigned long physaddr_vvar_page = __pa_symbol(&__vvar_page);
287 289
288 /* Note that VSYSCALL_MAPPED_PAGES must agree with the code below. */ 290 /* Note that VSYSCALL_MAPPED_PAGES must agree with the code below. */
289 __set_fixmap(VSYSCALL_FIRST_PAGE, physaddr_page0, PAGE_KERNEL_VSYSCALL); 291 __set_fixmap(VSYSCALL_FIRST_PAGE, physaddr_page0, PAGE_KERNEL_VSYSCALL);
292 __set_fixmap(VVAR_PAGE, physaddr_vvar_page, PAGE_KERNEL_VVAR);
293 BUILD_BUG_ON((unsigned long)__fix_to_virt(VVAR_PAGE) !=
294 (unsigned long)VVAR_ADDRESS);
290} 295}
291 296
292static int __init vsyscall_init(void) 297static int __init vsyscall_init(void)