summaryrefslogtreecommitdiff
path: root/arch/arm64/kernel/vdso.c
diff options
context:
space:
mode:
authorVincenzo Frascino <vincenzo.frascino@arm.com>2019-04-15 10:49:36 +0100
committerWill Deacon <will.deacon@arm.com>2019-04-23 18:01:58 +0100
commit1255a7341bee6cd96df056ed0c13e44b59023687 (patch)
tree652fd43fbcfd9ba054bf47696d8c2f0014d4140b /arch/arm64/kernel/vdso.c
parentd1e5ca64d5bab864000566ea695617d0e124d27e (diff)
arm64: compat: Refactor aarch32_alloc_vdso_pages()
aarch32_alloc_vdso_pages() needs to be refactored to make it easier to disable kuser helpers. Divide the function in aarch32_alloc_kuser_vdso_page() and aarch32_alloc_sigreturn_vdso_page(). Cc: Catalin Marinas <catalin.marinas@arm.com> Cc: Will Deacon <will.deacon@arm.com> Signed-off-by: Vincenzo Frascino <vincenzo.frascino@arm.com> Reviewed-by: Catalin Marinas <catalin.marinas@arm.com> [will: Inlined sigpage allocation to simplify error paths] Signed-off-by: Will Deacon <will.deacon@arm.com>
Diffstat (limited to 'arch/arm64/kernel/vdso.c')
-rw-r--r--arch/arm64/kernel/vdso.c52
1 files changed, 26 insertions, 26 deletions
diff --git a/arch/arm64/kernel/vdso.c b/arch/arm64/kernel/vdso.c
index 6bb7038dc96c..41f4d75bbc14 100644
--- a/arch/arm64/kernel/vdso.c
+++ b/arch/arm64/kernel/vdso.c
@@ -68,43 +68,43 @@ static const struct vm_special_mapping aarch32_vdso_spec[C_PAGES] = {
},
};
-static int __init aarch32_alloc_vdso_pages(void)
+static int aarch32_alloc_kuser_vdso_page(void)
{
extern char __kuser_helper_start[], __kuser_helper_end[];
- extern char __aarch32_sigret_code_start[], __aarch32_sigret_code_end[];
-
int kuser_sz = __kuser_helper_end - __kuser_helper_start;
- int sigret_sz = __aarch32_sigret_code_end - __aarch32_sigret_code_start;
- unsigned long vdso_pages[C_PAGES];
-
- vdso_pages[C_VECTORS] = get_zeroed_page(GFP_ATOMIC);
- if (!vdso_pages[C_VECTORS])
- return -ENOMEM;
+ unsigned long vdso_page;
- vdso_pages[C_SIGPAGE] = get_zeroed_page(GFP_ATOMIC);
- if (!vdso_pages[C_SIGPAGE]) {
- free_page(vdso_pages[C_VECTORS]);
+ vdso_page = get_zeroed_page(GFP_ATOMIC);
+ if (!vdso_page)
return -ENOMEM;
- }
- /* kuser helpers */
- memcpy((void *)(vdso_pages[C_VECTORS] + 0x1000 - kuser_sz),
- __kuser_helper_start,
+ memcpy((void *)(vdso_page + 0x1000 - kuser_sz), __kuser_helper_start,
kuser_sz);
+ aarch32_vdso_pages[C_VECTORS] = virt_to_page(vdso_page);
+ flush_dcache_page(aarch32_vdso_pages[C_VECTORS]);
+ return 0;
+}
- /* sigreturn code */
- memcpy((void *)vdso_pages[C_SIGPAGE], __aarch32_sigret_code_start,
- sigret_sz);
+static int __init aarch32_alloc_vdso_pages(void)
+{
+ extern char __aarch32_sigret_code_start[], __aarch32_sigret_code_end[];
+ int sigret_sz = __aarch32_sigret_code_end - __aarch32_sigret_code_start;
+ unsigned long sigpage;
+ int ret;
- flush_icache_range(vdso_pages[C_VECTORS],
- vdso_pages[C_VECTORS] + PAGE_SIZE);
- flush_icache_range(vdso_pages[C_SIGPAGE],
- vdso_pages[C_SIGPAGE] + PAGE_SIZE);
+ sigpage = get_zeroed_page(GFP_ATOMIC);
+ if (!sigpage)
+ return -ENOMEM;
- aarch32_vdso_pages[C_VECTORS] = virt_to_page(vdso_pages[C_VECTORS]);
- aarch32_vdso_pages[C_SIGPAGE] = virt_to_page(vdso_pages[C_SIGPAGE]);
+ memcpy((void *)sigpage, __aarch32_sigret_code_start, sigret_sz);
+ aarch32_vdso_pages[C_SIGPAGE] = virt_to_page(sigpage);
+ flush_dcache_page(aarch32_vdso_pages[C_SIGPAGE]);
- return 0;
+ ret = aarch32_alloc_kuser_vdso_page();
+ if (ret)
+ free_page(sigpage);
+
+ return ret;
}
arch_initcall(aarch32_alloc_vdso_pages);