Linux NFS development
 help / color / mirror / Atom feed
From: "Eric W. Biederman" <ebiederm@xmission.com>
To: trondmy@kernel.org
Cc: Christian Brauner <brauner@kernel.org>,
	 Alexander Viro <viro@zeniv.linux.org.uk>,
	 Jan Kara <jack@suse.cz>,
	linux-fsdevel@vger.kernel.org,  linux-nfs@vger.kernel.org
Subject: Re: [PATCH] umount: Allow superblock owners to force umount
Date: Tue, 18 Mar 2025 15:12:30 -0500	[thread overview]
Message-ID: <87wmcmxfm9.fsf@email.froward.int.ebiederm.org> (raw)
In-Reply-To: <12f212d4ef983714d065a6bb372fbb378753bf4c.1742315194.git.trond.myklebust@hammerspace.com> (trondmy@kernel.org's message of "Tue, 18 Mar 2025 12:29:21 -0400")

trondmy@kernel.org writes:

> From: Trond Myklebust <trond.myklebust@hammerspace.com>
>
> Loosen the permission check on forced umount to allow users holding
> CAP_SYS_ADMIN privileges in namespaces that are privileged with respect
> to the userns that originally mounted the filesystem.

Acked-by: "Eric W. Biederman" <ebiederm@xmission.com>

Semantically this seems reasonable.  I think forced umounts just got
overlooked when I was relaxing the other permission checks, to allow
things if you own the superblock.

The code has already checked you have permissions on the current mount
namespace.  Which was my immediate concern looking at the code.

Eric

> Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com>
> ---
>  fs/namespace.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/fs/namespace.c b/fs/namespace.c
> index 8f1000f9f3df..d401486fe95d 100644
> --- a/fs/namespace.c
> +++ b/fs/namespace.c
> @@ -2026,6 +2026,7 @@ static void warn_mandlock(void)
>  static int can_umount(const struct path *path, int flags)
>  {
>  	struct mount *mnt = real_mount(path->mnt);
> +	struct super_block *sb = path->dentry->d_sb;
>  
>  	if (!may_mount())
>  		return -EPERM;
> @@ -2035,7 +2036,7 @@ static int can_umount(const struct path *path, int flags)
>  		return -EINVAL;
>  	if (mnt->mnt.mnt_flags & MNT_LOCKED) /* Check optimistically */
>  		return -EINVAL;
> -	if (flags & MNT_FORCE && !capable(CAP_SYS_ADMIN))
> +	if (flags & MNT_FORCE && !ns_capable(sb->s_user_ns, CAP_SYS_ADMIN))
>  		return -EPERM;
>  	return 0;
>  }

  reply	other threads:[~2025-03-18 20:12 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-03-18 16:29 [PATCH] umount: Allow superblock owners to force umount trondmy
2025-03-18 20:12 ` Eric W. Biederman [this message]
2025-03-19  8:19 ` Christian Brauner
2025-03-19 21:53 ` Jeff Layton

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=87wmcmxfm9.fsf@email.froward.int.ebiederm.org \
    --to=ebiederm@xmission.com \
    --cc=brauner@kernel.org \
    --cc=jack@suse.cz \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-nfs@vger.kernel.org \
    --cc=trondmy@kernel.org \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox