]> git.proxmox.com Git - mirror_ubuntu-hirsute-kernel.git/commit
fs/namespace.c: WARN if mnt_count has become negative
authorEric Biggers <ebiggers@google.com>
Sun, 1 Nov 2020 04:40:21 +0000 (21:40 -0700)
committerPaolo Pisati <paolo.pisati@canonical.com>
Fri, 8 Jan 2021 11:25:25 +0000 (12:25 +0100)
commitf465dbe972d63a02b7b90cbe7922216860e21418
treee81ae106d0e62176be1baaaf22b2efbb745547ee
parent343502c46a2d22fbb9dc68049120a6b52a824fbf
fs/namespace.c: WARN if mnt_count has become negative

BugLink: https://bugs.launchpad.net/bugs/1910742
[ Upstream commit edf7ddbf1c5eb98b720b063b73e20e8a4a1ce673 ]

Missing calls to mntget() (or equivalently, too many calls to mntput())
are hard to detect because mntput() delays freeing mounts using
task_work_add(), then again using call_rcu().  As a result, mnt_count
can often be decremented to -1 without getting a KASAN use-after-free
report.  Such cases are still bugs though, and they point to real
use-after-frees being possible.

For an example of this, see the bug fixed by commit 1b0b9cc8d379
("vfs: fsmount: add missing mntget()"), discussed at
https://lkml.kernel.org/linux-fsdevel/20190605135401.GB30925@xxxxxxxxxxxxxxxxxxxxxxxxx/T/#u.
This bug *should* have been trivial to find.  But actually, it wasn't
found until syzkaller happened to use fchdir() to manipulate the
reference count just right for the bug to be noticeable.

Address this by making mntput_no_expire() issue a WARN if mnt_count has
become negative.

Suggested-by: Miklos Szeredi <miklos@szeredi.hu>
Signed-off-by: Eric Biggers <ebiggers@google.com>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Signed-off-by: Sasha Levin <sashal@kernel.org>
Signed-off-by: Paolo Pisati <paolo.pisati@canonical.com>
fs/namespace.c
fs/pnode.h