From patchwork Mon Dec 7 21:21:22 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Seth Forshee X-Patchwork-Id: 7792761 Return-Path: X-Original-To: patchwork-selinux@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 5A815BEEE1 for ; Mon, 7 Dec 2015 23:02:05 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id A5E6220576 for ; Mon, 7 Dec 2015 23:02:04 +0000 (UTC) Received: from emvm-gh1-uea08.nsa.gov (emvm-gh1-uea08.nsa.gov [63.239.67.9]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id C74CF20585 for ; Mon, 7 Dec 2015 23:02:03 +0000 (UTC) X-TM-IMSS-Message-ID: <3ea74afd0002978e@nsa.gov> Received: from tarius.tycho.ncsc.mil ([144.51.242.1]) by nsa.gov ([10.208.42.193]) with ESMTP (TREND IMSS SMTP Service 7.1) id 3ea74afd0002978e ; Mon, 7 Dec 2015 18:00:20 -0500 Received: from prometheus.infosec.tycho.ncsc.mil (prometheus [192.168.25.40]) by tarius.tycho.ncsc.mil (8.14.4/8.14.4) with ESMTP id tB7N0KaT010160; Mon, 7 Dec 2015 18:00:21 -0500 Received: from tarius.tycho.ncsc.mil (tarius.infosec.tycho.ncsc.mil [144.51.242.1]) by prometheus.infosec.tycho.ncsc.mil (8.15.2/8.15.2) with ESMTP id tB7LQXYQ263200 for ; Mon, 7 Dec 2015 16:26:33 -0500 Received: from goalie.tycho.ncsc.mil (goalie [144.51.242.250]) by tarius.tycho.ncsc.mil (8.14.4/8.14.4) with ESMTP id tB7LNOqI001405 for ; Mon, 7 Dec 2015 16:26:33 -0500 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: A1CeBABD9WVW/7HfVdFeGQEBAQEPAQEBAYRLuxeEFoYOAoITAQEBAQEBhUABAQEDEhUZAQE3AQ9RNAEFARwGARIiiA2iR4ExPjGKV4VUAQWLdQEBAQEBAQQCARoGCoQ6ghCOOI4kiEKPF4c2M4Vui242gRdjggSCH1MBhW4BAQE X-IPAS-Result: A1CeBABD9WVW/7HfVdFeGQEBAQEPAQEBAYRLuxeEFoYOAoITAQEBAQEBhUABAQEDEhUZAQE3AQ9RNAEFARwGARIiiA2iR4ExPjGKV4VUAQWLdQEBAQEBAQQCARoGCoQ6ghCOOI4kiEKPF4c2M4Vui242gRdjggSCH1MBhW4BAQE X-IronPort-AV: E=Sophos;i="5.20,396,1444708800"; d="scan'208";a="5004909" Received: from emvm-gh1-uea08.nsa.gov ([10.208.42.193]) by goalie.tycho.ncsc.mil with ESMTP; 07 Dec 2015 16:23:39 -0500 X-TM-IMSS-Message-ID: <3e4eb9e30002802b@nsa.gov> Received: from mail-io0-f177.google.com (mail-io0-f177.google.com [209.85.223.177]) by nsa.gov ([10.208.42.193]) with ESMTP (TREND IMSS SMTP Service 7.1; TLSv1/SSLv3 AES128-SHA (128/128)) id 3e4eb9e30002802b ; Mon, 7 Dec 2015 16:23:35 -0500 Received: by iofh3 with SMTP id h3so3967077iof.3 for ; Mon, 07 Dec 2015 13:23:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=amcOvjSJibxe9D0J1vUSJTc4CWm1bFCnFTdrUcC934M=; b=PN5VPgdmm5IPCzA2f3Horzc0X/Sdb+kwZhkJNIRWlVanZ+YvG+GAY5cb+zE+ccWuGU 9hzkiHpqheXaFOp0eEChNFy2Fl3d+TtBeESGj2cj5IdPVqhyJlo+FcpAqEU+Uj5oVaAc E+MAtfNlJDbg0BkhJNxNIkKEctjDIo/IYLKvA+JwHb6NGvjyOcCY5Cly1YRKp/kaadML UhME+VYLjTW+CJysjQiJJOQQWnB4kEEqt1qJlpz/NMIcU+jNC6HP2bN3s8l7YP8TWFGQ a8NpGdMR+P7ZYy0P32idga1NKBLdSI+ZURFO4amkloJO/ChwXZXiHIHp9MMOHKvHkIWC UzFg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=amcOvjSJibxe9D0J1vUSJTc4CWm1bFCnFTdrUcC934M=; b=IljibXbVp/qLjYZ/+TeeHK9uOGEkoSVTN87XQMXHUWJTnXPBlXmRWZeA1/ft8ROjiR Y6USOjXnWu58ZesTigmvmQrhoo96OjKidjaG/ggxVnveLkLPlCKprievG3S3Q0PXbWm+ yXjsWwEzsc3g1WSiBl8aXvnz7xJdMxMdwsL5xFtFgJmV0j3xpP62gfbqcYFTs8bwpkWa +aRv2NeB76pj6X3VD5b4Z4dl++QnNcwGdFYSaVOWf8geh+hRJvhnz+n8Qznax9YyZz7G EPKwzr3jRM3Z9DylUBl96z5OixbzUxx+/RgxFn/GKOpVXtA774FQ8c8b4u0d5DDRrsUp g7Fg== X-Gm-Message-State: ALoCoQkR5sDzTYcEo6z2YdCQwL6hjE838oyuGYS1VeSEA4oS1L0EUJk3FwDugHnWE2hTrYFBElpEtX77laE3IjvZ67pMVmuPnw== X-Received: by 10.107.152.142 with SMTP id a136mr630582ioe.110.1449523417573; Mon, 07 Dec 2015 13:23:37 -0800 (PST) Received: from localhost (199-87-125-144.dyn.kc.surewest.net. [199.87.125.144]) by smtp.gmail.com with ESMTPSA id z6sm7121179ign.1.2015.12.07.13.23.36 (version=TLS1_2 cipher=AES128-SHA bits=128/128); Mon, 07 Dec 2015 13:23:37 -0800 (PST) From: Seth Forshee To: "Eric W. Biederman" , Alexander Viro Subject: [PATCH v2 13/18] fs: Allow superblock owner to access do_remount_sb() Date: Mon, 7 Dec 2015 15:21:22 -0600 Message-Id: <1449523289-144238-14-git-send-email-seth.forshee@canonical.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1449523289-144238-1-git-send-email-seth.forshee@canonical.com> References: <1449523289-144238-1-git-send-email-seth.forshee@canonical.com> X-TM-AS-MML: disable X-Mailman-Approved-At: Mon, 07 Dec 2015 16:44:28 -0500 X-BeenThere: selinux@tycho.nsa.gov X-Mailman-Version: 2.1.20 Precedence: list List-Id: "Security-Enhanced Linux \(SELinux\) mailing list" List-Post: List-Help: Cc: Serge Hallyn , Seth Forshee , dm-devel@redhat.com, Miklos Szeredi , Richard Weinberger , linux-security-module@vger.kernel.org, linux-bcache@vger.kernel.org, linux-kernel@vger.kernel.org, linux-raid@vger.kernel.org, fuse-devel@lists.sourceforge.net, Austin S Hemmelgarn , linux-mtd@lists.infradead.org, selinux@tycho.nsa.gov, linux-fsdevel@vger.kernel.org MIME-Version: 1.0 Errors-To: selinux-bounces@tycho.nsa.gov Sender: "Selinux" X-Spam-Status: No, score=-6.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID,T_RP_MATCHES_RCVD,UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Superblock level remounts are currently restricted to global CAP_SYS_ADMIN, as is the path for changing the root mount to read only on umount. Loosen both of these permission checks to also allow CAP_SYS_ADMIN in any namespace which is privileged towards the userns which originally mounted the filesystem. Signed-off-by: Seth Forshee Acked-by: "Eric W. Biederman" Acked-by: Serge Hallyn --- fs/namespace.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/fs/namespace.c b/fs/namespace.c index 18fc58760aec..b00a765895e7 100644 --- a/fs/namespace.c +++ b/fs/namespace.c @@ -1510,7 +1510,7 @@ static int do_umount(struct mount *mnt, int flags) * Special case for "unmounting" root ... * we just try to remount it readonly. */ - if (!capable(CAP_SYS_ADMIN)) + if (!ns_capable(sb->s_user_ns, CAP_SYS_ADMIN)) return -EPERM; down_write(&sb->s_umount); if (!(sb->s_flags & MS_RDONLY)) @@ -2199,7 +2199,7 @@ static int do_remount(struct path *path, int flags, int mnt_flags, down_write(&sb->s_umount); if (flags & MS_BIND) err = change_mount_flags(path->mnt, flags); - else if (!capable(CAP_SYS_ADMIN)) + else if (!ns_capable(sb->s_user_ns, CAP_SYS_ADMIN)) err = -EPERM; else err = do_remount_sb(sb, flags, data, 0);