aboutsummaryrefslogtreecommitdiffstats
path: root/fs/affs
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/affs
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/affs')
-rw-r--r--fs/affs/affs.h4
-rw-r--r--fs/affs/inode.c20
-rw-r--r--fs/affs/super.c18
3 files changed, 23 insertions, 19 deletions
diff --git a/fs/affs/affs.h b/fs/affs/affs.h
index 6e216419f340..3952121f2f28 100644
--- a/fs/affs/affs.h
+++ b/fs/affs/affs.h
@@ -88,8 +88,8 @@ struct affs_sb_info {
88 u32 s_root_block; /* FFS root block number. */ 88 u32 s_root_block; /* FFS root block number. */
89 int s_hashsize; /* Size of hash table. */ 89 int s_hashsize; /* Size of hash table. */
90 unsigned long s_flags; /* See below. */ 90 unsigned long s_flags; /* See below. */
91 uid_t s_uid; /* uid to override */ 91 kuid_t s_uid; /* uid to override */
92 gid_t s_gid; /* gid to override */ 92 kgid_t s_gid; /* gid to override */
93 umode_t s_mode; /* mode to override */ 93 umode_t s_mode; /* mode to override */
94 struct buffer_head *s_root_bh; /* Cached root block. */ 94 struct buffer_head *s_root_bh; /* Cached root block. */
95 struct mutex s_bmlock; /* Protects bitmap access. */ 95 struct mutex s_bmlock; /* Protects bitmap access. */
diff --git a/fs/affs/inode.c b/fs/affs/inode.c
index 8bc4a59f4e7e..15c484268229 100644
--- a/fs/affs/inode.c
+++ b/fs/affs/inode.c
@@ -80,17 +80,17 @@ struct inode *affs_iget(struct super_block *sb, unsigned long ino)
80 if (id == 0 || sbi->s_flags & SF_SETUID) 80 if (id == 0 || sbi->s_flags & SF_SETUID)
81 inode->i_uid = sbi->s_uid; 81 inode->i_uid = sbi->s_uid;
82 else if (id == 0xFFFF && sbi->s_flags & SF_MUFS) 82 else if (id == 0xFFFF && sbi->s_flags & SF_MUFS)
83 inode->i_uid = 0; 83 i_uid_write(inode, 0);
84 else 84 else
85 inode->i_uid = id; 85 i_uid_write(inode, id);
86 86
87 id = be16_to_cpu(tail->gid); 87 id = be16_to_cpu(tail->gid);
88 if (id == 0 || sbi->s_flags & SF_SETGID) 88 if (id == 0 || sbi->s_flags & SF_SETGID)
89 inode->i_gid = sbi->s_gid; 89 inode->i_gid = sbi->s_gid;
90 else if (id == 0xFFFF && sbi->s_flags & SF_MUFS) 90 else if (id == 0xFFFF && sbi->s_flags & SF_MUFS)
91 inode->i_gid = 0; 91 i_gid_write(inode, 0);
92 else 92 else
93 inode->i_gid = id; 93 i_gid_write(inode, id);
94 94
95 switch (be32_to_cpu(tail->stype)) { 95 switch (be32_to_cpu(tail->stype)) {
96 case ST_ROOT: 96 case ST_ROOT:
@@ -193,13 +193,13 @@ affs_write_inode(struct inode *inode, struct writeback_control *wbc)
193 tail->size = cpu_to_be32(inode->i_size); 193 tail->size = cpu_to_be32(inode->i_size);
194 secs_to_datestamp(inode->i_mtime.tv_sec,&tail->change); 194 secs_to_datestamp(inode->i_mtime.tv_sec,&tail->change);
195 if (!(inode->i_ino == AFFS_SB(sb)->s_root_block)) { 195 if (!(inode->i_ino == AFFS_SB(sb)->s_root_block)) {
196 uid = inode->i_uid; 196 uid = i_uid_read(inode);
197 gid = inode->i_gid; 197 gid = i_gid_read(inode);
198 if (AFFS_SB(sb)->s_flags & SF_MUFS) { 198 if (AFFS_SB(sb)->s_flags & SF_MUFS) {
199 if (inode->i_uid == 0 || inode->i_uid == 0xFFFF) 199 if (uid == 0 || uid == 0xFFFF)
200 uid = inode->i_uid ^ ~0; 200 uid = uid ^ ~0;
201 if (inode->i_gid == 0 || inode->i_gid == 0xFFFF) 201 if (gid == 0 || gid == 0xFFFF)
202 gid = inode->i_gid ^ ~0; 202 gid = gid ^ ~0;
203 } 203 }
204 if (!(AFFS_SB(sb)->s_flags & SF_SETUID)) 204 if (!(AFFS_SB(sb)->s_flags & SF_SETUID))
205 tail->uid = cpu_to_be16(uid); 205 tail->uid = cpu_to_be16(uid);
diff --git a/fs/affs/super.c b/fs/affs/super.c
index 022cecb0757d..1f030825cd3a 100644
--- a/fs/affs/super.c
+++ b/fs/affs/super.c
@@ -188,7 +188,7 @@ static const match_table_t tokens = {
188}; 188};
189 189
190static int 190static int
191parse_options(char *options, uid_t *uid, gid_t *gid, int *mode, int *reserved, s32 *root, 191parse_options(char *options, kuid_t *uid, kgid_t *gid, int *mode, int *reserved, s32 *root,
192 int *blocksize, char **prefix, char *volume, unsigned long *mount_opts) 192 int *blocksize, char **prefix, char *volume, unsigned long *mount_opts)
193{ 193{
194 char *p; 194 char *p;
@@ -253,13 +253,17 @@ parse_options(char *options, uid_t *uid, gid_t *gid, int *mode, int *reserved, s
253 case Opt_setgid: 253 case Opt_setgid:
254 if (match_int(&args[0], &option)) 254 if (match_int(&args[0], &option))
255 return 0; 255 return 0;
256 *gid = option; 256 *gid = make_kgid(current_user_ns(), option);
257 if (!gid_valid(*gid))
258 return 0;
257 *mount_opts |= SF_SETGID; 259 *mount_opts |= SF_SETGID;
258 break; 260 break;
259 case Opt_setuid: 261 case Opt_setuid:
260 if (match_int(&args[0], &option)) 262 if (match_int(&args[0], &option))
261 return 0; 263 return 0;
262 *uid = option; 264 *uid = make_kuid(current_user_ns(), option);
265 if (!uid_valid(*uid))
266 return 0;
263 *mount_opts |= SF_SETUID; 267 *mount_opts |= SF_SETUID;
264 break; 268 break;
265 case Opt_verbose: 269 case Opt_verbose:
@@ -301,8 +305,8 @@ static int affs_fill_super(struct super_block *sb, void *data, int silent)
301 int num_bm; 305 int num_bm;
302 int i, j; 306 int i, j;
303 s32 key; 307 s32 key;
304 uid_t uid; 308 kuid_t uid;
305 gid_t gid; 309 kgid_t gid;
306 int reserved; 310 int reserved;
307 unsigned long mount_flags; 311 unsigned long mount_flags;
308 int tmp_flags; /* fix remount prototype... */ 312 int tmp_flags; /* fix remount prototype... */
@@ -527,8 +531,8 @@ affs_remount(struct super_block *sb, int *flags, char *data)
527{ 531{
528 struct affs_sb_info *sbi = AFFS_SB(sb); 532 struct affs_sb_info *sbi = AFFS_SB(sb);
529 int blocksize; 533 int blocksize;
530 uid_t uid; 534 kuid_t uid;
531 gid_t gid; 535 kgid_t gid;
532 int mode; 536 int mode;
533 int reserved; 537 int reserved;
534 int root_block; 538 int root_block;