Skip to content

Commit bf740a9

Browse files
brooniewilldeacon
authored andcommitted
arm64: vdso: Map the vDSO text with guarded pages when built for BTI
The kernel is responsible for mapping the vDSO into userspace processes, including mapping the text section as executable. Handle the mapping of the vDSO for BTI similarly, mapping the text section as guarded pages so the BTI annotations in the vDSO become effective when they are present. This will mean that we can have BTI active for the vDSO in processes that do not otherwise support BTI. This should not be an issue for any expected use of the vDSO. Signed-off-by: Mark Brown <[email protected]> Reviewed-by: Catalin Marinas <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Will Deacon <[email protected]>
1 parent 5e02a18 commit bf740a9

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

arch/arm64/kernel/vdso.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,7 @@ static int __setup_additional_pages(enum arch_vdso_type arch_index,
142142
int uses_interp)
143143
{
144144
unsigned long vdso_base, vdso_text_len, vdso_mapping_len;
145+
unsigned long gp_flags = 0;
145146
void *ret;
146147

147148
vdso_text_len = vdso_lookup[arch_index].vdso_pages << PAGE_SHIFT;
@@ -160,10 +161,13 @@ static int __setup_additional_pages(enum arch_vdso_type arch_index,
160161
if (IS_ERR(ret))
161162
goto up_fail;
162163

164+
if (IS_ENABLED(CONFIG_ARM64_BTI_KERNEL) && system_supports_bti())
165+
gp_flags = VM_ARM64_BTI;
166+
163167
vdso_base += PAGE_SIZE;
164168
mm->context.vdso = (void *)vdso_base;
165169
ret = _install_special_mapping(mm, vdso_base, vdso_text_len,
166-
VM_READ|VM_EXEC|
170+
VM_READ|VM_EXEC|gp_flags|
167171
VM_MAYREAD|VM_MAYWRITE|VM_MAYEXEC,
168172
vdso_lookup[arch_index].cm);
169173
if (IS_ERR(ret))

0 commit comments

Comments
 (0)