aboutsummaryrefslogtreecommitdiffstats
path: root/fs/hfs
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2012-10-02 14:11:09 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2012-10-02 14:11:09 -0400
commit437589a74b6a590d175f86cf9f7b2efcee7765e7 (patch)
tree37bf8635b1356d80ef002b00e84f3faf3d555a63 /fs/hfs
parent68d47a137c3bef754923bccf73fb639c9b0bbd5e (diff)
parent72235465864d84cedb2d9f26f8e1de824ee20339 (diff)
Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/ebiederm/user-namespace
Pull user namespace changes from Eric Biederman: "This is a mostly modest set of changes to enable basic user namespace support. This allows the code to code to compile with user namespaces enabled and removes the assumption there is only the initial user namespace. Everything is converted except for the most complex of the filesystems: autofs4, 9p, afs, ceph, cifs, coda, fuse, gfs2, ncpfs, nfs, ocfs2 and xfs as those patches need a bit more review. The strategy is to push kuid_t and kgid_t values are far down into subsystems and filesystems as reasonable. Leaving the make_kuid and from_kuid operations to happen at the edge of userspace, as the values come off the disk, and as the values come in from the network. Letting compile type incompatible compile errors (present when user namespaces are enabled) guide me to find the issues. The most tricky areas have been the places where we had an implicit union of uid and gid values and were storing them in an unsigned int. Those places were converted into explicit unions. I made certain to handle those places with simple trivial patches. Out of that work I discovered we have generic interfaces for storing quota by projid. I had never heard of the project identifiers before. Adding full user namespace support for project identifiers accounts for most of the code size growth in my git tree. Ultimately there will be work to relax privlige checks from "capable(FOO)" to "ns_capable(user_ns, FOO)" where it is safe allowing root in a user names to do those things that today we only forbid to non-root users because it will confuse suid root applications. While I was pushing kuid_t and kgid_t changes deep into the audit code I made a few other cleanups. I capitalized on the fact we process netlink messages in the context of the message sender. I removed usage of NETLINK_CRED, and started directly using current->tty. Some of these patches have also made it into maintainer trees, with no problems from identical code from different trees showing up in linux-next. After reading through all of this code I feel like I might be able to win a game of kernel trivial pursuit." Fix up some fairly trivial conflicts in netfilter uid/git logging code. * 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/ebiederm/user-namespace: (107 commits) userns: Convert the ufs filesystem to use kuid/kgid where appropriate userns: Convert the udf filesystem to use kuid/kgid where appropriate userns: Convert ubifs to use kuid/kgid userns: Convert squashfs to use kuid/kgid where appropriate userns: Convert reiserfs to use kuid and kgid where appropriate userns: Convert jfs to use kuid/kgid where appropriate userns: Convert jffs2 to use kuid and kgid where appropriate userns: Convert hpfs to use kuid and kgid where appropriate userns: Convert btrfs to use kuid/kgid where appropriate userns: Convert bfs to use kuid/kgid where appropriate userns: Convert affs to use kuid/kgid wherwe appropriate userns: On alpha modify linux_to_osf_stat to use convert from kuids and kgids userns: On ia64 deal with current_uid and current_gid being kuid and kgid userns: On ppc convert current_uid from a kuid before printing. userns: Convert s390 getting uid and gid system calls to use kuid and kgid userns: Convert s390 hypfs to use kuid and kgid where appropriate userns: Convert binder ipc to use kuids userns: Teach security_path_chown to take kuids and kgids userns: Add user namespace support to IMA userns: Convert EVM to deal with kuids and kgids in it's hmac computation ...
Diffstat (limited to 'fs/hfs')
-rw-r--r--fs/hfs/hfs_fs.h4
-rw-r--r--fs/hfs/inode.c4
-rw-r--r--fs/hfs/super.c16
3 files changed, 17 insertions, 7 deletions
diff --git a/fs/hfs/hfs_fs.h b/fs/hfs/hfs_fs.h
index 8275175acf6e..693df9fe52b2 100644
--- a/fs/hfs/hfs_fs.h
+++ b/fs/hfs/hfs_fs.h
@@ -134,8 +134,8 @@ struct hfs_sb_info {
134 permissions on all files */ 134 permissions on all files */
135 umode_t s_dir_umask; /* The umask applied to the 135 umode_t s_dir_umask; /* The umask applied to the
136 permissions on all dirs */ 136 permissions on all dirs */
137 uid_t s_uid; /* The uid of all files */ 137 kuid_t s_uid; /* The uid of all files */
138 gid_t s_gid; /* The gid of all files */ 138 kgid_t s_gid; /* The gid of all files */
139 139
140 int session, part; 140 int session, part;
141 struct nls_table *nls_io, *nls_disk; 141 struct nls_table *nls_io, *nls_disk;
diff --git a/fs/hfs/inode.c b/fs/hfs/inode.c
index 553909395270..0b35903219bc 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)
594 594
595 /* no uig/gid changes and limit which mode bits can be set */ 595 /* no uig/gid changes and limit which mode bits can be set */
596 if (((attr->ia_valid & ATTR_UID) && 596 if (((attr->ia_valid & ATTR_UID) &&
597 (attr->ia_uid != hsb->s_uid)) || 597 (!uid_eq(attr->ia_uid, hsb->s_uid))) ||
598 ((attr->ia_valid & ATTR_GID) && 598 ((attr->ia_valid & ATTR_GID) &&
599 (attr->ia_gid != hsb->s_gid)) || 599 (!gid_eq(attr->ia_gid, hsb->s_gid))) ||
600 ((attr->ia_valid & ATTR_MODE) && 600 ((attr->ia_valid & ATTR_MODE) &&
601 ((S_ISDIR(inode->i_mode) && 601 ((S_ISDIR(inode->i_mode) &&
602 (attr->ia_mode != inode->i_mode)) || 602 (attr->ia_mode != inode->i_mode)) ||
diff --git a/fs/hfs/super.c b/fs/hfs/super.c
index 4eb873e0c07b..0b63d135a092 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)
138 seq_printf(seq, ",creator=%.4s", (char *)&sbi->s_creator); 138 seq_printf(seq, ",creator=%.4s", (char *)&sbi->s_creator);
139 if (sbi->s_type != cpu_to_be32(0x3f3f3f3f)) 139 if (sbi->s_type != cpu_to_be32(0x3f3f3f3f))
140 seq_printf(seq, ",type=%.4s", (char *)&sbi->s_type); 140 seq_printf(seq, ",type=%.4s", (char *)&sbi->s_type);
141 seq_printf(seq, ",uid=%u,gid=%u", sbi->s_uid, sbi->s_gid); 141 seq_printf(seq, ",uid=%u,gid=%u",
142 from_kuid_munged(&init_user_ns, sbi->s_uid),
143 from_kgid_munged(&init_user_ns, sbi->s_gid));
142 if (sbi->s_file_umask != 0133) 144 if (sbi->s_file_umask != 0133)
143 seq_printf(seq, ",file_umask=%o", sbi->s_file_umask); 145 seq_printf(seq, ",file_umask=%o", sbi->s_file_umask);
144 if (sbi->s_dir_umask != 0022) 146 if (sbi->s_dir_umask != 0022)
@@ -254,14 +256,22 @@ static int parse_options(char *options, struct hfs_sb_info *hsb)
254 printk(KERN_ERR "hfs: uid requires an argument\n"); 256 printk(KERN_ERR "hfs: uid requires an argument\n");
255 return 0; 257 return 0;
256 } 258 }
257 hsb->s_uid = (uid_t)tmp; 259 hsb->s_uid = make_kuid(current_user_ns(), (uid_t)tmp);
260 if (!uid_valid(hsb->s_uid)) {
261 printk(KERN_ERR "hfs: invalid uid %d\n", tmp);
262 return 0;
263 }
258 break; 264 break;
259 case opt_gid: 265 case opt_gid:
260 if (match_int(&args[0], &tmp)) { 266 if (match_int(&args[0], &tmp)) {
261 printk(KERN_ERR "hfs: gid requires an argument\n"); 267 printk(KERN_ERR "hfs: gid requires an argument\n");
262 return 0; 268 return 0;
263 } 269 }
264 hsb->s_gid = (gid_t)tmp; 270 hsb->s_gid = make_kgid(current_user_ns(), (gid_t)tmp);
271 if (!gid_valid(hsb->s_gid)) {
272 printk(KERN_ERR "hfs: invalid gid %d\n", tmp);
273 return 0;
274 }
265 break; 275 break;
266 case opt_umask: 276 case opt_umask:
267 if (match_octal(&args[0], &tmp)) { 277 if (match_octal(&args[0], &tmp)) {