• Pavel Emelyanov's avatar
    filemap: Get vma mnt_id early · e651a6eb
    Pavel Emelyanov authored
    We have a, well, issue with how we calculate the vma's mnt_id.
    
    Right now get one via criu side file descriptor that it got by
    opening the /proc/pid/map_files/ link. The problem is that these
    descriptors are 'merged' or 'borrowed' by adjacent vmas from
    previous ones. Thus, getting the mnt_id value for each of them
    makes no sense -- these files are the same.
    
    So move this mnt_id getting earlier into vma parsing code. This
    brings a potential problem -- if we have two adjacent vmas
    mapping the same inode (dev:ino pair) but living in different
    mount namespaces -- this check would produce wrong result.
    "Wrong" from the perspective that on restore correct file would
    be opened from wrong namespace.
    
    I propose to live with it, since this is not worse than the
    --evasive-devices option, it's _very_ unlikely, but saves a lot
    of openeings.
    
    Note, that in case app switched mount namespace and then mapped
    some new library (with dlopen) things would work correctly -- new
    vmas will likely be not adjacent and for different dev:ino.
    Signed-off-by: 's avatarPavel Emelyanov <xemul@parallels.com>
    e651a6eb
proc_parse.h 5.8 KB