• Pavel Emelyanov's avatar
    reg-files: Do not try to linkat with wrong user · 9a392dff
    Pavel Emelyanov authored
    We link files to each other at restore time to restore
    unlinked paths. Kernel has strange secutiry restrictions
    about linkat we use. If the fsuid of the caller doesn't
    equals the uid of the file and the file is not "safe"
    one, then only global CAP_CHOWN will be allowed to link().
    
    This brings problems in user namespaces -- uns root is
    not allowed to linkat any file, unlike global root.
    
    Fortunately, we can change the fsuid temporarily and
    still linkat the file we want. Hopefully this hack will
    go away some day soon, when the kernel will have saner
    checks for linkat capabilities.
    Signed-off-by: 's avatarPavel Emelyanov <xemul@parallels.com>
    Acked-by: 's avatarAndrew Vagin <avagin@parallels.com>
    9a392dff
files-reg.c 29.1 KB