Commit 86f613bb9b10e8352d6ad6ca53ee5863c8d2fe2a

Authored by Vasily Averin
Committed by Greg Kroah-Hartman
1 parent 1977b3e16f

fs: umount on symlink leaks mnt count

commit 295dc39d941dc2ae53d5c170365af4c9d5c16212 upstream.

Currently umount on symlink blocks following umount:

/vz is separate mount

# ls /vz/ -al | grep test
drwxr-xr-x.  2 root root       4096 Jul 19 01:14 testdir
lrwxrwxrwx.  1 root root         11 Jul 19 01:16 testlink -> /vz/testdir
# umount -l /vz/testlink
umount: /vz/testlink: not mounted (expected)

# lsof /vz
# umount /vz
umount: /vz: device is busy. (unexpected)

In this case mountpoint_last() gets an extra refcount on path->mnt

Signed-off-by: Vasily Averin <vvs@openvz.org>
Acked-by: Ian Kent <raven@themaw.net>
Acked-by: Jeff Layton <jlayton@primarydata.com>
Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

Showing 1 changed file with 2 additions and 1 deletions Side-by-side Diff

... ... @@ -2256,9 +2256,10 @@
2256 2256 goto out;
2257 2257 }
2258 2258 path->dentry = dentry;
2259   - path->mnt = mntget(nd->path.mnt);
  2259 + path->mnt = nd->path.mnt;
2260 2260 if (should_follow_link(dentry, nd->flags & LOOKUP_FOLLOW))
2261 2261 return 1;
  2262 + mntget(path->mnt);
2262 2263 follow_mount(path);
2263 2264 error = 0;
2264 2265 out: