From patchwork Mon Jan 4 18:03:52 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Seth Forshee X-Patchwork-Id: 562615 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 9BC91140324 for ; Tue, 5 Jan 2016 05:11:49 +1100 (AEDT) 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=SjDCw1bU; 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 1aG9aA-00076C-Ry; Mon, 04 Jan 2016 18:10:14 +0000 Received: from mail-ig0-x230.google.com ([2607:f8b0:4001:c05::230]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1aG9V4-0000Yj-HB for linux-mtd@lists.infradead.org; Mon, 04 Jan 2016 18:05:18 +0000 Received: by mail-ig0-x230.google.com with SMTP id ph11so250380431igc.1 for ; Mon, 04 Jan 2016 10:04:40 -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=SjDCw1bU1sdlycv5aKZgGqsiW/PJTkK2QGikZRhg+suUCzhpN5tXpcDFCnVnX6GhTI fV3ea9/1GGL043c8UKh+ZZJvjwLipDkXjduVILgLt/51EazbdNI/VQp8QOtQZ5hemi2C 1hF4ZX5l4POt15S1LN/dBSc394xt8K9cZB4NZWnrKndSja07/LNHSSiLJruVfD1JCGnC 1b26kfaUkGQMgi6xMZrTMFn1zuWDVOg9DnWkiw1TUhqPcmw/Phq7Zhr7KzdJ8UrNNBsZ SAnnlYcY5Yu59jNRf9lCGWGjneZ+XVoCoZl3m5+WyeQB4c4w6uGznsdkhp4jPmkV0ut6 nFSA== 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=mvL4mz75hqx6T/YFxX0zYT8JJYOUlEH+aTMsOpXlKhEHw+MMeDgp9YaoKQzpMMXtJx Ub9Qpd89+RRhaCUn9zpdN3BlQKp3Wxlqh6+I5kO69/hnaAO8OSfPKBZQL4jDLJ5TJ/Sm CD0i00DHvgb3uQA/5tvvcr/oxr/wGQkngV95bSpJd07jFvIbDlAkfs29HAO+4iAz4cd0 B9/NNsBQ1IATrrj5P/yG5+WI/uUyvDjgjMsP4lukb5cYJS266rq5QxOIEtUsHZUAbfkG tJMwX6dSR7Y5V5dfplJ1UGLcWZQwUxQwcbbEK+27zck3MCi2+Gk59R9lcM9PLGtflFNN 4nDQ== X-Gm-Message-State: ALoCoQltiiEDZLQrU3hTBqJGZurbFC7ZmtQ79/upuvHicN/JzYaQa/96C4ndxOSLT2DGZHfKesC+jQf8aleEhanb2PBKYg8UXg== X-Received: by 10.50.79.234 with SMTP id m10mr30692716igx.23.1451930679979; Mon, 04 Jan 2016 10:04:39 -0800 (PST) Received: from localhost ([66.64.121.229]) by smtp.gmail.com with ESMTPSA id kc8sm16124479igb.4.2016.01.04.10.04.39 (version=TLS1_2 cipher=AES128-SHA bits=128/128); Mon, 04 Jan 2016 10:04:39 -0800 (PST) From: Seth Forshee To: "Eric W. Biederman" , Alexander Viro Subject: [PATCH RESEND v2 13/18] fs: Allow superblock owner to access do_remount_sb() Date: Mon, 4 Jan 2016 12:03:52 -0600 Message-Id: <1451930639-94331-14-git-send-email-seth.forshee@canonical.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1451930639-94331-1-git-send-email-seth.forshee@canonical.com> References: <1451930639-94331-1-git-send-email-seth.forshee@canonical.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160104_100459_335222_FFF3C601 X-CRM114-Status: GOOD ( 10.64 ) 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:4001:c05:0:0:0:230 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: 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 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 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);