mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Eric W. Biederman" <ebiederm@xmission.com>
To: <linux-fsdevel@vger.kernel.org>
Cc: <linux-kernel@vger.kernel.org>, Serge Hallyn <serge@hallyn.com>,
	Linux Containers <containers@lists.linux-foundation.org>,
	"Eric W. Biederman" <ebiederm@xmission.com>
Subject: [PATCH 07/25] userns: Convert adfs to use kuid and kgid where appropriate
Date: Thu, 20 Sep 2012 04:41:48 -0700	[thread overview]
Message-ID: <1348141326-23355-7-git-send-email-ebiederm@xmission.com> (raw)
In-Reply-To: <1348141326-23355-1-git-send-email-ebiederm@xmission.com>

From: "Eric W. Biederman" <ebiederm@xmission.com>

Acked-by: Serge Hallyn <serge.hallyn@canonical.com>
Signed-off-by: Eric W. Biederman <ebiederm@xmission.com>
---
 fs/adfs/adfs.h  |    4 ++--
 fs/adfs/inode.c |    4 ++--
 fs/adfs/super.c |   21 +++++++++++++--------
 init/Kconfig    |    1 -
 4 files changed, 17 insertions(+), 13 deletions(-)

diff --git a/fs/adfs/adfs.h b/fs/adfs/adfs.h
index 718ac1f..585adaf 100644
--- a/fs/adfs/adfs.h
+++ b/fs/adfs/adfs.h
@@ -46,8 +46,8 @@ struct adfs_sb_info {
 	struct adfs_discmap *s_map;	/* bh list containing map		 */
 	struct adfs_dir_ops *s_dir;	/* directory operations			 */
 
-	uid_t		s_uid;		/* owner uid				 */
-	gid_t		s_gid;		/* owner gid				 */
+	kuid_t		s_uid;		/* owner uid				 */
+	kgid_t		s_gid;		/* owner gid				 */
 	umode_t		s_owner_mask;	/* ADFS owner perm -> unix perm		 */
 	umode_t		s_other_mask;	/* ADFS other perm -> unix perm		 */
 	int		s_ftsuffix;	/* ,xyz hex filetype suffix option */
diff --git a/fs/adfs/inode.c b/fs/adfs/inode.c
index 1dab6a1..e9bad50 100644
--- a/fs/adfs/inode.c
+++ b/fs/adfs/inode.c
@@ -304,8 +304,8 @@ adfs_notify_change(struct dentry *dentry, struct iattr *attr)
 	 * we can't change the UID or GID of any file -
 	 * we have a global UID/GID in the superblock
 	 */
-	if ((ia_valid & ATTR_UID && attr->ia_uid != ADFS_SB(sb)->s_uid) ||
-	    (ia_valid & ATTR_GID && attr->ia_gid != ADFS_SB(sb)->s_gid))
+	if ((ia_valid & ATTR_UID && !uid_eq(attr->ia_uid, ADFS_SB(sb)->s_uid)) ||
+	    (ia_valid & ATTR_GID && !gid_eq(attr->ia_gid, ADFS_SB(sb)->s_gid)))
 		error = -EPERM;
 
 	if (error)
diff --git a/fs/adfs/super.c b/fs/adfs/super.c
index bdaec92..22a0d7e 100644
--- a/fs/adfs/super.c
+++ b/fs/adfs/super.c
@@ -15,6 +15,7 @@
 #include <linux/seq_file.h>
 #include <linux/slab.h>
 #include <linux/statfs.h>
+#include <linux/user_namespace.h>
 #include "adfs.h"
 #include "dir_f.h"
 #include "dir_fplus.h"
@@ -130,10 +131,10 @@ static int adfs_show_options(struct seq_file *seq, struct dentry *root)
 {
 	struct adfs_sb_info *asb = ADFS_SB(root->d_sb);
 
-	if (asb->s_uid != 0)
-		seq_printf(seq, ",uid=%u", asb->s_uid);
-	if (asb->s_gid != 0)
-		seq_printf(seq, ",gid=%u", asb->s_gid);
+	if (!uid_eq(asb->s_uid, GLOBAL_ROOT_UID))
+		seq_printf(seq, ",uid=%u", from_kuid_munged(&init_user_ns, asb->s_uid));
+	if (!gid_eq(asb->s_gid, GLOBAL_ROOT_GID))
+		seq_printf(seq, ",gid=%u", from_kgid_munged(&init_user_ns, asb->s_gid));
 	if (asb->s_owner_mask != ADFS_DEFAULT_OWNER_MASK)
 		seq_printf(seq, ",ownmask=%o", asb->s_owner_mask);
 	if (asb->s_other_mask != ADFS_DEFAULT_OTHER_MASK)
@@ -175,12 +176,16 @@ static int parse_options(struct super_block *sb, char *options)
 		case Opt_uid:
 			if (match_int(args, &option))
 				return -EINVAL;
-			asb->s_uid = option;
+			asb->s_uid = make_kuid(current_user_ns(), option);
+			if (!uid_valid(asb->s_uid))
+				return -EINVAL;
 			break;
 		case Opt_gid:
 			if (match_int(args, &option))
 				return -EINVAL;
-			asb->s_gid = option;
+			asb->s_gid = make_kgid(current_user_ns(), option);
+			if (!gid_valid(asb->s_gid))
+				return -EINVAL;
 			break;
 		case Opt_ownmask:
 			if (match_octal(args, &option))
@@ -369,8 +374,8 @@ static int adfs_fill_super(struct super_block *sb, void *data, int silent)
 	sb->s_fs_info = asb;
 
 	/* set default options */
-	asb->s_uid = 0;
-	asb->s_gid = 0;
+	asb->s_uid = GLOBAL_ROOT_UID;
+	asb->s_gid = GLOBAL_ROOT_GID;
 	asb->s_owner_mask = ADFS_DEFAULT_OWNER_MASK;
 	asb->s_other_mask = ADFS_DEFAULT_OTHER_MASK;
 	asb->s_ftsuffix = 0;
diff --git a/init/Kconfig b/init/Kconfig
index 485c60a..20ddf0d 100644
--- a/init/Kconfig
+++ b/init/Kconfig
@@ -933,7 +933,6 @@ config UIDGID_CONVERTED
 
 	# Filesystems
 	depends on 9P_FS = n
-	depends on ADFS_FS = n
 	depends on AFFS_FS = n
 	depends on AFS_FS = n
 	depends on AUTOFS4_FS = n
-- 
1.7.5.4


  parent reply	other threads:[~2012-09-20 11:43 UTC|newest]

Thread overview: 39+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-09-20 11:40 [REVIEW][PATCH 00/25] userns: Trivial filesystem conversions Eric W. Biederman
2012-09-20 11:41 ` [PATCH 01/25] userns: Convert fat to use kuid/kgid where appropriate Eric W. Biederman
2012-09-20 11:41   ` [PATCH 02/25] userns: Convert gadgetfs to use kuid and kgid " Eric W. Biederman
2012-09-20 11:58     ` Greg Kroah-Hartman
2012-09-21  9:33     ` Felipe Balbi
2012-09-20 11:41   ` [PATCH 03/25] userns: Convert usb functionfs to use kuid/kgid " Eric W. Biederman
2012-09-20 11:58     ` Greg Kroah-Hartman
2012-09-21  9:32     ` Felipe Balbi
2012-09-20 11:41   ` [PATCH 04/25] userns: Convert devtmpfs to use GLOBAL_ROOT_UID and GLOBAL_ROOT_GID Eric W. Biederman
2012-09-20 11:58     ` Greg Kroah-Hartman
2012-09-20 11:41   ` [PATCH 05/25] userns: Convert hugetlbfs to use kuid/kgid where appropriate Eric W. Biederman
2012-09-20 11:41   ` [PATCH 06/25] userns: Convert xenfs to use kuid and kgid " Eric W. Biederman
2012-09-20 11:41   ` Eric W. Biederman [this message]
2012-09-20 11:41   ` [PATCH 08/25] userns: Convert befs to use kuid/kgid " Eric W. Biederman
2012-09-20 11:41   ` [PATCH 09/25] userns: Convert cramfs " Eric W. Biederman
2012-09-20 11:41   ` [PATCH 10/25] userns: Convert ecryptfs " Eric W. Biederman
2012-09-20 11:41   ` [PATCH 11/25] userns: Convert efs " Eric W. Biederman
2012-09-20 11:41   ` [PATCH 12/25] userns: Convert exofs " Eric W. Biederman
2012-09-20 12:20     ` Boaz Harrosh
2012-09-20 11:41   ` [PATCH 13/25] userns: Convert hfs to use kuid and kgid " Eric W. Biederman
2012-09-20 11:41   ` [PATCH 14/25] userns: Convert hfsplus " Eric W. Biederman
2012-09-20 11:41   ` [PATCH 15/25] userns: Convert isofs to use kuid/kgid " Eric W. Biederman
2012-09-20 11:41   ` [PATCH 16/25] userns: Convert logfs " Eric W. Biederman
2012-09-20 11:41   ` [PATCH 17/25] userns: Convert minix " Eric W. Biederman
2012-09-20 11:41   ` [PATCH 18/25] userns: Convert nillfs2 " Eric W. Biederman
2012-09-20 14:34     ` Ryusuke Konishi
2012-09-20 11:42   ` [PATCH 19/25] userns: Convert ntfs to use kuid and kgid " Eric W. Biederman
2012-09-20 11:42   ` [PATCH 20/25] userns: Convert omfs " Eric W. Biederman
2012-09-20 12:50     ` Bob Copeland
2012-09-20 13:13       ` Eric W. Biederman
2012-09-20 13:19         ` Bob Copeland
2012-09-20 11:42   ` [PATCH 21/25] userns: Convert the qnx4 filesystem to use kuid/kgid " Eric W. Biederman
2012-09-20 12:34     ` Anders Larsen
2012-09-20 11:42   ` [PATCH 22/25] userns: Convert the qnx6 " Eric W. Biederman
2012-09-20 11:42   ` [PATCH 25/25] userns: Convert ipathfs to use GLOBAL_ROOT_UID and GLOBAL_ROOT_GID Eric W. Biederman
2012-09-20 16:47     ` Marciniszyn, Mike
2012-09-20 11:55   ` [PATCH 01/25] userns: Convert fat to use kuid/kgid where appropriate OGAWA Hirofumi
2012-09-20 12:04     ` Eric W. Biederman
2012-09-20 12:28       ` OGAWA Hirofumi

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1348141326-23355-7-git-send-email-ebiederm@xmission.com \
    --to=ebiederm@xmission.com \
    --cc=containers@lists.linux-foundation.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=serge@hallyn.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®