mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-10-29 11:11:45 -04:00
x86/vdso: Add mremap hook to vm_special_mapping
Add possibility for 32-bit user-space applications to move the vDSO mapping. Previously, when a user-space app called mremap() for the vDSO address, in the syscall return path it would land on the previous address of the vDSOpage, resulting in segmentation violation. Now it lands fine and returns to userspace with a remapped vDSO. This will also fix the context.vdso pointer for 64-bit, which does not affect the user of vDSO after mremap() currently, but this may change in the future. As suggested by Andy, return -EINVAL for mremap() that would split the vDSO image: that operation cannot possibly result in a working system so reject it. Renamed and moved the text_mapping structure declaration inside map_vdso(), as it used only there and now it complements the vvar_mapping variable. There is still a problem for remapping the vDSO in glibc applications: the linker relocates addresses for syscalls on the vDSO page, so you need to relink with the new addresses. Without that the next syscall through glibc may fail: Program received signal SIGSEGV, Segmentation fault. #0 0xf7fd9b80 in __kernel_vsyscall () #1 0xf7ec8238 in _exit () from /usr/lib32/libc.so.6 Signed-off-by: Dmitry Safonov <[email protected]> Acked-by: Andy Lutomirski <[email protected]> Cc: [email protected] Cc: Borislav Petkov <[email protected]> Cc: Brian Gerst <[email protected]> Cc: Denys Vlasenko <[email protected]> Cc: H. Peter Anvin <[email protected]> Cc: Josh Poimboeuf <[email protected]> Cc: Linus Torvalds <[email protected]> Cc: Peter Zijlstra <[email protected]> Cc: Thomas Gleixner <[email protected]> Cc: [email protected] Link: http://lkml.kernel.org/r/[email protected] Signed-off-by: Ingo Molnar <[email protected]>
This commit is contained in:
parent
39380b80d7
commit
b059a453b1
3 changed files with 55 additions and 5 deletions
10
mm/mmap.c
10
mm/mmap.c
|
|
@ -2943,9 +2943,19 @@ static const char *special_mapping_name(struct vm_area_struct *vma)
|
|||
return ((struct vm_special_mapping *)vma->vm_private_data)->name;
|
||||
}
|
||||
|
||||
static int special_mapping_mremap(struct vm_area_struct *new_vma)
|
||||
{
|
||||
struct vm_special_mapping *sm = new_vma->vm_private_data;
|
||||
|
||||
if (sm->mremap)
|
||||
return sm->mremap(sm, new_vma);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static const struct vm_operations_struct special_mapping_vmops = {
|
||||
.close = special_mapping_close,
|
||||
.fault = special_mapping_fault,
|
||||
.mremap = special_mapping_mremap,
|
||||
.name = special_mapping_name,
|
||||
};
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue