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 13/25] userns: Convert hfs to use kuid and kgid where appropriate
Date: Thu, 20 Sep 2012 04:41:54 -0700	[thread overview]
Message-ID: <1348141326-23355-13-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/hfs/hfs_fs.h |    4 ++--
 fs/hfs/inode.c  |    4 ++--
 fs/hfs/super.c  |   16 +++++++++++++---
 init/Kconfig    |    1 -
 4 files changed, 17 insertions(+), 8 deletions(-)

diff --git a/fs/hfs/hfs_fs.h b/fs/hfs/hfs_fs.h
index 8275175..693df9f 100644
--- a/fs/hfs/hfs_fs.h
+++ b/fs/hfs/hfs_fs.h
@@ -134,8 +134,8 @@ struct hfs_sb_info {
 						   permissions on all files */
 	umode_t s_dir_umask;			/* The umask applied to the
 						   permissions on all dirs */
-	uid_t s_uid;				/* The uid of all files */
-	gid_t s_gid;				/* The gid of all files */
+	kuid_t s_uid;				/* The uid of all files */
+	kgid_t s_gid;				/* The gid of all files */
 
 	int session, part;
 	struct nls_table *nls_io, *nls_disk;
diff --git a/fs/hfs/inode.c b/fs/hfs/inode.c
index ee1bc55..5d5c22d 100644
--- a/fs/hfs/inode.c
+++ b/fs/hfs/inode.c
@@ -594,9 +594,9 @@ int hfs_inode_setattr(struct dentry *dentry, struct iattr * attr)
 
 	/* no uig/gid changes and limit which mode bits can be set */
 	if (((attr->ia_valid & ATTR_UID) &&
-	     (attr->ia_uid != hsb->s_uid)) ||
+	     (!uid_eq(attr->ia_uid, hsb->s_uid))) ||
 	    ((attr->ia_valid & ATTR_GID) &&
-	     (attr->ia_gid != hsb->s_gid)) ||
+	     (!gid_eq(attr->ia_gid, hsb->s_gid))) ||
 	    ((attr->ia_valid & ATTR_MODE) &&
 	     ((S_ISDIR(inode->i_mode) &&
 	       (attr->ia_mode != inode->i_mode)) ||
diff --git a/fs/hfs/super.c b/fs/hfs/super.c
index 4eb873e..0b63d13 100644
--- a/fs/hfs/super.c
+++ b/fs/hfs/super.c
@@ -138,7 +138,9 @@ static int hfs_show_options(struct seq_file *seq, struct dentry *root)
 		seq_printf(seq, ",creator=%.4s", (char *)&sbi->s_creator);
 	if (sbi->s_type != cpu_to_be32(0x3f3f3f3f))
 		seq_printf(seq, ",type=%.4s", (char *)&sbi->s_type);
-	seq_printf(seq, ",uid=%u,gid=%u", sbi->s_uid, sbi->s_gid);
+	seq_printf(seq, ",uid=%u,gid=%u",
+			from_kuid_munged(&init_user_ns, sbi->s_uid),
+			from_kgid_munged(&init_user_ns, sbi->s_gid));
 	if (sbi->s_file_umask != 0133)
 		seq_printf(seq, ",file_umask=%o", sbi->s_file_umask);
 	if (sbi->s_dir_umask != 0022)
@@ -254,14 +256,22 @@ static int parse_options(char *options, struct hfs_sb_info *hsb)
 				printk(KERN_ERR "hfs: uid requires an argument\n");
 				return 0;
 			}
-			hsb->s_uid = (uid_t)tmp;
+			hsb->s_uid = make_kuid(current_user_ns(), (uid_t)tmp);
+			if (!uid_valid(hsb->s_uid)) {
+				printk(KERN_ERR "hfs: invalid uid %d\n", tmp);
+				return 0;
+			}
 			break;
 		case opt_gid:
 			if (match_int(&args[0], &tmp)) {
 				printk(KERN_ERR "hfs: gid requires an argument\n");
 				return 0;
 			}
-			hsb->s_gid = (gid_t)tmp;
+			hsb->s_gid = make_kgid(current_user_ns(), (gid_t)tmp);
+			if (!gid_valid(hsb->s_gid)) {
+				printk(KERN_ERR "hfs: invalid gid %d\n", tmp);
+				return 0;
+			}
 			break;
 		case opt_umask:
 			if (match_octal(&args[0], &tmp)) {
diff --git a/init/Kconfig b/init/Kconfig
index 39e55d6..6038d64 100644
--- a/init/Kconfig
+++ b/init/Kconfig
@@ -943,7 +943,6 @@ config UIDGID_CONVERTED
 	depends on CODA_FS = n
 	depends on FUSE_FS = n
 	depends on GFS2_FS = n
-	depends on HFS_FS = n
 	depends on HFSPLUS_FS = n
 	depends on HPFS_FS = n
 	depends on ISO9660_FS = n
-- 
1.7.5.4


  parent reply	other threads:[~2012-09-20 12:11 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   ` [PATCH 07/25] userns: Convert adfs " Eric W. Biederman
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   ` Eric W. Biederman [this message]
2012-09-20 11:41   ` [PATCH 14/25] userns: Convert hfsplus to use kuid and kgid " 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-13-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®