2005-04-16 18:20:36 -04:00
|
|
|
/*
|
|
|
|
* Copyright (C) 1994 Linus Torvalds
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef __ASM_X86_64_PROCESSOR_H
|
|
|
|
#define __ASM_X86_64_PROCESSOR_H
|
|
|
|
|
|
|
|
#include <asm/segment.h>
|
|
|
|
#include <asm/page.h>
|
|
|
|
#include <asm/types.h>
|
|
|
|
#include <asm/sigcontext.h>
|
|
|
|
#include <asm/cpufeature.h>
|
|
|
|
#include <linux/threads.h>
|
|
|
|
#include <asm/msr.h>
|
|
|
|
#include <asm/current.h>
|
|
|
|
#include <asm/system.h>
|
|
|
|
#include <linux/personality.h>
|
2008-01-30 07:31:14 -05:00
|
|
|
#include <asm/desc_defs.h>
|
2005-04-16 18:20:36 -04:00
|
|
|
|
|
|
|
/*
|
2005-05-17 00:53:20 -04:00
|
|
|
* User space process size. 47bits minus one guard page.
|
2005-04-16 18:20:36 -04:00
|
|
|
*/
|
[PATCH] x86_64: TASK_SIZE fixes for compatibility mode processes
Appended patch will setup compatibility mode TASK_SIZE properly. This will
fix atleast three known bugs that can be encountered while running
compatibility mode apps.
a) A malicious 32bit app can have an elf section at 0xffffe000. During
exec of this app, we will have a memory leak as insert_vm_struct() is
not checking for return value in syscall32_setup_pages() and thus not
freeing the vma allocated for the vsyscall page. And instead of exec
failing (as it has addresses > TASK_SIZE), we were allowing it to
succeed previously.
b) With a 32bit app, hugetlb_get_unmapped_area/arch_get_unmapped_area
may return addresses beyond 32bits, ultimately causing corruption
because of wrap-around and resulting in SEGFAULT, instead of returning
ENOMEM.
c) 32bit app doing this below mmap will now fail.
mmap((void *)(0xFFFFE000UL), 0x10000UL, PROT_READ|PROT_WRITE,
MAP_FIXED|MAP_PRIVATE|MAP_ANON, 0, 0);
Signed-off-by: Zou Nan hai <nanhai.zou@intel.com>
Signed-off-by: Suresh Siddha <suresh.b.siddha@intel.com>
Cc: Andi Kleen <ak@muc.de>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
2005-06-21 20:14:32 -04:00
|
|
|
#define TASK_SIZE64 (0x800000000000UL - 4096)
|
2005-04-16 18:20:36 -04:00
|
|
|
|
|
|
|
/* This decides where the kernel will search for a free chunk of vm
|
|
|
|
* space during mmap's.
|
|
|
|
*/
|
|
|
|
#define IA32_PAGE_OFFSET ((current->personality & ADDR_LIMIT_3GB) ? 0xc0000000 : 0xFFFFe000)
|
[PATCH] x86_64: TASK_SIZE fixes for compatibility mode processes
Appended patch will setup compatibility mode TASK_SIZE properly. This will
fix atleast three known bugs that can be encountered while running
compatibility mode apps.
a) A malicious 32bit app can have an elf section at 0xffffe000. During
exec of this app, we will have a memory leak as insert_vm_struct() is
not checking for return value in syscall32_setup_pages() and thus not
freeing the vma allocated for the vsyscall page. And instead of exec
failing (as it has addresses > TASK_SIZE), we were allowing it to
succeed previously.
b) With a 32bit app, hugetlb_get_unmapped_area/arch_get_unmapped_area
may return addresses beyond 32bits, ultimately causing corruption
because of wrap-around and resulting in SEGFAULT, instead of returning
ENOMEM.
c) 32bit app doing this below mmap will now fail.
mmap((void *)(0xFFFFE000UL), 0x10000UL, PROT_READ|PROT_WRITE,
MAP_FIXED|MAP_PRIVATE|MAP_ANON, 0, 0);
Signed-off-by: Zou Nan hai <nanhai.zou@intel.com>
Signed-off-by: Suresh Siddha <suresh.b.siddha@intel.com>
Cc: Andi Kleen <ak@muc.de>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
2005-06-21 20:14:32 -04:00
|
|
|
|
|
|
|
#define TASK_SIZE (test_thread_flag(TIF_IA32) ? IA32_PAGE_OFFSET : TASK_SIZE64)
|
|
|
|
#define TASK_SIZE_OF(child) ((test_tsk_thread_flag(child, TIF_IA32)) ? IA32_PAGE_OFFSET : TASK_SIZE64)
|
|
|
|
|
2005-04-16 18:20:36 -04:00
|
|
|
|
|
|
|
|
2006-08-30 13:37:19 -04:00
|
|
|
DECLARE_PER_CPU(struct orig_ist, orig_ist);
|
2005-04-16 18:20:36 -04:00
|
|
|
|
2005-09-12 12:49:24 -04:00
|
|
|
#define INIT_THREAD { \
|
2008-01-30 07:31:02 -05:00
|
|
|
.sp0 = (unsigned long)&init_stack + sizeof(init_stack) \
|
2005-09-12 12:49:24 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
#define INIT_TSS { \
|
2008-01-30 07:31:31 -05:00
|
|
|
.x86_tss.sp0 = (unsigned long)&init_stack + sizeof(init_stack) \
|
2005-09-12 12:49:24 -04:00
|
|
|
}
|
2005-04-16 18:20:36 -04:00
|
|
|
|
|
|
|
#define start_thread(regs,new_rip,new_rsp) do { \
|
|
|
|
asm volatile("movl %0,%%fs; movl %0,%%es; movl %0,%%ds": :"r" (0)); \
|
|
|
|
load_gs_index(0); \
|
2008-01-30 07:30:56 -05:00
|
|
|
(regs)->ip = (new_rip); \
|
|
|
|
(regs)->sp = (new_rsp); \
|
2005-04-16 18:20:36 -04:00
|
|
|
write_pda(oldrsp, (new_rsp)); \
|
|
|
|
(regs)->cs = __USER_CS; \
|
|
|
|
(regs)->ss = __USER_DS; \
|
2008-01-30 07:30:56 -05:00
|
|
|
(regs)->flags = 0x200; \
|
2005-04-16 18:20:36 -04:00
|
|
|
set_fs(USER_DS); \
|
|
|
|
} while(0)
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Return saved PC of a blocked thread.
|
|
|
|
* What is this good for? it will be always the scheduler or ret_from_fork.
|
|
|
|
*/
|
2008-01-30 07:31:02 -05:00
|
|
|
#define thread_saved_pc(t) (*(unsigned long *)((t)->thread.sp - 8))
|
2005-04-16 18:20:36 -04:00
|
|
|
|
2008-01-30 07:31:02 -05:00
|
|
|
#define task_pt_regs(tsk) ((struct pt_regs *)(tsk)->thread.sp0 - 1)
|
2005-04-16 18:20:36 -04:00
|
|
|
#define KSTK_ESP(tsk) -1 /* sorry. doesn't work for syscall. */
|
|
|
|
|
|
|
|
#endif /* __ASM_X86_64_PROCESSOR_H */
|