2005-04-16 15:20:36 -07:00
/ *
2008-01-30 13:30:44 +01:00
* Code f o r t h e v D S O . T h i s v e r s i o n u s e s t h e s y s e n t e r i n s t r u c t i o n .
2005-04-16 15:20:36 -07:00
*
2008-01-30 13:30:44 +01:00
* First g e t t h e c o m m o n c o d e f o r t h e s i g r e t u r n e n t r y p o i n t s .
* This m u s t c o m e f i r s t .
2005-04-16 15:20:36 -07:00
* /
2008-01-30 13:30:44 +01:00
# include " s i g r e t u r n . S "
2005-04-16 15:20:36 -07:00
2006-02-14 13:53:20 -08:00
/ *
* The c a l l e r p u t s a r g 2 i n % e c x , w h i c h g e t s p u s h e d . T h e k e r n e l w i l l u s e
* % ecx i t s e l f f o r a r g 2 . T h e p u s h i n g i s b e c a u s e t h e s y s e x i t i n s t r u c t i o n
* ( found i n e n t r y . S ) r e q u i r e s t h a t w e c l o b b e r % e c x w i t h t h e d e s i r e d % e s p .
* User c o d e m i g h t e x p e c t t h a t % e c x i s u n c l o b b e r e d t h o u g h , a s i t w o u l d b e
* for r e t u r n i n g v i a t h e i r e t i n s t r u c t i o n , s o w e m u s t p u s h a n d p o p .
*
* The c a l l e r p u t s a r g 3 i n % e d x , w h i c h t h e s y s e x i t i n s t r u c t i o n r e q u i r e s
* for % e i p . T h u s , e x a c t l y a s f o r a r g 2 , w e m u s t p u s h a n d p o p .
*
* Arg6 i s d i f f e r e n t . T h e c a l l e r p u t s a r g 6 i n % e b p . S i n c e t h e s y s e n t e r
* instruction c l o b b e r s % e s p , t h e u s e r ' s % e s p w o n ' t e v e n s u r v i v e e n t r y
* into t h e k e r n e l . W e s t o r e % e s p i n % e b p . C o d e i n e n t r y . S m u s t f e t c h
* arg6 f r o m t h e s t a c k .
2006-03-23 02:59:48 -08:00
*
* You c a n n o t u s e t h i s v s y s c a l l f o r t h e c l o n e ( ) s y s c a l l b e c a u s e t h e
2008-01-30 13:30:44 +01:00
* three w o r d s o n t h e p a r e n t s t a c k d o n o t g e t c o p i e d t o t h e c h i l d .
2006-02-14 13:53:20 -08:00
* /
2005-04-16 15:20:36 -07:00
.text
.globl __kernel_vsyscall
.type _ _ kernel_ v s y s c a l l ,@function
2008-01-30 13:30:44 +01:00
ALIGN
2005-04-16 15:20:36 -07:00
__kernel_vsyscall :
.LSTART_vsyscall :
push % e c x
.Lpush_ecx :
push % e d x
.Lpush_edx :
push % e b p
.Lenter_kernel :
movl % e s p ,% e b p
sysenter
/* 7: align return point with nop's to make disassembly easier */
.space 7 , 0 x9 0
[PATCH] vdso: randomize the i386 vDSO by moving it into a vma
Move the i386 VDSO down into a vma and thus randomize it.
Besides the security implications, this feature also helps debuggers, which
can COW a vma-backed VDSO just like a normal DSO and can thus do
single-stepping and other debugging features.
It's good for hypervisors (Xen, VMWare) too, which typically live in the same
high-mapped address space as the VDSO, hence whenever the VDSO is used, they
get lots of guest pagefaults and have to fix such guest accesses up - which
slows things down instead of speeding things up (the primary purpose of the
VDSO).
There's a new CONFIG_COMPAT_VDSO (default=y) option, which provides support
for older glibcs that still rely on a prelinked high-mapped VDSO. Newer
distributions (using glibc 2.3.3 or later) can turn this option off. Turning
it off is also recommended for security reasons: attackers cannot use the
predictable high-mapped VDSO page as syscall trampoline anymore.
There is a new vdso=[0|1] boot option as well, and a runtime
/proc/sys/vm/vdso_enabled sysctl switch, that allows the VDSO to be turned
on/off.
(This version of the VDSO-randomization patch also has working ELF
coredumping, the previous patch crashed in the coredumping code.)
This code is a combined work of the exec-shield VDSO randomization
code and Gerd Hoffmann's hypervisor-centric VDSO patch. Rusty Russell
started this patch and i completed it.
[akpm@osdl.org: cleanups]
[akpm@osdl.org: compile fix]
[akpm@osdl.org: compile fix 2]
[akpm@osdl.org: compile fix 3]
[akpm@osdl.org: revernt MAXMEM change]
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Arjan van de Ven <arjan@infradead.org>
Cc: Gerd Hoffmann <kraxel@suse.de>
Cc: Rusty Russell <rusty@rustcorp.com.au>
Cc: Zachary Amsden <zach@vmware.com>
Cc: Andi Kleen <ak@muc.de>
Cc: Jan Beulich <jbeulich@novell.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
2006-06-27 02:53:50 -07:00
/* 14: System call restart point is here! (SYSENTER_RETURN-2) */
2011-08-22 13:27:06 -07:00
int $ 0 x80
2005-04-16 15:20:36 -07:00
/* 16: System call normal return point is here! */
2008-01-30 13:30:42 +01:00
VDSO32_SYSENTER_RETURN : /* Symbol used by sysenter.c via vdso32-syms.h */
2005-04-16 15:20:36 -07:00
pop % e b p
.Lpop_ebp :
pop % e d x
.Lpop_edx :
pop % e c x
.Lpop_ecx :
ret
.LEND_vsyscall :
.size _ _ kernel_ v s y s c a l l ,. - . L S T A R T _ v s y s c a l l
.previous
.section .eh_frame , " a" ,@progbits
.LSTARTFRAMEDLSI :
.long .LENDCIEDLSI - .LSTARTCIEDLSI
.LSTARTCIEDLSI :
.long 0 /* CIE ID */
.byte 1 /* Version number */
.string " zR" / * N U L - t e r m i n a t e d a u g m e n t a t i o n s t r i n g * /
.uleb128 1 /* Code alignment factor */
.sleb128 - 4 /* Data alignment factor */
.byte 8 /* Return address register column */
.uleb128 1 /* Augmentation value length */
.byte 0x1b /* DW_EH_PE_pcrel|DW_EH_PE_sdata4. */
.byte 0x0c /* DW_CFA_def_cfa */
.uleb128 4
.uleb128 4
.byte 0x88 /* DW_CFA_offset, column 0x8 */
.uleb128 1
.align 4
.LENDCIEDLSI :
.long .LENDFDEDLSI - .LSTARTFDEDLSI /* Length FDE */
.LSTARTFDEDLSI :
.long .LSTARTFDEDLSI - .LSTARTFRAMEDLSI /* CIE pointer */
.long .LSTART_vsyscall - . /* PC-relative start address */
.long .LEND_vsyscall - .LSTART_vsyscall
.uleb128 0
/ * What f o l l o w s a r e t h e i n s t r u c t i o n s f o r t h e t a b l e g e n e r a t i o n .
We h a v e t o r e c o r d a l l c h a n g e s o f t h e s t a c k p o i n t e r . * /
2008-01-30 13:30:44 +01:00
.byte 0x40 + ( .Lpush_ecx - .LSTART_vsyscall ) /* DW_CFA_advance_loc */
2005-04-16 15:20:36 -07:00
.byte 0x0e /* DW_CFA_def_cfa_offset */
.byte 0x08 /* RA at offset 8 now */
2008-01-30 13:30:44 +01:00
.byte 0x40 + ( .Lpush_edx - .Lpush_ecx ) /* DW_CFA_advance_loc */
2005-04-16 15:20:36 -07:00
.byte 0x0e /* DW_CFA_def_cfa_offset */
.byte 0x0c /* RA at offset 12 now */
2008-01-30 13:30:44 +01:00
.byte 0x40 + ( .Lenter_kernel - .Lpush_edx ) /* DW_CFA_advance_loc */
2005-04-16 15:20:36 -07:00
.byte 0x0e /* DW_CFA_def_cfa_offset */
.byte 0x10 /* RA at offset 16 now */
.byte 0 x8 5 , 0 x04 / * D W _ C F A _ o f f s e t % e b p - 1 6 * /
/* Finally the epilogue. */
2008-01-30 13:30:44 +01:00
.byte 0x40 + ( .Lpop_ebp - .Lenter_kernel ) /* DW_CFA_advance_loc */
2005-04-16 15:20:36 -07:00
.byte 0x0e /* DW_CFA_def_cfa_offset */
.byte 0x0c /* RA at offset 12 now */
.byte 0xc5 /* DW_CFA_restore %ebp */
2008-01-30 13:30:44 +01:00
.byte 0x40 + ( .Lpop_edx - .Lpop_ebp ) /* DW_CFA_advance_loc */
2005-04-16 15:20:36 -07:00
.byte 0x0e /* DW_CFA_def_cfa_offset */
.byte 0x08 /* RA at offset 8 now */
2008-01-30 13:30:44 +01:00
.byte 0x40 + ( .Lpop_ecx - .Lpop_edx ) /* DW_CFA_advance_loc */
2005-04-16 15:20:36 -07:00
.byte 0x0e /* DW_CFA_def_cfa_offset */
.byte 0x04 /* RA at offset 4 now */
.align 4
.LENDFDEDLSI :
.previous
2008-01-30 13:30:44 +01:00
/ *
* Emit a s y m b o l w i t h t h e s i z e o f t h i s . e h _ f r a m e d a t a ,
* to v e r i f y i t m a t c h e s t h e o t h e r v e r s i o n s .
* /
VDSO3 2 _ v s y s c a l l _ e h _ f r a m e _ s i z e = ( . L E N D F D E D L S I - . L S T A R T F R A M E D L S I )