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: 613749 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2001:1868:205::9]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3qs0G84dvvz9t5C for ; Sat, 23 Apr 2016 01:41:20 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=canonical-com.20150623.gappssmtp.com header.i=@canonical-com.20150623.gappssmtp.com header.b=ZybwO95f; dkim-atps=neutral Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1atdBv-000429-8S; Fri, 22 Apr 2016 15:40:23 +0000 Received: from mail-oi0-x22c.google.com ([2607:f8b0:4003:c06::22c]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1atdBK-0001pj-BM for linux-mtd@lists.infradead.org; Fri, 22 Apr 2016 15:39:47 +0000 Received: by mail-oi0-x22c.google.com with SMTP id r78so120780015oie.0 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=CGDVf4heFnVtcD3kB0uSi8hQtS3q7IYRZ1SZNmLbPjWfELAysNdC2/YTboSfcQ9x64 Op/jwRDXl78h4ct2z33qkGhG/5X78alDu1Rkv6a3GPR4RNuMRw15vQ25IakRZjJTV3yv dfyGE85uMKG8N47Tj9GyChiRDeYxdnbPMB2YQdXggdfeFdoxzqYXkZbf7ipArX3iNRJ/ wHf/a44vYooTD05NeuXnCnMCRXjUWOzGFbF3UnDgHt7r3IVEG7lrU+c9p7+nrXMufHwc PQgD+0cRLzNGkBi7wh3Cp6WI1GkPO56IYcAh8Pfrz73ND1dbLnEimZGduGeQi4WO4CdC Wn+A== X-Gm-Message-State: AOPr4FWheOkqb0cIXg6KpDcjOkIxzbMAgwK0qVVTAaZ+3QPcOZvpUeNA62YIYJlvqeGzj7ua 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-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160422_083946_616563_7C71838D X-CRM114-Status: GOOD ( 10.40 ) X-Spam-Score: -2.6 (--) X-Spam-Report: SpamAssassin version 3.4.0 on bombadil.infradead.org summary: Content analysis details: (-2.6 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/, low trust [2607:f8b0:4003:c06:0:0:0:22c listed in] [list.dnswl.org] -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature X-BeenThere: linux-mtd@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: Linux MTD discussion mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , 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 Sender: "linux-mtd" Errors-To: linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org 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);