x86, vdso32: fix out of memory handling setup vDSO
PATCH 1/1 x86, vdso32: fix out of memory handling setup vDSO
This patch add a correct out of memory handling for setup a 32 bit vDSO.
The patch is against tip commit 4e40112c4ff6a577dd06d92b2a54cdf06265bf74
--- arch/x86/vdso/vdso32-setup.c | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-)
arch/x86/vdso/vdso32-setup.c +16 -1
@@ -134,8 +134,14 @@ int __init sysenter_setup(void) } vdso32_size = (vdso_len +PAGE_SIZE -1 ) /PAGE_SIZE ; - vdso32_pages =kmalloc (sizeof (*vdso32_pages) * vdso32_size,GFP_ATOMIC ); + + vdso32_pages =kmalloc (sizeof (*vdso32_pages) * vdso32_size,GFP_ATOMIC ); +if (!vdso32_pages) + goto fail; + vdso_pages =kmalloc (VDSO_OFFSET (vdso32_size),GFP_ATOMIC ); +if (!vdso_pages) + goto fail;for (i =0 ; i != vdso32_size; ++i) vdso32_pages[i] =virt_to_page (vdso_pages +VDSO_OFFSET (i));
@@ -144,6 +150,12 @@ int __init sysenter_setup(void)patch_vdso32 (vdso_pages, vdso_len);return 0 ; +fail: +kfree (vdso32_pages); +kfree (vdso_pages); + vdso32_size =0 ; + +return -ENOMEM ; }/* Setup a VMA at program startup for the vsyscall page */
@@ -162,6 +174,9 @@ int arch_setup_additional_pages(struct linux_binprm *bprm, int uses_interp)if (vdso_enabled !=1 )/* Other values all mean "disabled" */ return 0 ; +if (!vdso32_size) +return 0 ; +down_write (&mm->mmap_sem); addr =get_unmapped_area (NULL ,0 ,PAGE_SIZE ,0 ,0 );
Signature · 1 line
1.9.0
Quoted 14 lines · Stefani Seibold
This patch add a correct out of memory handling for setup a 32 bit vDSO.
The patch is against tip commit
4e40112c4ff6a577dd06d92b2a54cdf06265bf74Signed-off-by Stefani Seibold <[email protected]>--- arch/x86/vdso/vdso32-setup.c | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-)arch/x86/vdso/vdso32-setup.c +0
-0
arch/x86/vdso/vdso32-setup.c int __init sysenter_setup(void) · line 138
Quoted 6 lines
arch/x86/vdso/vdso32-setup.c +2
-1@@ -134,8 +134,14 @@ int __init sysenter_setup(void) } vdso32_size = (vdso_len +PAGE_SIZE -1 ) /PAGE_SIZE ; - vdso32_pages =kmalloc (sizeof (*vdso32_pages) * vdso32_size,GFP_ATOMIC ); + + vdso32_pages =kmalloc (sizeof (*vdso32_pages) * vdso32_size,GFP_ATOMIC );
Why is this GFP_ATOMIC and not GFP_ATOMIC ?
That code is called either from identify_boot_cpu(), where GFP_KERNEL is perfectly valid and from subsys_initcall(sysenter_setup) which is way late in the boot process where GFP_KERNEL is the RightThing.
Aside of that, why do we need to call it early for X86_32 and late for X86_64?
We need the vdso before we head off to user space, but not in the early boot process.
Thanks,
tglx
Quoted 18 lines · Thomas Gleixner
Quoted 16 lines · Stefani Seibold
This patch add a correct out of memory handling for setup a 32 bit vDSO.
The patch is against tip commit
4e40112c4ff6a577dd06d92b2a54cdf06265bf74Signed-off-by Stefani Seibold <[email protected]>--- arch/x86/vdso/vdso32-setup.c | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-)arch/x86/vdso/vdso32-setup.c +0
-0@@ -134,8 +134,14 @@ int __init sysenter_setup(void) }
Quoted 6 lines
arch/x86/vdso/vdso32-setup.c int __init sysenter_setup(void) · line 138
Quoted 4 lines
arch/x86/vdso/vdso32-setup.c +2
-1vdso32_size = (vdso_len +PAGE_SIZE -1 ) /PAGE_SIZE ; - vdso32_pages =kmalloc (sizeof (*vdso32_pages) * vdso32_size,GFP_ATOMIC ); + + vdso32_pages =kmalloc (sizeof (*vdso32_pages) * vdso32_size,GFP_ATOMIC );Why is this
GFP_ATOMICand notGFP_ATOMIC?
Should be: Why is this GFP_ATOMIC and not GFP_KERNEL ?
Quoted 15 lines
That code is called either from
identify_boot_cpu(), whereGFP_KERNELis perfectly valid and fromsubsys_initcall(sysenter_setup)which is way late in the boot process whereGFP_KERNELis the RightThing.Aside of that, why do we need to call it early for
X86_32and late forX86_64?We need the vdso before we head off to user space, but not in the early boot process.
Thanks,
tglx
Am Donnerstag, den 20.03.2014, 10:53 +0100 schrieb Thomas Gleixner:
Quoted 29 lines · Stefani Seibold
Quoted 15 lines
This patch add a correct out of memory handling for setup a 32 bit vDSO.
The patch is against tip commit
4e40112c4ff6a577dd06d92b2a54cdf06265bf74Signed-off-by Stefani Seibold <[email protected]>--- arch/x86/vdso/vdso32-setup.c | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-)arch/x86/vdso/vdso32-setup.c +0
-0arch/x86/vdso/vdso32-setup.c int __init sysenter_setup(void) · line 138
Quoted 6 lines
arch/x86/vdso/vdso32-setup.c +2
-1@@ -134,8 +134,14 @@ int __init sysenter_setup(void) } vdso32_size = (vdso_len +PAGE_SIZE -1 ) /PAGE_SIZE ; - vdso32_pages =kmalloc (sizeof (*vdso32_pages) * vdso32_size,GFP_ATOMIC ); + + vdso32_pages =kmalloc (sizeof (*vdso32_pages) * vdso32_size,GFP_ATOMIC );Why is this
GFP_ATOMICand notGFP_ATOMIC?That code is called either from
identify_boot_cpu(), whereGFP_KERNELis perfectly valid and fromsubsys_initcall(sysenter_setup)which is way late in the boot process whereGFP_KERNELis the RightThing.
Quoted 6 lines
Aside of that, why do we need to call it early for
X86_32and late forX86_64?We need the vdso before we head off to user space, but not in the early boot process.
All complains are design decisions not made by me. I will send a patch for the GFP_ATOMIC thing. For the other one it would be the best to ask Andy for the reason.
- Stefani
Quoted 33 lines · Stefani Seibold
Am Donnerstag, den 20.03.2014, 10:53 +0100 schrieb Thomas Gleixner:
Quoted 32 lines · Stefani Seibold
Quoted 15 lines
This patch add a correct out of memory handling for setup a 32 bit vDSO.
The patch is against tip commit
4e40112c4ff6a577dd06d92b2a54cdf06265bf74Signed-off-by Stefani Seibold <[email protected]>--- arch/x86/vdso/vdso32-setup.c | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-)arch/x86/vdso/vdso32-setup.c +0
-0arch/x86/vdso/vdso32-setup.c int __init sysenter_setup(void) · line 138
Quoted 6 lines
arch/x86/vdso/vdso32-setup.c +2
-1@@ -134,8 +134,14 @@ int __init sysenter_setup(void) } vdso32_size = (vdso_len +PAGE_SIZE -1 ) /PAGE_SIZE ; - vdso32_pages =kmalloc (sizeof (*vdso32_pages) * vdso32_size,GFP_ATOMIC ); + + vdso32_pages =kmalloc (sizeof (*vdso32_pages) * vdso32_size,GFP_ATOMIC );Why is this
GFP_ATOMICand notGFP_ATOMIC?That code is called either from
identify_boot_cpu(), whereGFP_KERNELis perfectly valid and fromsubsys_initcall(sysenter_setup)which is way late in the boot process whereGFP_KERNELis the RightThing.Aside of that, why do we need to call it early for
X86_32and late forX86_64?
Quoted 7 lines
Quoted 3 lines
We need the vdso before we head off to user space, but not in the early boot process.
All complains are design decisions not made by me. I will send a patch for the
GFP_ATOMICthing. For the other one it would be the best to ask Andy for the reason.
I'm not saying it's your fault, but if we rework code, then we really should question such things. What happens if you remove the x32 call and make the x64 subsys thing valid for both cases?
Thanks,
tglx
Quoted 38 lines · Thomas Gleixner
Quoted 37 lines · Stefani Seibold
Am Donnerstag, den 20.03.2014, 10:53 +0100 schrieb Thomas Gleixner:
Quoted 35 lines · Stefani Seibold
Quoted 15 lines
This patch add a correct out of memory handling for setup a 32 bit vDSO.
The patch is against tip commit
4e40112c4ff6a577dd06d92b2a54cdf06265bf74Signed-off-by Stefani Seibold <[email protected]>--- arch/x86/vdso/vdso32-setup.c | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-)arch/x86/vdso/vdso32-setup.c +0
-0arch/x86/vdso/vdso32-setup.c int __init sysenter_setup(void) · line 138
Quoted 6 lines
arch/x86/vdso/vdso32-setup.c +2
-1@@ -134,8 +134,14 @@ int __init sysenter_setup(void) } vdso32_size = (vdso_len +PAGE_SIZE -1 ) /PAGE_SIZE ; - vdso32_pages =kmalloc (sizeof (*vdso32_pages) * vdso32_size,GFP_ATOMIC ); + + vdso32_pages =kmalloc (sizeof (*vdso32_pages) * vdso32_size,GFP_ATOMIC );Why is this
GFP_ATOMICand notGFP_ATOMIC?That code is called either from
identify_boot_cpu(), whereGFP_KERNELis perfectly valid and fromsubsys_initcall(sysenter_setup)which is way late in the boot process whereGFP_KERNELis the RightThing.Aside of that, why do we need to call it early for
X86_32and late forX86_64?We need the vdso before we head off to user space, but not in the early boot process.
Quoted 8 lines
Quoted 3 lines
All complains are design decisions not made by me. I will send a patch for the
GFP_ATOMICthing. For the other one it would be the best to ask Andy for the reason.I'm not saying it's your fault, but if we rework code, then we really should question such things. What happens if you remove the x32 call and make the x64 subsys thing valid for both cases?
It's not just that. The x86_64 and x32 vdso page arrays are *far* cleaner than the 32-bit variant. They manage to do the entire vdso setup dance without any allocation at all. This avoids silly questions about error handling and GFP_KERNEL :)
See vdso/vdso.S for the rather small amount of magic needed.
--Andy
Quoted 11 lines · Andy Lutomirski
Quoted 9 lines · Thomas Gleixner
Quoted 3 lines · Stefani Seibold
All complains are design decisions not made by me. I will send a patch for the
GFP_ATOMICthing. For the other one it would be the best to ask Andy for the reason.I'm not saying it's your fault, but if we rework code, then we really should question such things. What happens if you remove the x32 call and make the x64 subsys thing valid for both cases?
Quoted 6 lines
It's not just that. The
x86_64and x32 vdso page arrays are *far* cleaner than the 32-bit variant. They manage to do the entire vdso setup dance without any allocation at all. This avoids silly questions about error handling andGFP_KERNEL:)See
vdso/vdso.Sfor the rather small amount of magic needed.
Is there any reason why we can't use that for x86_32 ?
Thanks,
tglx
Quoted 12 lines · Thomas Gleixner
Quoted 11 lines · Andy Lutomirski
Quoted 9 lines · Thomas Gleixner
Quoted 3 lines · Stefani Seibold
All complains are design decisions not made by me. I will send a patch for the
GFP_ATOMICthing. For the other one it would be the best to ask Andy for the reason.I'm not saying it's your fault, but if we rework code, then we really should question such things. What happens if you remove the x32 call and make the x64 subsys thing valid for both cases?
Quoted 9 lines
Quoted 6 lines
It's not just that. The
x86_64and x32 vdso page arrays are *far* cleaner than the 32-bit variant. They manage to do the entire vdso setup dance without any allocation at all. This avoids silly questions about error handling andGFP_KERNEL:)See
vdso/vdso.Sfor the rather small amount of magic needed.Is there any reason why we can't use that for
x86_32?
Not really. I'll play with it a bit.
Quoted 3 lines
Thanks,
tglx
Signature · 2 lines
Andy Lutomirski AMA Capital Management, LLC
H. Peter Anvin
reviewerQuoted 3 lines · Andy Lutomirski
Not really. I'll play with it a bit.
That would be really nice.
-hpa
Quoted 7 lines · H. Peter Anvin
Quoted 3 lines · Andy Lutomirski
Not really. I'll play with it a bit.
That would be really nice.
Holy cow the 32-bit vdso code is a mess. I have a patch to clean up this bit of it, and I'll send it out once I've tested it a bit.
--Andy
Quoted 3 lines
-hpa
Signature · 2 lines
Andy Lutomirski AMA Capital Management, LLC
H. Peter Anvin
reviewerQuoted 4 lines · Andy Lutomirski
Holy cow the 32-bit vdso code is a mess. I have a patch to clean up this bit of it, and I'll send it out once I've tested it a bit.
Thanks.
-hpa
PATCH 1/1 x86: Load the 32-bit vdso in place, just like the 64-bit vdsos
In reply to Andy LutomirskiThis replaces a decent amount of incomprehensible and buggy code with much more straightforward code. It also brings the 32-bit vdso more in line with the 64-bit vdsos, so maybe someday they can share even more code.
This wastes a small amount of kernel .data and .text space, but it avoids a couple of allocations on startup, so it should be more or less a wash memory-wise.
--- arch/x86/include/asm/vdso.h | 8 ------- arch/x86/vdso/vdso.S | 22 ++----------------- arch/x86/vdso/vdso32-setup.c | 50 +++++++++++++++++++++++++------------------- arch/x86/vdso/vdso32.S | 21 ++++--------------- arch/x86/vdso/vdso_image.h | 30 ++++++++++++++++++++++++++ arch/x86/vdso/vdsox32.S | 22 ++----------------- arch/x86/vdso/vma.c | 8 +++---- 7 files changed, 70 insertions(+), 91 deletions(-) create mode 100644 arch/x86/vdso/vdso_image.h
arch/x86/include/asm/vdso.h +0 -8
@@ -25,14 +25,6 @@ extern const char VDSO32_PRELINK[];extern void __user __kernel_sigreturn;extern void __user __kernel_rt_sigreturn; -/* -* These symbols are defined by vdso32.S to mark the bounds -* of the ELF DSO images included therein. -*/ -extern const char vdso32_int80_start, vdso32_int80_end; -extern const char vdso32_syscall_start, vdso32_syscall_end; -extern const char vdso32_sysenter_start, vdso32_sysenter_end; -void __init patch_vdso32 (void *vdso,size_t len);#endif /* _ASM_X86_VDSO_H */
arch/x86/vdso/vdso.S +2 -20
@@ -1,21 +1,3 @@ -#include <asm/page_types.h> -#include <linux/linkage.h> +#include "vdso_image.h" -__PAGE_ALIGNED_DATA - - .globl vdso_start, vdso_end - .align PAGE_SIZE -vdso_start: - .incbin "arch/x86/vdso/vdso.so" -vdso_end: - .align PAGE_SIZE /* extra data here leaks to userspace. */ - -.previous - - .globl vdso_pages - .bss - .align 8 - .type vdso_pages, @object -vdso_pages: - .zero (vdso_end - vdso_start + PAGE_SIZE - 1) / PAGE_SIZE * 8 - .size vdso_pages, .-vdso_pages +DEFINE_VDSO_IMAGE(vdso, "arch/x86/vdso/vdso.so")
arch/x86/vdso/vdso32-setup.c +29 -21
86 lines not on this page · raw message
arch/x86/vdso/vdso32.S +4 -17
@@ -1,22 +1,9 @@ -#include <linux/init.h> +#include "vdso_image.h" -__INITDATA +DEFINE_VDSO_IMAGE(vdso32_int80, "arch/x86/vdso/vdso32-int80.so") - .globl vdso32_int80_start, vdso32_int80_end -vdso32_int80_start: - .incbin "arch/x86/vdso/vdso32-int80.so" -vdso32_int80_end: - - .globl vdso32_syscall_start, vdso32_syscall_end -vdso32_syscall_start: #ifdef CONFIG_COMPAT - .incbin "arch/x86/vdso/vdso32-syscall.so" +DEFINE_VDSO_IMAGE(vdso32_syscall, "arch/x86/vdso/vdso32-syscall.so") #endif -vdso32_syscall_end: - - .globl vdso32_sysenter_start, vdso32_sysenter_end -vdso32_sysenter_start: - .incbin "arch/x86/vdso/vdso32-sysenter.so" -vdso32_sysenter_end: -__FINIT +DEFINE_VDSO_IMAGE(vdso32_sysenter, "arch/x86/vdso/vdso32-sysenter.so")
arch/x86/vdso/vdso_image.h new file +30 -0
@@ -0,0 +1,30 @@ +#ifndef _VDSO_IMAGE_H +#define _VDSO_IMAGE_H + +#include <asm/page_types.h> +#include <linux/linkage.h> + +#define DEFINE_VDSO_IMAGE(symname, filename) \ +__PAGE_ALIGNED_DATA ; \ + .globl symname##_start, symname##_end ; \ + .align PAGE_SIZE ; \ + symname##_start: ; \ + .incbin filename ; \ + symname##_end: ; \ + .align PAGE_SIZE /* extra data here leaks to userspace. */ ; \ + \ +.previous ; \ + \ + .globl symname##_pages ; \ + .bss ; \ + .align 8 ; \ + .type symname##_pages, @object ; \ + symname##_pages: ; \ + .zero (symname##_end - symname##_start + PAGE_SIZE - 1) / PAGE_SIZE * (BITS_PER_LONG / 8) ; \ + .size symname##_pages, .-symname##_pages + +#define DECLARE_VDSO_IMAGE (symname) \ + extern char symname##_start[], symname##_end[]; \ + extern struct page *symname##_pages[] + +#endif /* _VDSO_IMAGE_H */
arch/x86/vdso/vdsox32.S +2 -20
@@ -1,21 +1,3 @@ -#include <asm/page_types.h> -#include <linux/linkage.h> +#include "vdso_image.h" -__PAGE_ALIGNED_DATA - - .globl vdsox32_start, vdsox32_end - .align PAGE_SIZE -vdsox32_start: - .incbin "arch/x86/vdso/vdsox32.so" -vdsox32_end: - .align PAGE_SIZE /* extra data here leaks to userspace. */ - -.previous - - .globl vdsox32_pages - .bss - .align 8 - .type vdsox32_pages, @object -vdsox32_pages: - .zero (vdsox32_end - vdsox32_start + PAGE_SIZE - 1) / PAGE_SIZE * 8 - .size vdsox32_pages, .-vdsox32_pages +DEFINE_VDSO_IMAGE(vdsox32, "arch/x86/vdso/vdsox32.so")
arch/x86/vdso/vma.c +3 -5
@@ -15,19 +15,17 @@#include <asm/proto.h> #include <asm/vdso.h> #include <asm/page.h> +#include "vdso_image.h" #if defined(CONFIG_X86_64 )unsigned int __read_mostly vdso_enabled =1 ; -extern char vdso_start[], vdso_end[]; +DECLARE_VDSO_IMAGE (vdso);extern unsigned short vdso_sync_cpuid; - -extern struct page *vdso_pages[];static unsigned vdso_size;#ifdef CONFIG_X86_X32_ABI -extern char vdsox32_start[], vdsox32_end[]; -extern struct page *vdsox32_pages[]; +DECLARE_VDSO_IMAGE (vdsox32);static unsigned vdsox32_size;#endif #endif
Signature · 1 line
1.8.5.3
tip-bot for Andy Lutomirski
merge bot[tip:x86/vdso] x86: Load the 32-bit vdso in place, just like the 64-bit vdsos
x86: Load the 32-bit vdso in place, just like the 64-bit vdsos
Commit-ID: b67e612cef1e5964efc6fa99fb7ad3d31c4db01a Gitweb: http://git.kernel.org/tip/b67e612cef1e5964efc6fa99fb7ad3d31c4db01a Author: Andy Lutomirski <[email protected]> AuthorDate: Thu, 20 Mar 2014 15:01:21 -0700 Committer: H. Peter Anvin <[email protected]> CommitDate: Thu, 20 Mar 2014 15:19:14 -0700
x86: Load the 32-bit vdso in place, just like the 64-bit vdsos
This replaces a decent amount of incomprehensible and buggy code with much more straightforward code. It also brings the 32-bit vdso more in line with the 64-bit vdsos, so maybe someday they can share even more code.
This wastes a small amount of kernel .data and .text space, but it avoids a couple of allocations on startup, so it should be more or less a wash memory-wise.
--- arch/x86/include/asm/vdso.h | 8 ------- arch/x86/vdso/vdso.S | 22 ++----------------- arch/x86/vdso/vdso32-setup.c | 50 +++++++++++++++++++++++++------------------- arch/x86/vdso/vdso32.S | 21 ++++--------------- arch/x86/vdso/vdso_image.h | 30 ++++++++++++++++++++++++++ arch/x86/vdso/vdsox32.S | 22 ++----------------- arch/x86/vdso/vma.c | 8 +++---- 7 files changed, 70 insertions(+), 91 deletions(-)
arch/x86/include/asm/vdso.h +0 -8
@@ -25,14 +25,6 @@ extern const char VDSO32_PRELINK[];extern void __user __kernel_sigreturn;extern void __user __kernel_rt_sigreturn; -/* -* These symbols are defined by vdso32.S to mark the bounds -* of the ELF DSO images included therein. -*/ -extern const char vdso32_int80_start, vdso32_int80_end; -extern const char vdso32_syscall_start, vdso32_syscall_end; -extern const char vdso32_sysenter_start, vdso32_sysenter_end; -void __init patch_vdso32 (void *vdso,size_t len);#endif /* _ASM_X86_VDSO_H */
arch/x86/vdso/vdso.S +2 -20
@@ -1,21 +1,3 @@ -#include <asm/page_types.h> -#include <linux/linkage.h> +#include "vdso_image.h" -__PAGE_ALIGNED_DATA - - .globl vdso_start, vdso_end - .align PAGE_SIZE -vdso_start: - .incbin "arch/x86/vdso/vdso.so" -vdso_end: - .align PAGE_SIZE /* extra data here leaks to userspace. */ - -.previous - - .globl vdso_pages - .bss - .align 8 - .type vdso_pages, @object -vdso_pages: - .zero (vdso_end - vdso_start + PAGE_SIZE - 1) / PAGE_SIZE * 8 - .size vdso_pages, .-vdso_pages +DEFINE_VDSO_IMAGE(vdso, "arch/x86/vdso/vdso.so")
arch/x86/vdso/vdso32-setup.c +29 -21
86 lines not on this page · raw message
arch/x86/vdso/vdso32.S +4 -17
@@ -1,22 +1,9 @@ -#include <linux/init.h> +#include "vdso_image.h" -__INITDATA +DEFINE_VDSO_IMAGE(vdso32_int80, "arch/x86/vdso/vdso32-int80.so") - .globl vdso32_int80_start, vdso32_int80_end -vdso32_int80_start: - .incbin "arch/x86/vdso/vdso32-int80.so" -vdso32_int80_end: - - .globl vdso32_syscall_start, vdso32_syscall_end -vdso32_syscall_start: #ifdef CONFIG_COMPAT - .incbin "arch/x86/vdso/vdso32-syscall.so" +DEFINE_VDSO_IMAGE(vdso32_syscall, "arch/x86/vdso/vdso32-syscall.so") #endif -vdso32_syscall_end: - - .globl vdso32_sysenter_start, vdso32_sysenter_end -vdso32_sysenter_start: - .incbin "arch/x86/vdso/vdso32-sysenter.so" -vdso32_sysenter_end: -__FINIT +DEFINE_VDSO_IMAGE(vdso32_sysenter, "arch/x86/vdso/vdso32-sysenter.so")
arch/x86/vdso/vdso_image.h new file +30 -0
@@ -0,0 +1,30 @@ +#ifndef _VDSO_IMAGE_H +#define _VDSO_IMAGE_H + +#include <asm/page_types.h> +#include <linux/linkage.h> + +#define DEFINE_VDSO_IMAGE(symname, filename) \ +__PAGE_ALIGNED_DATA ; \ + .globl symname##_start, symname##_end ; \ + .align PAGE_SIZE ; \ + symname##_start: ; \ + .incbin filename ; \ + symname##_end: ; \ + .align PAGE_SIZE /* extra data here leaks to userspace. */ ; \ + \ +.previous ; \ + \ + .globl symname##_pages ; \ + .bss ; \ + .align 8 ; \ + .type symname##_pages, @object ; \ + symname##_pages: ; \ + .zero (symname##_end - symname##_start + PAGE_SIZE - 1) / PAGE_SIZE * (BITS_PER_LONG / 8) ; \ + .size symname##_pages, .-symname##_pages + +#define DECLARE_VDSO_IMAGE (symname) \ + extern char symname##_start[], symname##_end[]; \ + extern struct page *symname##_pages[] + +#endif /* _VDSO_IMAGE_H */
arch/x86/vdso/vdsox32.S +2 -20
@@ -1,21 +1,3 @@ -#include <asm/page_types.h> -#include <linux/linkage.h> +#include "vdso_image.h" -__PAGE_ALIGNED_DATA - - .globl vdsox32_start, vdsox32_end - .align PAGE_SIZE -vdsox32_start: - .incbin "arch/x86/vdso/vdsox32.so" -vdsox32_end: - .align PAGE_SIZE /* extra data here leaks to userspace. */ - -.previous - - .globl vdsox32_pages - .bss - .align 8 - .type vdsox32_pages, @object -vdsox32_pages: - .zero (vdsox32_end - vdsox32_start + PAGE_SIZE - 1) / PAGE_SIZE * 8 - .size vdsox32_pages, .-vdsox32_pages +DEFINE_VDSO_IMAGE(vdsox32, "arch/x86/vdso/vdsox32.so")
arch/x86/vdso/vma.c +3 -5
@@ -15,19 +15,17 @@#include <asm/proto.h> #include <asm/vdso.h> #include <asm/page.h> +#include "vdso_image.h" #if defined(CONFIG_X86_64 )unsigned int __read_mostly vdso_enabled =1 ; -extern char vdso_start[], vdso_end[]; +DECLARE_VDSO_IMAGE (vdso);extern unsigned short vdso_sync_cpuid; - -extern struct page *vdso_pages[];static unsigned vdso_size;#ifdef CONFIG_X86_X32_ABI -extern char vdsox32_start[], vdsox32_end[]; -extern struct page *vdsox32_pages[]; +DECLARE_VDSO_IMAGE (vdsox32);static unsigned vdsox32_size;#endif #endif