From patchwork Fri Apr 22 15:38:33 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Seth Forshee X-Patchwork-Id: 8913591 Return-Path: X-Original-To: patchwork-selinux@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 4EE7A9F39A for ; Fri, 22 Apr 2016 15:54:23 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 9E8A420121 for ; Fri, 22 Apr 2016 15:54:22 +0000 (UTC) Received: from emvm-gh1-uea09.nsa.gov (emvm-gh1-uea09.nsa.gov [8.44.101.9]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 57AF420131 for ; Fri, 22 Apr 2016 15:54:21 +0000 (UTC) X-TM-IMSS-Message-ID: Received: from tarius.tycho.ncsc.mil ([144.51.242.1]) by nsa.gov ([10.208.42.194]) with ESMTP (TREND IMSS SMTP Service 7.1) id ad9fa3cd00000a2e ; Fri, 22 Apr 2016 11:51:01 -0400 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 u3MFpRtb008785; Fri, 22 Apr 2016 11:51:27 -0400 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 u3MFdmkX105318 for ; Fri, 22 Apr 2016 11:39:48 -0400 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 u3MFdlDY004476 for ; Fri, 22 Apr 2016 11:39:48 -0400 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: A0CqBABlRRpX/yQp0ApeHYJwgXu3d4QQhg4CgXQBAQEBAQFmJ4RCAQEBAxIVGQEBNwEPUTQBBQEcBgESIogIAaBwgTE+MYpPhSgBBIxcAQEBAQEBBAIBFwYKhA2CCo5gAY5LiUiBVYxBgWSHRTGFNEWNLDCBDmKBeIIRTgGIegEBAQ X-IPAS-Result: A0CqBABlRRpX/yQp0ApeHYJwgXu3d4QQhg4CgXQBAQEBAQFmJ4RCAQEBAxIVGQEBNwEPUTQBBQEcBgESIogIAaBwgTE+MYpPhSgBBIxcAQEBAQEBBAIBFwYKhA2CCo5gAY5LiUiBVYxBgWSHRTGFNEWNLDCBDmKBeIIRTgGIegEBAQ X-IronPort-AV: E=Sophos;i="5.24,517,1454994000"; d="scan'208";a="5402627" Received: from emsm-gh1-uea10.corp.nsa.gov (HELO emsm-gh1-uea10.nsa.gov) ([10.208.41.36]) by goalie.tycho.ncsc.mil with ESMTP; 22 Apr 2016 11:39:26 -0400 IronPort-PHdr: =?us-ascii?q?9a23=3A2G62KhC0oWPEcHMAzuSzUyQJP3N1i/DPJgcQr6Af?= =?us-ascii?q?oPdwSP/4pcbcNUDSrc9gkEXOFd2CrakU26yJ6+uwBSQp2tWojjMrSNR0TRgLiM?= =?us-ascii?q?EbzUQLIfWuLgnFFsPsdDEwB89YVVVorDmROElRH9viNRWJ+iXhpQAbFhi3Dwdp?= =?us-ascii?q?POO9QteU1JTnkb/qsM2PKyxzxxODIppKZC2sqgvQssREyaBDEY0WjiXzn31TZu?= =?us-ascii?q?5NznlpL1/A1zz158O34YIxu38I46Fp34d6XK77Z6U1S6BDRHRjajhtpZ6jiR6W?= =?us-ascii?q?ByaV53BUbSNeuBtFDwXf6Rj8FN+lvyH7u+ZwwiyyLcj3Vqs1XjLk5KBuHlugoS?= =?us-ascii?q?MKJzc//GzNwvJxlqUT9AygvRtX0YPSYZ/TMPt4Y7ObeskVA3dCCJV/TStEV7ix?= =?us-ascii?q?c4tHIe0bJuZVosGpvFYSrV2wAhO3BO7i4jRBgHjw3KYz16IqFgSQj19oJM4HrH?= =?us-ascii?q?mB9Ia9D6wVS+3gifCQlTg=3D?= X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: =?us-ascii?q?A1EmAQCfQhpXiDDaVdFeHYJwgXu3d4QQg?= =?us-ascii?q?g2EAQKBdAEBAQEBAQICDwEBAQgLCwkfgl59Wz0BAQEDEhUZAQE3AQ9RNAEFARw?= =?us-ascii?q?GARIiiAgBoGyBMT4xik+FKAEEjF0BAQEBAQEEAgEXBgqEDYIKjmCOTIlIgVWMQ?= =?us-ascii?q?YFkh0UxhTRFjSwwgQ6CWh6Bc04BiHoBAQE?= X-IPAS-Result: =?us-ascii?q?A1EmAQCfQhpXiDDaVdFeHYJwgXu3d4QQgg2EAQKBdAEBAQE?= =?us-ascii?q?BAQICDwEBAQgLCwkfgl59Wz0BAQEDEhUZAQE3AQ9RNAEFARwGARIiiAgBoGyBM?= =?us-ascii?q?T4xik+FKAEEjF0BAQEBAQEEAgEXBgqEDYIKjmCOTIlIgVWMQYFkh0UxhTRFjSw?= =?us-ascii?q?wgQ6CWh6Bc04BiHoBAQE?= X-IronPort-AV: E=Sophos;i="5.24,517,1454976000"; d="scan'208";a="12934457" Received: from emvm-gh1-uea09.nsa.gov ([10.208.42.194]) by emsm-gh1-uea10.nsa.gov with ESMTP/TLS/DHE-RSA-AES256-SHA; 22 Apr 2016 15:39:26 +0000 X-TM-IMSS-Message-ID: Received: from mail-oi0-f48.google.com (mail-oi0-f48.google.com [209.85.218.48]) by nsa.gov ([10.208.42.194]) with ESMTP (TREND IMSS SMTP Service 7.1; TLSv1/SSLv3 AES128-SHA (128/128)) id ad949ece00000642 ; Fri, 22 Apr 2016 11:38:59 -0400 Received: by mail-oi0-f48.google.com with SMTP id k142so120576542oib.1 for ; Fri, 22 Apr 2016 08:39:25 -0700 (PDT) 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=5DGHTdoXKj3X6hInWtS+3kgIbolZRXsfjfwU9afMSxk=; b=ZybwO95fY52QN5iJcp7kV0g5TD5NcfxQLmUIJQ1ELiWaoHKJOVaTrz1NMvufNxMSCh RNrj5KTAMPLWGTWOpL7TPZb99qW5x03HOkzGgbDn/BPkH10w0Ci6bFxtmRhkr3nvFBg0 4PPSwR+xxajc+exQc9LFYw7gzY8ntJ7cH11lJundeloqhB7Qh5qOjXLGCtwCFadK1Flm j7VnM7t65W3LvPlyzKSLikpxaRwfy946NARx8/Kai+8YqfmAdlSf7bpHsEGvHszK1yPl /j6peA+fO0yzsys61aryu8omQ6fEqLnZ0mbvL5KWNkTMb6z0RX+ggV2MOmj+sR2+cngR jGvQ== 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=5DGHTdoXKj3X6hInWtS+3kgIbolZRXsfjfwU9afMSxk=; b=m5sgfZsGBQSiV+HZScPJxzzIvT90U4Xk4z34RaZcchZ3rHd+BmoILMA7ZsmMLmVNSF ldkmCNM97KKRr8lntvcorX8MBK10zdBjcvZ11QvP8vq2+3t10clGAeFySDH0roS1ywBI GmShpAvOjKxLV1UZWMOdLbFX+019JI9IsXUD4HO8S10EaGwpqSC4pLRRRHPMH6dG2tFb 6034JrCJd121NVaem3FcSfWx7Xw1xAFFSN4II4KkAMJ9FAF2WnfdUjajLgNp7bylpYyZ 15XU12oItxtlcR4dULMtCKqOjt4oANqtI1ei9TXvvVGfx2C9vmvqoGF5TckaOescq+vn DAag== X-Gm-Message-State: AOPr4FUw5rcnw6TU4HnLmFFRx7AVVkhUhbBvkf1IabBnhs0OHHa//wDX+coeKAfPSzW/yNOf X-Received: by 10.157.19.93 with SMTP id q29mr8269483otq.171.1461339565027; Fri, 22 Apr 2016 08:39:25 -0700 (PDT) Received: from localhost ([2605:a601:aab:f920:ad1c:41df:dcb1:a4a0]) by smtp.gmail.com with ESMTPSA id xm14sm2074572oeb.17.2016.04.22.08.39.24 (version=TLS1_2 cipher=AES128-SHA bits=128/128); Fri, 22 Apr 2016 08:39:24 -0700 (PDT) From: Seth Forshee To: "Eric W. Biederman" , Alexander Viro Subject: [PATCH v3 16/21] fs: Allow superblock owner to access do_remount_sb() Date: Fri, 22 Apr 2016 10:38:33 -0500 Message-Id: <1461339521-123191-17-git-send-email-seth.forshee@canonical.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1461339521-123191-1-git-send-email-seth.forshee@canonical.com> References: <1461339521-123191-1-git-send-email-seth.forshee@canonical.com> X-TM-AS-MML: disable X-Mailman-Approved-At: Fri, 22 Apr 2016 11:40:27 -0400 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: linux-bcache@vger.kernel.org, Serge Hallyn , Seth Forshee , dm-devel@redhat.com, Miklos Szeredi , Richard Weinberger , linux-security-module@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, cgroups@vger.kernel.org, Pavel Tikhomirov MIME-Version: 1.0 Errors-To: selinux-bounces@tycho.nsa.gov Sender: "Selinux" X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, RP_MATCHES_RCVD, T_DKIM_INVALID, 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 0ad8e4a4f50b..575e3f8b34fd 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)) @@ -2207,7 +2207,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);