Skip to contentSkip to conversation

fs: add a comment explaining how MNT_NS_INTERNAL affects mnt_may_suid()

PATCH In review Jann Horn 1 participant 2 messages Nov 21, 2018 – Feb 4, 2019 VFS

lore
Share & tools
lore

Jann Horn

author
#0 lore raw

PATCH 1/1 fs: add a comment explaining how MNT_NS_INTERNAL affects mnt_may_suid()

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.)

---
 fs/namespace.c | 3 +++
 1 file changed, 3 insertions(+)
fs/namespace.c +3 -0
index a7f91265ea67..e68488426e42 100644
@@ -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);
Signature · 1 line
2.20.0.rc0.387.gc7a69e6b6c-goog
author
#1 lore raw
Quoted 3 lines · Jann Horn

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.)

Ping. Al, can you take this into your tree? fs/namespace.c is your stuff, right?

Quoted 22 lines
---
 fs/namespace.c | 3 +++
 1 file changed, 3 insertions(+)
fs/namespace.c +3 -1
index a7f91265ea67..e68488426e42 100644
@@ -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