Skip to content

Commit a39060b

Browse files
committed
arm64: compat: Allow 32-bit vdso and sigpage to co-exist
In preparation for removing the signal trampoline from the compat vDSO, allow the sigpage and the compat vDSO to co-exist. For the moment the vDSO signal trampoline will still be used when built. Subsequent patches will move to the sigpage consistently. Acked-by: Dave Martin <[email protected]> Reviewed-by: Vincenzo Frascino <[email protected]> Reviewed-by: Ard Biesheuvel <[email protected]> Reviewed-by: Mark Rutland <[email protected]> Signed-off-by: Will Deacon <[email protected]>
1 parent 87676cf commit a39060b

File tree

4 files changed

+32
-36
lines changed

4 files changed

+32
-36
lines changed

arch/arm64/include/asm/mmu.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@
1919

2020
typedef struct {
2121
atomic64_t id;
22+
#ifdef CONFIG_COMPAT
23+
void *sigpage;
24+
#endif
2225
void *vdso;
2326
unsigned long flags;
2427
} mm_context_t;

arch/arm64/kernel/Makefile

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,7 @@ $(obj)/%.stub.o: $(obj)/%.o FORCE
2929

3030
obj-$(CONFIG_COMPAT) += sys32.o signal32.o \
3131
sys_compat.o
32-
ifneq ($(CONFIG_COMPAT_VDSO), y)
3332
obj-$(CONFIG_COMPAT) += sigreturn32.o
34-
endif
3533
obj-$(CONFIG_KUSER_HELPERS) += kuser32.o
3634
obj-$(CONFIG_FUNCTION_TRACER) += ftrace.o entry-ftrace.o
3735
obj-$(CONFIG_MODULES) += module.o

arch/arm64/kernel/signal32.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -371,7 +371,7 @@ static void compat_setup_return(struct pt_regs *regs, struct k_sigaction *ka,
371371
if (ka->sa.sa_flags & SA_SIGINFO)
372372
idx += 3;
373373

374-
retcode = (unsigned long)current->mm->context.vdso +
374+
retcode = (unsigned long)current->mm->context.sigpage +
375375
(idx << 2) + thumb;
376376
#endif
377377
}

arch/arm64/kernel/vdso.c

Lines changed: 28 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -191,15 +191,12 @@ enum aarch32_map {
191191
#ifdef CONFIG_COMPAT_VDSO
192192
AA32_MAP_VVAR,
193193
AA32_MAP_VDSO,
194-
#else
195-
AA32_MAP_SIGPAGE
196194
#endif
195+
AA32_MAP_SIGPAGE
197196
};
198197

199198
static struct page *aarch32_vectors_page __ro_after_init;
200-
#ifndef CONFIG_COMPAT_VDSO
201199
static struct page *aarch32_sig_page __ro_after_init;
202-
#endif
203200

204201
static struct vm_special_mapping aarch32_vdso_maps[] = {
205202
[AA32_MAP_VECTORS] = {
@@ -214,12 +211,11 @@ static struct vm_special_mapping aarch32_vdso_maps[] = {
214211
.name = "[vdso]",
215212
.mremap = aarch32_vdso_mremap,
216213
},
217-
#else
214+
#endif /* CONFIG_COMPAT_VDSO */
218215
[AA32_MAP_SIGPAGE] = {
219216
.name = "[sigpage]", /* ABI */
220217
.pages = &aarch32_sig_page,
221218
},
222-
#endif /* CONFIG_COMPAT_VDSO */
223219
};
224220

225221
static int aarch32_alloc_kuser_vdso_page(void)
@@ -242,27 +238,11 @@ static int aarch32_alloc_kuser_vdso_page(void)
242238
return 0;
243239
}
244240

245-
#ifdef CONFIG_COMPAT_VDSO
246-
static int __aarch32_alloc_vdso_pages(void)
247-
{
248-
int ret;
249-
250-
vdso_info[VDSO_ABI_AA32].dm = &aarch32_vdso_maps[AA32_MAP_VVAR];
251-
vdso_info[VDSO_ABI_AA32].cm = &aarch32_vdso_maps[AA32_MAP_VDSO];
252-
253-
ret = __vdso_init(VDSO_ABI_AA32);
254-
if (ret)
255-
return ret;
256-
257-
return aarch32_alloc_kuser_vdso_page();
258-
}
259-
#else
260-
static int __aarch32_alloc_vdso_pages(void)
241+
static int aarch32_alloc_sigpage(void)
261242
{
262243
extern char __aarch32_sigret_code_start[], __aarch32_sigret_code_end[];
263244
int sigret_sz = __aarch32_sigret_code_end - __aarch32_sigret_code_start;
264245
unsigned long sigpage;
265-
int ret;
266246

267247
sigpage = get_zeroed_page(GFP_ATOMIC);
268248
if (!sigpage)
@@ -271,18 +251,34 @@ static int __aarch32_alloc_vdso_pages(void)
271251
memcpy((void *)sigpage, __aarch32_sigret_code_start, sigret_sz);
272252
aarch32_sig_page = virt_to_page(sigpage);
273253
flush_dcache_page(aarch32_sig_page);
254+
return 0;
255+
}
274256

275-
ret = aarch32_alloc_kuser_vdso_page();
276-
if (ret)
277-
free_page(sigpage);
257+
#ifdef CONFIG_COMPAT_VDSO
258+
static int __aarch32_alloc_vdso_pages(void)
259+
{
260+
vdso_info[VDSO_ABI_AA32].dm = &aarch32_vdso_maps[AA32_MAP_VVAR];
261+
vdso_info[VDSO_ABI_AA32].cm = &aarch32_vdso_maps[AA32_MAP_VDSO];
278262

279-
return ret;
263+
return __vdso_init(VDSO_ABI_AA32);
280264
}
281265
#endif /* CONFIG_COMPAT_VDSO */
282266

283267
static int __init aarch32_alloc_vdso_pages(void)
284268
{
285-
return __aarch32_alloc_vdso_pages();
269+
int ret;
270+
271+
#ifdef CONFIG_COMPAT_VDSO
272+
ret = __aarch32_alloc_vdso_pages();
273+
if (ret)
274+
return ret;
275+
#endif
276+
277+
ret = aarch32_alloc_sigpage();
278+
if (ret)
279+
return ret;
280+
281+
return aarch32_alloc_kuser_vdso_page();
286282
}
287283
arch_initcall(aarch32_alloc_vdso_pages);
288284

@@ -305,7 +301,6 @@ static int aarch32_kuser_helpers_setup(struct mm_struct *mm)
305301
return PTR_ERR_OR_ZERO(ret);
306302
}
307303

308-
#ifndef CONFIG_COMPAT_VDSO
309304
static int aarch32_sigreturn_setup(struct mm_struct *mm)
310305
{
311306
unsigned long addr;
@@ -328,12 +323,11 @@ static int aarch32_sigreturn_setup(struct mm_struct *mm)
328323
if (IS_ERR(ret))
329324
goto out;
330325

331-
mm->context.vdso = (void *)addr;
326+
mm->context.sigpage = (void *)addr;
332327

333328
out:
334329
return PTR_ERR_OR_ZERO(ret);
335330
}
336-
#endif /* !CONFIG_COMPAT_VDSO */
337331

338332
int aarch32_setup_additional_pages(struct linux_binprm *bprm, int uses_interp)
339333
{
@@ -352,10 +346,11 @@ int aarch32_setup_additional_pages(struct linux_binprm *bprm, int uses_interp)
352346
mm,
353347
bprm,
354348
uses_interp);
355-
#else
356-
ret = aarch32_sigreturn_setup(mm);
349+
if (ret)
350+
goto out;
357351
#endif /* CONFIG_COMPAT_VDSO */
358352

353+
ret = aarch32_sigreturn_setup(mm);
359354
out:
360355
mmap_write_unlock(mm);
361356
return ret;

0 commit comments

Comments
 (0)