From patchwork Wed May 4 14:26:54 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Djalal Harouni X-Patchwork-Id: 9014641 Return-Path: X-Original-To: patchwork-linux-fsdevel@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 3191A9F39D for ; Wed, 4 May 2016 14:30:46 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 52E97203A5 for ; Wed, 4 May 2016 14:30:45 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 3D4AA203A1 for ; Wed, 4 May 2016 14:30:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753286AbcEDOaF (ORCPT ); Wed, 4 May 2016 10:30:05 -0400 Received: from mail-wm0-f49.google.com ([74.125.82.49]:35196 "EHLO mail-wm0-f49.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753059AbcEDO37 (ORCPT ); Wed, 4 May 2016 10:29:59 -0400 Received: by mail-wm0-f49.google.com with SMTP id e201so190638176wme.0; Wed, 04 May 2016 07:29:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=mNq/FksLehOH8ST2uWdCBJvZtwDDuIB53a0t6o4uOZY=; b=Ej02yzb8+6NZoIhnPdrhFUguu+0Yn+pCoetqQRZKjpnVlJtuSw33KcIF4FJtgHoH9X uhig/rbBcCVQ/oByLzh8Ojs9vSw3tgfMWPqW/e1VNbD5p6JXFUzae/PibetQP+4YxMYR AxyaClguj67z8J5v9vK4BIHCd8zE86BESVePNgXZiNklJ65HS/Lnon6JIlgU8NeH2MlM pRws5N3yDyPAYtUibysZPaWPanQZFSsYEXx7XL0T1TabEKTOrzcogvIuSwx2bkh6h7g3 4bJOseArGrEY5ovOCf4/pIbGYgffDyxU4UiI4CgJDGTc7ipj/hAq/awTLzY6CswkaHfk Y4Kg== 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=mNq/FksLehOH8ST2uWdCBJvZtwDDuIB53a0t6o4uOZY=; b=LMjZUsXOZB+0m1MU/MVjG6+HMn+HS15Q4vMA7fwubD78GIaw9ApuAgWLzFYQKVWZoP E5gO2LhxuvNjVmRL1s/fqKiwBZkn7qtq6MF6Gp9YYYal9x8//pBqVPZZj11s4v4gjRTF 33UPgQ3GjBEfP4QS8hTXSMqEeNUbh/WFFUhA+bO5RzecotxrnG1Sy6pKA+BpeJZ14sfD dSDto39WqqDSofYcxb8kdQ6IT+oICAbZ6GmhoVdxjP+1FTUhmoxuwitLQNH5dL1dxbCJ ocrRJ7tM1reXFH8vjDKM6q6fSLprBZp0vILk6kbKDtWOzng4hbj0B4zuTmcdTqgxXlgW 45fw== X-Gm-Message-State: AOPr4FXh8zZCcXcu+22lep3/7QgFXD/CxPPU2TxM/SDUqboN0zzdaXVLlQFWe7ogRvDAYA== X-Received: by 10.194.122.199 with SMTP id lu7mr9551086wjb.40.1462372192847; Wed, 04 May 2016 07:29:52 -0700 (PDT) Received: from dztty2.localdomain (ip5b42f9c9.dynamic.kabel-deutschland.de. [91.66.249.201]) by smtp.gmail.com with ESMTPSA id a75sm4615505wme.18.2016.05.04.07.29.51 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 04 May 2016 07:29:52 -0700 (PDT) From: Djalal Harouni To: Alexander Viro , Chris Mason , , Serge Hallyn , Josh Triplett , "Eric W. Biederman" , Andy Lutomirski , Seth Forshee , linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, linux-security-module@vger.kernel.org, Dongsu Park , David Herrmann , Miklos Szeredi , Alban Crequy Cc: Djalal Harouni , Djalal Harouni Subject: [RFC v2 PATCH 8/8] btrfs: add support for vfs_shift_uids and vfs_shift_gids mount options Date: Wed, 4 May 2016 16:26:54 +0200 Message-Id: <1462372014-3786-9-git-send-email-tixxdz@gmail.com> X-Mailer: git-send-email 2.5.5 In-Reply-To: <1462372014-3786-1-git-send-email-tixxdz@gmail.com> References: <1462372014-3786-1-git-send-email-tixxdz@gmail.com> Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org X-Spam-Status: No, score=-8.9 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=unavailable 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 Make btrfs able to parse vfs_shift_uids and vfs_shift_gids options and set the appropriate flags into the super_block structure. vfs_shift_uids and vfs_shift_gids allow mounts that show up in a mount namespace that supports VFS UID/GID shifts on inodes to perform translation from in kernel virtual view into on-disk view and vice versa. This allows user namespaces users to be able to access, read and write inodes on these mounts. Signed-off-by: Dongsu Park Signed-off-by: Djalal Harouni --- fs/btrfs/super.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c index 00b8f37..20e7223 100644 --- a/fs/btrfs/super.c +++ b/fs/btrfs/super.c @@ -304,7 +304,8 @@ enum { Opt_commit_interval, Opt_barrier, Opt_nodefrag, Opt_nodiscard, Opt_noenospc_debug, Opt_noflushoncommit, Opt_acl, Opt_datacow, Opt_datasum, Opt_treelog, Opt_noinode_cache, Opt_usebackuproot, - Opt_nologreplay, Opt_norecovery, + Opt_nologreplay, Opt_norecovery, Opt_vfs_shift_uids, + Opt_vfs_shift_gids, #ifdef CONFIG_BTRFS_DEBUG Opt_fragment_data, Opt_fragment_metadata, Opt_fragment_all, #endif @@ -364,6 +365,8 @@ static const match_table_t tokens = { {Opt_rescan_uuid_tree, "rescan_uuid_tree"}, {Opt_fatal_errors, "fatal_errors=%s"}, {Opt_commit_interval, "commit=%d"}, + {Opt_vfs_shift_uids, "vfs_shift_uids"}, + {Opt_vfs_shift_gids, "vfs_shift_gids"}, #ifdef CONFIG_BTRFS_DEBUG {Opt_fragment_data, "fragment=data"}, {Opt_fragment_metadata, "fragment=metadata"}, @@ -786,6 +789,12 @@ int btrfs_parse_options(struct btrfs_root *root, char *options, info->commit_interval = BTRFS_DEFAULT_COMMIT_INTERVAL; } break; + case Opt_vfs_shift_uids: + root->fs_info->sb->s_iflags |= SB_I_VFS_SHIFT_UIDS; + break; + case Opt_vfs_shift_gids: + root->fs_info->sb->s_iflags |= SB_I_VFS_SHIFT_GIDS; + break; #ifdef CONFIG_BTRFS_DEBUG case Opt_fragment_all: btrfs_info(root->fs_info, "fragmenting all space"); @@ -1279,6 +1288,10 @@ static int btrfs_show_options(struct seq_file *seq, struct dentry *dentry) if (btrfs_test_opt(root, FRAGMENT_METADATA)) seq_puts(seq, ",fragment=metadata"); #endif + if (root->fs_info->sb->s_iflags & SB_I_VFS_SHIFT_UIDS) + seq_puts(seq, ",vfs_shift_uids"); + if (root->fs_info->sb->s_iflags & SB_I_VFS_SHIFT_GIDS) + seq_puts(seq, ",vfs_shift_gids"); seq_printf(seq, ",subvolid=%llu", BTRFS_I(d_inode(dentry))->root->root_key.objectid); seq_puts(seq, ",subvol=");