Skip to content

Commit

Permalink
linux: Unmap the VDSO page when unloading
Browse files Browse the repository at this point in the history
linux_shared_page_init() creates an object and grabs and maps a single
page to back the VDSO.  When destroying the VDSO object, we failed to
destroy the mapping and free KVA.  Fix this.

Reviewed by:	kib
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D28696

(cherry picked from commit 0fc8a79)
  • Loading branch information
markjdb committed Feb 23, 2021
1 parent ab3e1bd commit 3df2766
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 5 deletions.
3 changes: 2 additions & 1 deletion sys/amd64/linux/linux_sysvec.c
Original file line number Diff line number Diff line change
Expand Up @@ -818,7 +818,8 @@ static void
linux_vdso_deinstall(void *param)
{

__elfN(linux_shared_page_fini)(linux_shared_page_obj);
__elfN(linux_shared_page_fini)(linux_shared_page_obj,
linux_shared_page_mapping);
}
SYSUNINIT(elf_linux_vdso_uninit, SI_SUB_EXEC, SI_ORDER_FIRST,
linux_vdso_deinstall, NULL);
Expand Down
3 changes: 2 additions & 1 deletion sys/amd64/linux32/linux32_sysvec.c
Original file line number Diff line number Diff line change
Expand Up @@ -961,7 +961,8 @@ static void
linux_vdso_deinstall(void *param)
{

__elfN(linux_shared_page_fini)(linux_shared_page_obj);
__elfN(linux_shared_page_fini)(linux_shared_page_obj,
linux_shared_page_mapping);
}
SYSUNINIT(elf_linux_vdso_uninit, SI_SUB_EXEC, SI_ORDER_FIRST,
linux_vdso_deinstall, NULL);
Expand Down
3 changes: 2 additions & 1 deletion sys/arm64/linux/linux_sysvec.c
Original file line number Diff line number Diff line change
Expand Up @@ -461,7 +461,8 @@ linux_vdso_deinstall(const void *param)
{

LIN_SDT_PROBE0(sysvec, linux_vdso_deinstall, todo);
__elfN(linux_shared_page_fini)(linux_shared_page_obj);
__elfN(linux_shared_page_fini)(linux_shared_page_obj,
linux_shared_page_mapping);
}
SYSUNINIT(elf_linux_vdso_uninit, SI_SUB_EXEC, SI_ORDER_FIRST,
linux_vdso_deinstall, NULL);
Expand Down
6 changes: 5 additions & 1 deletion sys/compat/linux/linux_vdso.c
Original file line number Diff line number Diff line change
Expand Up @@ -93,9 +93,13 @@ __elfN(linux_shared_page_init)(char **mapping)
}

void
__elfN(linux_shared_page_fini)(vm_object_t obj)
__elfN(linux_shared_page_fini)(vm_object_t obj, void *mapping)
{
vm_offset_t va;

va = (vm_offset_t)mapping;
pmap_qremove(va, 1);
kva_free(va, PAGE_SIZE);
vm_object_deallocate(obj);
}

Expand Down
2 changes: 1 addition & 1 deletion sys/compat/linux/linux_vdso.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ struct linux_vdso_sym {
};

vm_object_t __elfN(linux_shared_page_init)(char **);
void __elfN(linux_shared_page_fini)(vm_object_t);
void __elfN(linux_shared_page_fini)(vm_object_t, void *);
void __elfN(linux_vdso_fixup)(struct sysentvec *);
void __elfN(linux_vdso_reloc)(struct sysentvec *);
void __elfN(linux_vdso_sym_init)(struct linux_vdso_sym *);
Expand Down

0 comments on commit 3df2766

Please sign in to comment.