• Piotr Krysiuk's avatar
    fs/namespace.c: fix mountpoint reference counter race · f511dc75
    Piotr Krysiuk authored
    A race condition between threads updating mountpoint reference counter
    affects longterm releases 4.4.220, 4.9.220, 4.14.177 and 4.19.118.
    
    The mountpoint reference counter corruption may occur when:
    * one thread increments m_count member of struct mountpoint
      [under namespace_sem, but not holding mount_lock]
        pivot_root()
    * another thread simultaneously decrements the same m_count
      [under mount_lock, but not holding namespace_sem]
        put_mountpoint()
          unhash_mnt()
            umount_mnt()
              mntput_no_expire()
    
    To fix this race condition, grab mount_lock before updating m_count in
    pivot_root().
    
    Reference: CVE-2020-12114
    Cc: Al Viro <viro@zeniv.linux.org.uk>
    Signed-off-by: default avatarPiotr Krysiuk <piotras@gmail.com>
    Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
    f511dc75
namespace.c 84.6 KB