From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-vs1-f74.google.com ([209.85.217.74]:52051 "EHLO mail-vs1-f74.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732450AbeKVGfC (ORCPT ); Thu, 22 Nov 2018 01:35:02 -0500 Received: by mail-vs1-f74.google.com with SMTP id p1so2506023vsc.18 for ; Wed, 21 Nov 2018 11:59:18 -0800 (PST) Date: Wed, 21 Nov 2018 20:58:59 +0100 Message-Id: <20181121195859.10894-1-jannh@google.com> Mime-Version: 1.0 Subject: [PATCH] fs: add a comment explaining how MNT_NS_INTERNAL affects mnt_may_suid() From: Jann Horn To: Alexander Viro , jannh@google.com Cc: Andy Lutomirski , linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Sender: linux-fsdevel-owner@vger.kernel.org List-ID: 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 --- 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