summaryrefslogtreecommitdiff
path: root/arch/riscv/kernel/vdso.c
diff options
context:
space:
mode:
authorVincent Chen <vincent.chen@sifive.com>2020-06-09 22:14:49 +0800
committerPalmer Dabbelt <palmerdabbelt@google.com>2020-06-10 19:47:35 -0700
commit01f76386b0ac0b1c1094456c8f43ea6085fc49d2 (patch)
tree889dc2bf914443827c96e1d7a7f6f4b449e742a2 /arch/riscv/kernel/vdso.c
parentad5d1122b82fbd6a816d1b9d26ee01a6dbc2d757 (diff)
riscv: set the permission of vdso_data to read-only
The original vdso_data page is empty, so the permission of the vdso_data page can be the same with the vdso text page. After introducing the vDSO common flow, the vdso_data is not empty and the permission should be changed to read-only. Signed-off-by: Vincent Chen <vincent.chen@sifive.com> Signed-off-by: Palmer Dabbelt <palmerdabbelt@google.com>
Diffstat (limited to 'arch/riscv/kernel/vdso.c')
-rw-r--r--arch/riscv/kernel/vdso.c16
1 files changed, 14 insertions, 2 deletions
diff --git a/arch/riscv/kernel/vdso.c b/arch/riscv/kernel/vdso.c
index 70b6461a6387..94450332aa4f 100644
--- a/arch/riscv/kernel/vdso.c
+++ b/arch/riscv/kernel/vdso.c
@@ -79,13 +79,22 @@ int arch_setup_additional_pages(struct linux_binprm *bprm,
*/
mm->context.vdso = (void *)vdso_base;
- ret = install_special_mapping(mm, vdso_base, vdso_len,
+ ret =
+ install_special_mapping(mm, vdso_base, vdso_pages << PAGE_SHIFT,
(VM_READ | VM_EXEC | VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC),
vdso_pagelist);
- if (unlikely(ret))
+ if (unlikely(ret)) {
mm->context.vdso = NULL;
+ goto end;
+ }
+ vdso_base += (vdso_pages << PAGE_SHIFT);
+ ret = install_special_mapping(mm, vdso_base, PAGE_SIZE,
+ (VM_READ | VM_MAYREAD), &vdso_pagelist[vdso_pages]);
+
+ if (unlikely(ret))
+ mm->context.vdso = NULL;
end:
up_write(&mm->mmap_sem);
return ret;
@@ -95,5 +104,8 @@ const char *arch_vma_name(struct vm_area_struct *vma)
{
if (vma->vm_mm && (vma->vm_start == (long)vma->vm_mm->context.vdso))
return "[vdso]";
+ if (vma->vm_mm && (vma->vm_start ==
+ (long)vma->vm_mm->context.vdso + PAGE_SIZE))
+ return "[vdso_data]";
return NULL;
}