From patchwork Tue Apr 26 19:36:29 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Seth Forshee X-Patchwork-Id: 8944631 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 0CBCA9F1D3 for ; Tue, 26 Apr 2016 20:13:52 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 8630F201EF for ; Tue, 26 Apr 2016 20:13:50 +0000 (UTC) Received: from emsm-gh1-uea11.nsa.gov (smtp.nsa.gov [8.44.101.9]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 9D44D20138 for ; Tue, 26 Apr 2016 20:13:49 +0000 (UTC) X-IronPort-AV: E=Sophos;i="5.24,538,1454976000"; d="scan'208";a="15644174" IronPort-PHdr: =?us-ascii?q?9a23=3Al+Dhmh+LrGBrz/9uRHKM819IXTAuvvDOBiVQ1KB8?= =?us-ascii?q?0O4cTK2v8tzYMVDF4r011RmSDdWdtKMP0rGI+4nbGkU+or+5+EgYd5JNUxJXwe?= =?us-ascii?q?43pCcHRPC/NEvgMfTxZDY7FskRHHVs/nW8LFQHUJ2mPw6anHS+4HYoFwnlMkIt?= =?us-ascii?q?f6KuSt6U0JX8jrvss7ToICx2xxOFKYtoKxu3qQiD/uI3uqBFbpgL9x3Sv3FTcP?= =?us-ascii?q?5Xz247bXianhL7+9vitMU7q3cYk7sb+sVBSaT3ebgjBfwdVWx+cjN92Mq+/zTZ?= =?us-ascii?q?TADH2T1UeGQbnhdSBgHDplmuU53wvyf3rO9VyCybJtb3SrZyUjOnueMjYRvlmC?= =?us-ascii?q?4BOzMjuF/WkMs42LxauhWJtRF5wpCSZICTKeo4ebnSO84ZEzlvRMFUAhdMHoP0?= =?us-ascii?q?QYwVFOoMMK4MtIThpx0AqgGlBQShLOjmzDhOh3T/2esx1OF3QlKO5xApA99b6C?= =?us-ascii?q?ecl97yLqpHFLntlKQ=3D?= X-IPAS-Result: =?us-ascii?q?A2EJBQBiyx9X/wHyM5BeHAGCcCuBULtyJIF2hUVMAQEBAQE?= =?us-ascii?q?BAgJiJ4ItfVs9AQEBAwECDxUTBgEBDCALAQIDCQEBFykICAMBLQMBBQELEQYBB?= =?us-ascii?q?wsFGAQBiAgBpVGBMT4xik+FKAEEjEcBAQgBAQEBFgYKhA2CCohaEQGFdAGOTIl?= =?us-ascii?q?IgVWMRIFlh0UlDIU0RY0tMIEOYoQJTgGHeIE1AQEB?= Received: from unknown (HELO tarius.tycho.ncsc.mil) ([144.51.242.1]) by emsm-gh1-uea11.nsa.gov with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 26 Apr 2016 20:13:22 +0000 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 u3QKDMv3022272; Tue, 26 Apr 2016 16:13:22 -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 u3QJbDGf172327 for ; Tue, 26 Apr 2016 15:37:13 -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 u3QJak05011587 for ; Tue, 26 Apr 2016 15:37:12 -0400 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: A0A+BQD9wR9X/yQp0ApeHYJwK4FQt3CEEYYPAoFATAEBAQEBAWYnhEIBAQEDEhUZAQE3AQ9RNAEFARwGARIiiAgBpVeBMT4xik+FKAEEjEoBAQEBAQEEAgEXBgqEDYIKjmCOTYlIgVWMRIFlh0UxhTRFjS0wgQ5igXiCEU4BiS0BAQE X-IPAS-Result: A0A+BQD9wR9X/yQp0ApeHYJwK4FQt3CEEYYPAoFATAEBAQEBAWYnhEIBAQEDEhUZAQE3AQ9RNAEFARwGARIiiAgBpVeBMT4xik+FKAEEjEoBAQEBAQEEAgEXBgqEDYIKjmCOTYlIgVWMRIFlh0UxhTRFjS0wgQ5igXiCEU4BiS0BAQE X-IronPort-AV: E=Sophos;i="5.24,537,1454994000"; d="scan'208";a="5410391" 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; 26 Apr 2016 15:37:13 -0400 IronPort-PHdr: =?us-ascii?q?9a23=3AhQWXsB+KPKfZ7f9uRHKM819IXTAuvvDOBiVQ1KB8?= =?us-ascii?q?0O4cTK2v8tzYMVDF4r011RmSDdWdtKMP0rGO+4nbGkU+or+5+EgYd5JNUxJXwe?= =?us-ascii?q?43pCcHRPC/NEvgMfTxZDY7FskRHHVs/nW8LFQHUJ2mPw6anHS+4HYoFwnlMkIt?= =?us-ascii?q?f6KuSt6U0JX8jrvqs7ToICx2xxOFKYtoKxu3qQiD/uI3uqBFbpgL9x3Sv3FTcP?= =?us-ascii?q?5Xz247bXianhL7+9vitMU7q3cYk7sb+sVBSaT3ebgjBfwdVWx+cjN92Mq+/zTZ?= =?us-ascii?q?TADH2T1UeGQbnhdSBgHDplmuU53wvyf3rO9VyCybJtb3SrZyUjOnueMjYRvlmC?= =?us-ascii?q?4BOzMjuF/WkMs42LxauhWJtRF5wpCSZICTKeo4ebnSO84ZEzlvRMFUAhdMHoP0?= =?us-ascii?q?QYwVFOoMMK4MtIThpx0AqgGlBQShLOjmzDhOh3T/2esx1OF3QlKO5xApA99b6C?= =?us-ascii?q?ecl97yLqpHFLntlKQ=3D?= X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: =?us-ascii?q?A0HzAAC5wh9XkK3fVdFegw2Be7dwhBGCD?= =?us-ascii?q?YQCAoFATAEBAQEBAQICDwEBAQEHDQkJIS+CLX1bPQEBAQMSFRkBATcBD1E0AQU?= =?us-ascii?q?BHAYBEiKICAGlV4ExPjGKT4UoAQSMSgEBAQEBAQQCARcGCoQNggqOYI5NiUiBV?= =?us-ascii?q?YxEgWWHRTGFNEWNLTCBDoJaHoFzTgGJLQEBAQ?= X-IPAS-Result: =?us-ascii?q?A0HzAAC5wh9XkK3fVdFegw2Be7dwhBGCDYQCAoFATAEBAQE?= =?us-ascii?q?BAQICDwEBAQEHDQkJIS+CLX1bPQEBAQMSFRkBATcBD1E0AQUBHAYBEiKICAGlV?= =?us-ascii?q?4ExPjGKT4UoAQSMSgEBAQEBAQQCARcGCoQNggqOYI5NiUiBVYxEgWWHRTGFNEW?= =?us-ascii?q?NLTCBDoJaHoFzTgGJLQEBAQ?= X-IronPort-AV: E=Sophos;i="5.24,537,1454976000"; d="scan'208";a="13051022" Received: from mail-io0-f173.google.com ([209.85.223.173]) by emsm-gh1-uea10.nsa.gov with ESMTP/TLS/AES128-GCM-SHA256; 26 Apr 2016 19:37:11 +0000 Received: by mail-io0-f173.google.com with SMTP id 190so20534046iow.1 for ; Tue, 26 Apr 2016 12:37:11 -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=IPLc+Iy3kJDxOUff1MUyTZBlc5hmrMRMoXrk1foDoBo=; b=s7cw3NE5fFCj9CbfviCEyRAfhW68MgQteaD5mgVh7aFq1qVqlrjmWpq/6dS1kNfvAj 14ngFkdO/4YDve+FgUoBeXYb4IBajSoE76x1VS/3pLnWVckt5yo+dTFJrZa+6/utHFxD vtV2r99V7C3hUA4ggcROAzzOuylbul0SOJ2+6fBgOFdN1Js9jJiHMF/0RF6zaeD3SD8E 5pVBrFDpr8ucKP5DLk0bjZHmTfVWeYEdcWadmDPE5yzmD/xIsDIyKExwd6YTMxRJuFB7 fTejlCH8bHq31ZTMQ28vlWuH8yW2nkQZN5YcZy7pMCRmsD69K2uZuhIrv2kNDw9hdFZl ndig== 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=IPLc+Iy3kJDxOUff1MUyTZBlc5hmrMRMoXrk1foDoBo=; b=fWJnmf6BsVuRBn9QqD11BNa/aCarex5NKGVKN9yQP3waMb/jHuqGYmwXwCB0+3joGZ VkCTtJDLr6/JQflBO++fOYPlt4Y+9QAMjCFZ2VDbiaJeenRw6xE+WVDW8VljnB0FQ5h0 fEaQdUkD+U/VC/BfFe+xr/bIgUONWZ643V+fvGD6JLwHk1zROAaYASDs6SkL0J3fyS0w uxVmMu/rMBrrQlWHAI/wZQ0eZwTQxDCm3u3RFq+ZmHw8tlDj0GkleUfT6twZvorp/CQK MAgQjpG6fXMiGCeIQorW+IG5vooOh9fI/xtHFT7cv9y4h4hKYCOWcWKKjidzYpz1BArX w97g== X-Gm-Message-State: AOPr4FU/cpbaqF6J5WYC4OnIfG1PsSp/u/RjtvXU71QvVBInOjG6QU4KcQKZV4aHu+kw53Uy X-Received: by 10.107.130.160 with SMTP id m32mr6171853ioi.137.1461699431217; Tue, 26 Apr 2016 12:37:11 -0700 (PDT) Received: from localhost ([2605:a601:aab:f920:39a1:5bcf:aa:5b00]) by smtp.gmail.com with ESMTPSA id o127sm2396310iof.0.2016.04.26.12.37.10 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 26 Apr 2016 12:37:10 -0700 (PDT) From: Seth Forshee To: "Eric W. Biederman" , Alexander Viro Subject: [PATCH v4 16/21] fs: Allow superblock owner to access do_remount_sb() Date: Tue, 26 Apr 2016 14:36:29 -0500 Message-Id: <1461699396-33000-17-git-send-email-seth.forshee@canonical.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1461699396-33000-1-git-send-email-seth.forshee@canonical.com> References: <1461699396-33000-1-git-send-email-seth.forshee@canonical.com> X-Mailman-Approved-At: Tue, 26 Apr 2016 16:11:02 -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);