linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jann Horn <jannh@google.com>
To: Alexander Viro <viro@zeniv.linux.org.uk>, jannh@google.com
Cc: Andy Lutomirski <luto@kernel.org>,
	linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org
Subject: [PATCH] fs: add a comment explaining how MNT_NS_INTERNAL affects mnt_may_suid()
Date: Wed, 21 Nov 2018 20:58:59 +0100	[thread overview]
Message-ID: <20181121195859.10894-1-jannh@google.com> (raw)

commit 380cf5ba6b0a ("fs: Treat foreign mounts as nosuid"), in addition to
the intended effect, also prevented suid execution of memfd files.
(And I think that's a good change.)

Signed-off-by: Jann Horn <jannh@google.com>
---
 fs/namespace.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/fs/namespace.c b/fs/namespace.c
index a7f91265ea67..e68488426e42 100644
--- a/fs/namespace.c
+++ b/fs/namespace.c
@@ -3400,6 +3400,9 @@ bool mnt_may_suid(struct vfsmount *mnt)
 	 * prevents namespaces from trusting potentially unsafe
 	 * suid/sgid bits, file caps, or security labels that originate
 	 * in other namespaces.
+	 *
+	 * check_mnt() rejects MNT_NS_INTERNAL mounts; this means that suid
+	 * execution is blocked for files on internal mounts, e.g. memfds.
 	 */
 	return !(mnt->mnt_flags & MNT_NOSUID) && check_mnt(real_mount(mnt)) &&
 	       current_in_userns(mnt->mnt_sb->s_user_ns);
-- 
2.20.0.rc0.387.gc7a69e6b6c-goog

             reply	other threads:[~2018-11-22  6:35 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-11-21 19:58 Jann Horn [this message]
2019-02-04  4:04 ` [PATCH] fs: add a comment explaining how MNT_NS_INTERNAL affects mnt_may_suid() Jann Horn

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=20181121195859.10894-1-jannh@google.com \
    --to=jannh@google.com \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=luto@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;
as well as URLs for NNTP newsgroup(s).