• Dmitry Safonov's avatar
    x86/vdso: Add mremap hook to vm_special_mapping · b059a453
    Dmitry Safonov authored
    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: default avatarDmitry Safonov <dsafonov@virtuozzo.com>
    Acked-by: default avatarAndy Lutomirski <luto@kernel.org>
    Cc: 0x7f454c46@gmail.com
    Cc: Borislav Petkov <bp@alien8.de>
    Cc: Brian Gerst <brgerst@gmail.com>
    Cc: Denys Vlasenko <dvlasenk@redhat.com>
    Cc: H. Peter Anvin <hpa@zytor.com>
    Cc: Josh Poimboeuf <jpoimboe@redhat.com>
    Cc: Linus Torvalds <torvalds@linux-foundation.org>
    Cc: Peter Zijlstra <peterz@infradead.org>
    Cc: Thomas Gleixner <tglx@linutronix.de>
    Cc: linux-mm@kvack.org
    Link: http://lkml.kernel.org/r/20160628113539.13606-2-dsafonov@virtuozzo.comSigned-off-by: default avatarIngo Molnar <mingo@kernel.org>
    b059a453
mmap.c 88.9 KB