From patchwork Wed May 4 14:26:53 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Djalal Harouni X-Patchwork-Id: 9014671 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 276479F39D for ; Wed, 4 May 2016 14:31:06 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 3A405203A1 for ; Wed, 4 May 2016 14:31:04 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 45B56203A5 for ; Wed, 4 May 2016 14:31:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753196AbcEDOaA (ORCPT ); Wed, 4 May 2016 10:30:00 -0400 Received: from mail-wm0-f53.google.com ([74.125.82.53]:35170 "EHLO mail-wm0-f53.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751246AbcEDO35 (ORCPT ); Wed, 4 May 2016 10:29:57 -0400 Received: by mail-wm0-f53.google.com with SMTP id e201so190637020wme.0; Wed, 04 May 2016 07:29:51 -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=C8tBdp7pVuAgfu2UhRNV/GrTwOhD+dpT1lVjX3+jqrg=; b=Vw2oxoApMQPsZZR00d5RCnXyb+ytYVVEvQ1HimXUQtyRxeHWj6pvkdsZWdQeoVV9Sm AWOivIN2MlTuja+GZn8ly/aCNGZ9eBlzDNYtbGO5BuYBfNAtBu4QsxBRLanv5YZhzW61 uyUiDcbwg1pUKcQQ/crkkKNjOIQdHz+VsM/A+YXO5GIOqfc2xz8FWQYoBJLZwNW5XY6U 6Mr2Ep8A+moBE5ymoxrY2rmmDn9L8YUx2Z7oot3uc5wz8pqlN2uwc0lfKN/JzUWmzFpu OKP87sGs+4y3sBAGfj9k8S8Dj84g/7m5p6BHiajiPCfczi2L1O0qG+fdSb5j6tl+zgYJ /Mpg== 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=C8tBdp7pVuAgfu2UhRNV/GrTwOhD+dpT1lVjX3+jqrg=; b=NQ951IClt1iO/7hMWlwGwo8PtJAufHyzf9zHKf66I9SmqErYNTjFJwYSv3LWlhv1sf 7UXZHDS+0O9fPeqtVKbztVTrX1Jgfx6gC0q3dwzC2IEBt7PSR3g0fU6AlPltYapc0oHS r4B85cD5M5OmGY/vS/qxnGz9XziJjuuG+kNdzNjXEmOqnsI6WgNvRn7TMjYGHMGonILz Xa9syYYkoOGfFwEgqFUrcINbQuLvl2pBxpbRA4FEBiDBqGZVELTGiia5fibEXDeDMWUn CIFo0BhXwnD7PPPInKVlWutcJsTivXWUiTB32tg+/qHs7NH4aonKGCNjfc/zOYQDkRkR tY8g== X-Gm-Message-State: AOPr4FXiYX/Z0k1RzLalXwg1mTT4/u2LL8gNhqGR8sLT6UJ3Mz/XFvqjE0n2XwpAhVwryQ== X-Received: by 10.28.39.196 with SMTP id n187mr9368192wmn.4.1462372191110; Wed, 04 May 2016 07:29:51 -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.49 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 04 May 2016 07:29:50 -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 7/8] ext4: add support for vfs_shift_uids and vfs_shift_gids mount options Date: Wed, 4 May 2016 16:26:53 +0200 Message-Id: <1462372014-3786-8-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 ext4 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/ext4/super.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/fs/ext4/super.c b/fs/ext4/super.c index 304c712..c9a20c0 100644 --- a/fs/ext4/super.c +++ b/fs/ext4/super.c @@ -1194,6 +1194,7 @@ enum { Opt_dioread_nolock, Opt_dioread_lock, Opt_discard, Opt_nodiscard, Opt_init_itable, Opt_noinit_itable, Opt_max_dir_size_kb, Opt_nojournal_checksum, + Opt_vfs_shift_uids, Opt_vfs_shift_gids, }; static const match_table_t tokens = { @@ -1279,6 +1280,8 @@ static const match_table_t tokens = { {Opt_removed, "reservation"}, /* mount option from ext2/3 */ {Opt_removed, "noreservation"}, /* mount option from ext2/3 */ {Opt_removed, "journal=%u"}, /* mount option from ext2/3 */ + {Opt_vfs_shift_uids, "vfs_shift_uids"}, + {Opt_vfs_shift_gids, "vfs_shift_gids"}, {Opt_err, NULL}, }; @@ -1521,8 +1524,15 @@ static int handle_mount_opt(struct super_block *sb, char *opt, int token, case Opt_nolazytime: sb->s_flags &= ~MS_LAZYTIME; return 1; + case Opt_vfs_shift_uids: + sb->s_iflags |= SB_I_VFS_SHIFT_UIDS; + return 1; + case Opt_vfs_shift_gids: + sb->s_iflags |= SB_I_VFS_SHIFT_GIDS; + return 1; } + for (m = ext4_mount_opts; m->token != Opt_err; m++) if (token == m->token) break; @@ -1920,6 +1930,10 @@ static int _ext4_show_options(struct seq_file *seq, struct super_block *sb, SEQ_OPTS_PRINT("max_dir_size_kb=%u", sbi->s_max_dir_size_kb); if (test_opt(sb, DATA_ERR_ABORT)) SEQ_OPTS_PUTS("data_err=abort"); + if (sb->s_iflags & SB_I_VFS_SHIFT_UIDS) + SEQ_OPTS_PUTS("vfs_shift_uids"); + if (sb->s_iflags & SB_I_VFS_SHIFT_GIDS) + SEQ_OPTS_PUTS("vfs_shift_gids"); ext4_show_quota_options(seq, sb); return 0;