Skip to content

Commit 01f7638

Browse files
VincentZWCpalmer-dabbelt
authored andcommitted
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 <[email protected]> Signed-off-by: Palmer Dabbelt <[email protected]>
1 parent ad5d112 commit 01f7638

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

arch/riscv/kernel/vdso.c

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,13 +79,22 @@ int arch_setup_additional_pages(struct linux_binprm *bprm,
7979
*/
8080
mm->context.vdso = (void *)vdso_base;
8181

82-
ret = install_special_mapping(mm, vdso_base, vdso_len,
82+
ret =
83+
install_special_mapping(mm, vdso_base, vdso_pages << PAGE_SHIFT,
8384
(VM_READ | VM_EXEC | VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC),
8485
vdso_pagelist);
8586

86-
if (unlikely(ret))
87+
if (unlikely(ret)) {
8788
mm->context.vdso = NULL;
89+
goto end;
90+
}
8891

92+
vdso_base += (vdso_pages << PAGE_SHIFT);
93+
ret = install_special_mapping(mm, vdso_base, PAGE_SIZE,
94+
(VM_READ | VM_MAYREAD), &vdso_pagelist[vdso_pages]);
95+
96+
if (unlikely(ret))
97+
mm->context.vdso = NULL;
8998
end:
9099
up_write(&mm->mmap_sem);
91100
return ret;
@@ -95,5 +104,8 @@ const char *arch_vma_name(struct vm_area_struct *vma)
95104
{
96105
if (vma->vm_mm && (vma->vm_start == (long)vma->vm_mm->context.vdso))
97106
return "[vdso]";
107+
if (vma->vm_mm && (vma->vm_start ==
108+
(long)vma->vm_mm->context.vdso + PAGE_SIZE))
109+
return "[vdso_data]";
98110
return NULL;
99111
}

0 commit comments

Comments
 (0)