]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
fs/namespace.c: fix mountpoint reference counter race
authorPiotr Krysiuk <piotras@gmail.com>
Mon, 27 Apr 2020 10:34:12 +0000 (11:34 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 2 May 2020 15:23:10 +0000 (17:23 +0200)
commit91e997939dda1a866f23ddfb043dcd4a3ff57524
tree805babc9e4cae48f2a04bb6a52985109b27dd4bc
parent3d275f1675eb7ce3adcf2bbdc584709dbf71b4b5
fs/namespace.c: fix mountpoint reference counter race

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: Piotr Krysiuk <piotras@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
fs/namespace.c