All of lore.kernel.org
 help / color / mirror / Atom feed
From: Christoph Hellwig <hch@lst.de>
To: Vikas Kumar <vikas.kumar2@arm.com>
Cc: Christoph Hellwig <hch@lst.de>, Al Viro <viro@zeniv.linux.org.uk>,
	Linus Torvalds <torvalds@linux-foundation.org>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org,
	linux-api@vger.kernel.org, rafael@kernel.org
Subject: Re: [LTP-FAIL][02/21] fs: refactor ksys_umount
Date: Thu, 6 Aug 2020 16:17:32 +0200	[thread overview]
Message-ID: <20200806141732.GA5902@lst.de> (raw)
In-Reply-To: <d28d2235-9b1c-0403-59ca-e57ac5d0460e@arm.com>

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 <vikas.kumar2@arm.com>
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


  reply	other threads:[~2020-08-06 16:53 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-08-06  9:43 [LTP-FAIL][02/21] fs: refactor ksys_umount Vikas Kumar
2020-08-06 14:17 ` Christoph Hellwig [this message]
2020-08-06 14:32   ` Al Viro
2020-08-06 14:48     ` Christoph Hellwig

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200806141732.GA5902@lst.de \
    --to=hch@lst.de \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-api@vger.kernel.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=rafael@kernel.org \
    --cc=torvalds@linux-foundation.org \
    --cc=vikas.kumar2@arm.com \
    --cc=viro@zeniv.linux.org.uk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.