Thread (4 messages) flat view 4 messages, 3 authors, 2020-08-06

Re: [LTP-FAIL][02/21] fs: refactor ksys_umount

From: Christoph Hellwig <hch@lst.de>
Date: 2020-08-06 16:53:18
Also in: linux-fsdevel, lkml
Subsystem: filesystems (vfs and infrastructure), the rest · Maintainers: Alexander Viro, Christian Brauner, Linus Torvalds

Fix for umount03 below.  The other one works fine here, but from
your logs this might be a follow on if you run it after umount without
the fix.

---
From 718c12b6559c6be5fac39837b496fd1cd325a0d5 Mon Sep 17 00:00:00 2001
From: Christoph Hellwig <hch@lst.de>
Date: Thu, 6 Aug 2020 16:07:10 +0200
Subject: fs: fix a struct path leak in path_umount

Make sure we also put the dentry and vfsmnt in the illegal flags
and !may_mount cases.

Fixes: 41525f56e256 ("fs: refactor ksys_umount")
Reported-by: Vikas Kumar <redacted>
Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 fs/namespace.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)
diff --git a/fs/namespace.c b/fs/namespace.c
index a7301790abb211..1180437dfab909 100644
--- a/fs/namespace.c
+++ b/fs/namespace.c
@@ -1708,15 +1708,16 @@ static inline bool may_mandlock(void)
 
 int path_umount(struct path *path, int flags)
 {
-	struct mount *mnt;
+	struct mount *mnt = real_mount(path->mnt);
 	int retval;
 
+	retval = -EINVAL;
 	if (flags & ~(MNT_FORCE | MNT_DETACH | MNT_EXPIRE | UMOUNT_NOFOLLOW))
-		return -EINVAL;
+		goto dput_and_out;
+	retval = -EPERM;
 	if (!may_mount())
-		return -EPERM;
+		goto dput_and_out;
 
-	mnt = real_mount(path->mnt);
 	retval = -EINVAL;
 	if (path->dentry != path->mnt->mnt_root)
 		goto dput_and_out;
-- 
2.27.0
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help