• Pavel Emelyanov's avatar
    irmap: Get root mntfd before releasing tasks on predump · b4768792
    Pavel Emelyanov authored
    We have a use-after-free in predump code:
    
    1st the free_pstree() is called in pre_dump_tasks(), then we
    go to irmap_predump_run() which may call the lookup_irmap()
    which, in turn, dereferences the root_item to get the root
    mount ns fd.
    
    But the problem is bigger than that. After we've released the
    tasks (done before freeing pstree on predump) we can no longer
    access them by PIDs, so keeping the root-item after irmap
    scan is not a fix.
    
    Fix is to get the root fd before releasing the tasks and using
    one in irmap scanner.
    
    Caught recently on iterative inotify_irmap test.
    Signed-off-by: 's avatarPavel Emelyanov <xemul@parallels.com>
    Acked-by: 's avatarAndrew Vagin <avagin@parallels.com>
    b4768792
irmap.h 396 Bytes