From patchwork Mon Jul 19 11:10:47 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Brauner X-Patchwork-Id: 12385565 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-20.5 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 48115C07E9B for ; Mon, 19 Jul 2021 11:11:42 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 2D78A6115B for ; Mon, 19 Jul 2021 11:11:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236576AbhGSKbA (ORCPT ); Mon, 19 Jul 2021 06:31:00 -0400 Received: from mail.kernel.org ([198.145.29.99]:59724 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236654AbhGSKa7 (ORCPT ); Mon, 19 Jul 2021 06:30:59 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 5AD7E610FB; Mon, 19 Jul 2021 11:11:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1626693099; bh=CIhc9aZbuMCh85zSIZOctJcasDvhpNAFVIEeIzjvFM4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=c2QjkonLbxBHNBePVoAulYaxswlqHW7rpg2x6TzAYb9yJKpkXM1m2jYvg4QemPuxb MQjU+7rZu/G9PfE4v2+ptyNAcNgLA8BKqC7mwIv8TNDdOzrHHk9LehYUwMfbyaV4Pl d899j4l0U1uAGo/ukh++7d9euMSNZF/70xmE7lQiih5q9YoNUFzYleUFw4dmCPmI93 PR6arEl237r2+e9p3FOe4h0FRLNN6Vrt4MxbnAmTfkaeJzWAewiFWnwqTGdyfQVuQ0 mwjJf9YuvNGIYDs8CTJZ3lUE9rz45mrhBPcyY18XxsEN6R78u/GtwYDtnCegJvDgKk LS0T8KnbHMo+A== From: Christian Brauner To: Christoph Hellwig , Chris Mason , Josef Bacik , David Sterba , Al Viro Cc: linux-btrfs@vger.kernel.org, Christian Brauner , Christoph Hellwig Subject: [PATCH v2 16/21] btrfs/ioctl: allow idmapped BTRFS_IOC_SET_RECEIVED_SUBVOL{_32} ioctl Date: Mon, 19 Jul 2021 13:10:47 +0200 Message-Id: <20210719111052.1626299-17-brauner@kernel.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210719111052.1626299-1-brauner@kernel.org> References: <20210719111052.1626299-1-brauner@kernel.org> MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=2127; h=from:subject; bh=UOz8ZUGGvks1eZvm8DVLFZP4fMG0s8EHx74ivt0aUpo=; b=owGbwMvMwCU28Zj0gdSKO4sYT6slMSR8jd1+aTtPj/u71739pz7ca8w32sngtWyGxr7ZiZGZoQ3L W6X2dJSyMIhxMciKKbI4tJuEyy3nqdhslKkBM4eVCWQIAxenANzkM4wME26qlpW/f/li/Xdze74tyR Wpc3bbde+tiU3jiI+ec+/CRkaGzYcOJa8Pk3+y7+/z++u7vp9xeSbl3ZSbUu67TdO1WGYDEwA= X-Developer-Key: i=christian.brauner@ubuntu.com; a=openpgp; fpr=4880B8C9BD0E5106FC070F4F7B3C391EFEA93624 Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org From: Christian Brauner The BTRFS_IOC_SET_RECEIVED_SUBVOL{_32} are used to set information about a received subvolume. Make it possible to set information about a received subvolume on idmapped mounts. This is a fairly straightforward operation since all the permission checking helpers are already capable of handling idmapped mounts. So we just need to pass down the mount's userns. Cc: Chris Mason Cc: Josef Bacik Cc: Christoph Hellwig Cc: David Sterba Cc: linux-btrfs@vger.kernel.org Signed-off-by: Christian Brauner --- /* v2 */ unchanged --- fs/btrfs/ioctl.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c index 72045ae30d1c..d631a1cb621d 100644 --- a/fs/btrfs/ioctl.c +++ b/fs/btrfs/ioctl.c @@ -4466,6 +4466,7 @@ static long btrfs_ioctl_quota_rescan_wait(struct btrfs_fs_info *fs_info, } static long _btrfs_ioctl_set_received_subvol(struct file *file, + struct user_namespace *mnt_userns, struct btrfs_ioctl_received_subvol_args *sa) { struct inode *inode = file_inode(file); @@ -4477,7 +4478,7 @@ static long _btrfs_ioctl_set_received_subvol(struct file *file, int ret = 0; int received_uuid_changed; - if (!inode_owner_or_capable(&init_user_ns, inode)) + if (!inode_owner_or_capable(mnt_userns, inode)) return -EPERM; ret = mnt_want_write_file(file); @@ -4582,7 +4583,7 @@ static long btrfs_ioctl_set_received_subvol_32(struct file *file, args64->rtime.nsec = args32->rtime.nsec; args64->flags = args32->flags; - ret = _btrfs_ioctl_set_received_subvol(file, args64); + ret = _btrfs_ioctl_set_received_subvol(file, file_mnt_user_ns(file), args64); if (ret) goto out; @@ -4616,7 +4617,7 @@ static long btrfs_ioctl_set_received_subvol(struct file *file, if (IS_ERR(sa)) return PTR_ERR(sa); - ret = _btrfs_ioctl_set_received_subvol(file, sa); + ret = _btrfs_ioctl_set_received_subvol(file, file_mnt_user_ns(file), sa); if (ret) goto out;