From patchwork Wed Dec 2 15:40:13 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Seth Forshee X-Patchwork-Id: 7748671 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 7087FBEEE1 for ; Wed, 2 Dec 2015 16:34:03 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id BFEED205E1 for ; Wed, 2 Dec 2015 16:34:02 +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 D2E9B20549 for ; Wed, 2 Dec 2015 16:34:01 +0000 (UTC) X-TM-IMSS-Message-ID: <2384b3ce00017db3@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 2384b3ce00017db3 ; Wed, 2 Dec 2015 11:32:49 -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 tB2GWY9g011984; Wed, 2 Dec 2015 11:32:36 -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 tB2FgbTk185610 for ; Wed, 2 Dec 2015 10:42:37 -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 tB2FgWlI006648 for ; Wed, 2 Dec 2015 10:42:37 -0500 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: A1CeBAA0EF9W/6vVVdFeGQEBAQEPAQEBAYRMu3CEFoYOAoIYAQEBAQEBhUABAQEDEhUZAQE3AQ9RNAEFARwGARIiiA2hFYExPjGKV4VUAQWMIwEBAQEBAQQCARoGCoQ6ghCONo4giEGPFoc2M4Vui2s2gRdjggSCH1MBhW4BAQE X-IPAS-Result: A1CeBAA0EF9W/6vVVdFeGQEBAQEPAQEBAYRMu3CEFoYOAoIYAQEBAQEBhUABAQEDEhUZAQE3AQ9RNAEFARwGARIiiA2hFYExPjGKV4VUAQWMIwEBAQEBAQQCARoGCoQ6ghCONo4giEGPFoc2M4Vui2s2gRdjggSCH1MBhW4BAQE X-IronPort-AV: E=Sophos;i="5.20,373,1444708800"; d="scan'208";a="4986127" Received: from emvm-gh1-uea08.nsa.gov ([10.208.42.193]) by goalie.tycho.ncsc.mil with ESMTP; 02 Dec 2015 10:42:31 -0500 X-TM-IMSS-Message-ID: <2356c8c400015ef5@nsa.gov> Received: from mail-ig0-f171.google.com (mail-ig0-f171.google.com [209.85.213.171]) by nsa.gov ([10.208.42.193]) with ESMTP (TREND IMSS SMTP Service 7.1; TLSv1/SSLv3 AES128-SHA (128/128)) id 2356c8c400015ef5 ; Wed, 2 Dec 2015 10:42:39 -0500 Received: by igl9 with SMTP id 9so113072239igl.0 for ; Wed, 02 Dec 2015 07:42:30 -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=2bXD8ZlB3biQUOg1qqelwM0pxf5+YP3ufVslYwP4MGM=; b=z9IlqFd16DCudMjEnC7RFvKSox+mwl7peKZhF6frQ7pbRhAmRTJ34QUE5JAqG6CBKf D5gsdyR0cBAw+mR9BtWfyLWHkgCra6UDPKGMc7vapqJvLdZku3HeO3xvnty8Vs4SZSaq e35+8EjtV86FhGj1Q5/wswF6Kx0E02zcOer5KZCwunkQo1qdK2+WG6GA1TSFpynKsE21 6qN0HktAJd98xzoOhdtdfO/egHoBUicvHZRKOXjtwAqxP2Db3PeGNjKk3O3W5y9JEnT+ fO4uv/Kg2iNn3YGw/meEIR7ym/eqUEqjmOmgw9R3x1sii3zMHWLFnW/aXEeoCsq1G0GM EOjA== 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=2bXD8ZlB3biQUOg1qqelwM0pxf5+YP3ufVslYwP4MGM=; b=cAI9uvyL3YQ1lujRd46pej/oT8EbnrUAe9KpxLe1UiYUa5rTKsemynmQRh8FT6zxqp j12JLntnxz58+Yz/bMHaqAl+exIrSdya8iyOy56oPrJNkjHv5cqf/HHDFNBtZj9HkNE6 HYpjx6RNj8+SZA4brLBzu04TrdPnhdnz++47uBroLCPLs7aK2L5Df8LzQokhbYWWgSUP 4shFsKtnz6qEnwhWM1Znv53TgcAoGOcdnO0TgLdepn5mlKXIy2aSQZfa1vN3oL9zeKz3 RAI7HO1iy71fqjCBTz5Jnhg9J4J3opnb2qHlcOhosRuWRDlB1kDlysuEjTEoeeEul5Vd K6EA== X-Gm-Message-State: ALoCoQlbxjJh7WKBcJmzCG2QxZiqXvZwTtW23iEAlVWKblM/NMbGVmpmrcZ2HF9/lOEhCL0Qopfj X-Received: by 10.50.50.179 with SMTP id d19mr4525724igo.91.1449070950153; Wed, 02 Dec 2015 07:42:30 -0800 (PST) Received: from localhost (199-87-125-144.dyn.kc.surewest.net. [199.87.125.144]) by smtp.gmail.com with ESMTPSA id l21sm1359740ioe.21.2015.12.02.07.42.29 (version=TLS1_2 cipher=AES128-SHA bits=128/128); Wed, 02 Dec 2015 07:42:29 -0800 (PST) From: Seth Forshee To: "Eric W. Biederman" , Alexander Viro Subject: [PATCH 13/19] fs: Allow superblock owner to access do_remount_sb() Date: Wed, 2 Dec 2015 09:40:13 -0600 Message-Id: <1449070821-73820-14-git-send-email-seth.forshee@canonical.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1449070821-73820-1-git-send-email-seth.forshee@canonical.com> References: <1449070821-73820-1-git-send-email-seth.forshee@canonical.com> X-TM-AS-MML: disable X-Mailman-Approved-At: Wed, 02 Dec 2015 11:15:49 -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);