arm64/vdso: Restrict splitting VVAR VMA
authorAndrei Vagin <avagin@gmail.com>
Wed, 24 Jun 2020 08:33:20 +0000 (01:33 -0700)
committerCatalin Marinas <catalin.marinas@arm.com>
Fri, 24 Jul 2020 17:06:52 +0000 (18:06 +0100)
Forbid splitting VVAR VMA resulting in a stricter ABI and reducing the
amount of corner-cases to consider while working further on VDSO time
namespace support.

As the offset from timens to VVAR page is computed compile-time, the pages
in VVAR should stay together and not being partically mremap()'ed.

Signed-off-by: Andrei Vagin <avagin@gmail.com>
Reviewed-by: Vincenzo Frascino <vincenzo.frascino@arm.com>
Reviewed-by: Dmitry Safonov <dima@arista.com>
Link: https://lore.kernel.org/r/20200624083321.144975-6-avagin@gmail.com
Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
arch/arm64/kernel/vdso.c

index c11ee18e3e79667416a191ae0e938e17a5223481..d4202a32abc9ceed76779f41f77156d5a71088a7 100644 (file)
@@ -223,6 +223,17 @@ static vm_fault_t vvar_fault(const struct vm_special_mapping *sm,
        return vmf_insert_pfn(vma, vmf->address, pfn);
 }
 
+static int vvar_mremap(const struct vm_special_mapping *sm,
+                      struct vm_area_struct *new_vma)
+{
+       unsigned long new_size = new_vma->vm_end - new_vma->vm_start;
+
+       if (new_size != VVAR_NR_PAGES * PAGE_SIZE)
+               return -EINVAL;
+
+       return 0;
+}
+
 static int __setup_additional_pages(enum vdso_abi abi,
                                    struct mm_struct *mm,
                                    struct linux_binprm *bprm,
@@ -302,6 +313,7 @@ static struct vm_special_mapping aarch32_vdso_maps[] = {
        [AA32_MAP_VVAR] = {
                .name = "[vvar]",
                .fault = vvar_fault,
+               .mremap = vvar_mremap,
        },
        [AA32_MAP_VDSO] = {
                .name = "[vdso]",
@@ -468,6 +480,7 @@ static struct vm_special_mapping aarch64_vdso_maps[] __ro_after_init = {
        [AA64_MAP_VVAR] = {
                .name   = "[vvar]",
                .fault = vvar_fault,
+               .mremap = vvar_mremap,
        },
        [AA64_MAP_VDSO] = {
                .name   = "[vdso]",