• Andrew Vagin's avatar
    mount: fix a race between restoring namespaces and file mappings (v2) · af55c059
    Andrew Vagin authored
    Currently we wait when a namespace will be restored to get its root.
    We need to open a namespace root to open a file to restore a memory mapping.
    
    A process restores mappings and only then forks children. So we can have
    a situation, when we need to open a file from a namespace, which will be
    "restored" by one of our children.
    
    The root task restores all mount namespaces and opens a file descriptor
    for each of them. In this patch we open root for each mntns in the root
    task.
    
    If we neeed to get root of a namespace which isn't populated, we can get
    it from the root task. After the CR_STATE_FORKING stage, the root task
    closes all namespace descriptors ane we know that all namespaces are
    populated at this moment.
    
    v2: don't close root_fd for root ns, because it was not opened
    Signed-off-by: 's avatarAndrew Vagin <avagin@virtuozzo.com>
    Signed-off-by: 's avatarPavel Emelyanov <xemul@parallels.com>
    af55c059
mount.c 75.8 KB