[PATCH 5/6] arm64/vdso: Restrict splitting VVAR VMA

2020-06-24 Thread Andrei Vagin
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.

Reviewed-by: Vincenzo Frascino 
Reviewed-by: Dmitry Safonov 
Signed-off-by: Andrei Vagin 
---
 arch/arm64/kernel/vdso.c | 13 +
 1 file changed, 13 insertions(+)

diff --git a/arch/arm64/kernel/vdso.c b/arch/arm64/kernel/vdso.c
index be9ca8c46cff..8be6bd6625db 100644
--- a/arch/arm64/kernel/vdso.c
+++ b/arch/arm64/kernel/vdso.c
@@ -224,6 +224,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,
@@ -306,6 +317,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]",
@@ -474,6 +486,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]",
-- 
2.24.1



[PATCH 5/6] arm64/vdso: Restrict splitting VVAR VMA

2020-06-16 Thread Andrei Vagin
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.

Reviewed-by: Vincenzo Frascino 
Reviewed-by: Dmitry Safonov 
Signed-off-by: Andrei Vagin 
---
 arch/arm64/kernel/vdso.c | 13 +
 1 file changed, 13 insertions(+)

diff --git a/arch/arm64/kernel/vdso.c b/arch/arm64/kernel/vdso.c
index 21bdd0d74f40..68e021324113 100644
--- a/arch/arm64/kernel/vdso.c
+++ b/arch/arm64/kernel/vdso.c
@@ -226,6 +226,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,
@@ -308,6 +319,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]",
@@ -476,6 +488,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]",
-- 
2.24.1



[PATCH 5/6] arm64/vdso: Restrict splitting VVAR VMA

2020-06-02 Thread Andrei Vagin
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.

Reviewed-by: Vincenzo Frascino 
Signed-off-by: Andrei Vagin 
---
 arch/arm64/kernel/vdso.c | 13 +
 1 file changed, 13 insertions(+)

diff --git a/arch/arm64/kernel/vdso.c b/arch/arm64/kernel/vdso.c
index f3baecd8edfb..8b17d7d10729 100644
--- a/arch/arm64/kernel/vdso.c
+++ b/arch/arm64/kernel/vdso.c
@@ -235,6 +235,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 arch_vdso_type arch_index,
struct mm_struct *mm,
struct linux_binprm *bprm,
@@ -317,6 +328,7 @@ static struct vm_special_mapping aarch32_vdso_spec[C_PAGES] 
= {
{
.name = "[vvar]",
.fault = vvar_fault,
+   .mremap = vvar_mremap,
},
{
.name = "[vdso]",
@@ -488,6 +500,7 @@ static struct vm_special_mapping vdso_spec[A_PAGES] 
__ro_after_init = {
{
.name   = "[vvar]",
.fault = vvar_fault,
+   .mremap = vvar_mremap,
},
{
.name   = "[vdso]",
-- 
2.24.1