diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2012-10-02 14:11:09 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2012-10-02 14:11:09 -0400 |
commit | 437589a74b6a590d175f86cf9f7b2efcee7765e7 (patch) | |
tree | 37bf8635b1356d80ef002b00e84f3faf3d555a63 /fs/udf | |
parent | 68d47a137c3bef754923bccf73fb639c9b0bbd5e (diff) | |
parent | 72235465864d84cedb2d9f26f8e1de824ee20339 (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/udf')
-rw-r--r-- | fs/udf/inode.c | 12 | ||||
-rw-r--r-- | fs/udf/super.c | 20 | ||||
-rw-r--r-- | fs/udf/udf_sb.h | 4 |
3 files changed, 20 insertions, 16 deletions
diff --git a/fs/udf/inode.c b/fs/udf/inode.c index aa233469b3c1..287ef9f587b7 100644 --- a/fs/udf/inode.c +++ b/fs/udf/inode.c | |||
@@ -1312,14 +1312,14 @@ static void udf_fill_inode(struct inode *inode, struct buffer_head *bh) | |||
1312 | } | 1312 | } |
1313 | 1313 | ||
1314 | read_lock(&sbi->s_cred_lock); | 1314 | read_lock(&sbi->s_cred_lock); |
1315 | inode->i_uid = le32_to_cpu(fe->uid); | 1315 | i_uid_write(inode, le32_to_cpu(fe->uid)); |
1316 | if (inode->i_uid == -1 || | 1316 | if (!uid_valid(inode->i_uid) || |
1317 | UDF_QUERY_FLAG(inode->i_sb, UDF_FLAG_UID_IGNORE) || | 1317 | UDF_QUERY_FLAG(inode->i_sb, UDF_FLAG_UID_IGNORE) || |
1318 | UDF_QUERY_FLAG(inode->i_sb, UDF_FLAG_UID_SET)) | 1318 | UDF_QUERY_FLAG(inode->i_sb, UDF_FLAG_UID_SET)) |
1319 | inode->i_uid = UDF_SB(inode->i_sb)->s_uid; | 1319 | inode->i_uid = UDF_SB(inode->i_sb)->s_uid; |
1320 | 1320 | ||
1321 | inode->i_gid = le32_to_cpu(fe->gid); | 1321 | i_gid_write(inode, le32_to_cpu(fe->gid)); |
1322 | if (inode->i_gid == -1 || | 1322 | if (!gid_valid(inode->i_gid) || |
1323 | UDF_QUERY_FLAG(inode->i_sb, UDF_FLAG_GID_IGNORE) || | 1323 | UDF_QUERY_FLAG(inode->i_sb, UDF_FLAG_GID_IGNORE) || |
1324 | UDF_QUERY_FLAG(inode->i_sb, UDF_FLAG_GID_SET)) | 1324 | UDF_QUERY_FLAG(inode->i_sb, UDF_FLAG_GID_SET)) |
1325 | inode->i_gid = UDF_SB(inode->i_sb)->s_gid; | 1325 | inode->i_gid = UDF_SB(inode->i_sb)->s_gid; |
@@ -1542,12 +1542,12 @@ static int udf_update_inode(struct inode *inode, int do_sync) | |||
1542 | if (UDF_QUERY_FLAG(inode->i_sb, UDF_FLAG_UID_FORGET)) | 1542 | if (UDF_QUERY_FLAG(inode->i_sb, UDF_FLAG_UID_FORGET)) |
1543 | fe->uid = cpu_to_le32(-1); | 1543 | fe->uid = cpu_to_le32(-1); |
1544 | else | 1544 | else |
1545 | fe->uid = cpu_to_le32(inode->i_uid); | 1545 | fe->uid = cpu_to_le32(i_uid_read(inode)); |
1546 | 1546 | ||
1547 | if (UDF_QUERY_FLAG(inode->i_sb, UDF_FLAG_GID_FORGET)) | 1547 | if (UDF_QUERY_FLAG(inode->i_sb, UDF_FLAG_GID_FORGET)) |
1548 | fe->gid = cpu_to_le32(-1); | 1548 | fe->gid = cpu_to_le32(-1); |
1549 | else | 1549 | else |
1550 | fe->gid = cpu_to_le32(inode->i_gid); | 1550 | fe->gid = cpu_to_le32(i_gid_read(inode)); |
1551 | 1551 | ||
1552 | udfperms = ((inode->i_mode & S_IRWXO)) | | 1552 | udfperms = ((inode->i_mode & S_IRWXO)) | |
1553 | ((inode->i_mode & S_IRWXG) << 2) | | 1553 | ((inode->i_mode & S_IRWXG) << 2) | |
diff --git a/fs/udf/super.c b/fs/udf/super.c index 18fc038a438d..862741dddf27 100644 --- a/fs/udf/super.c +++ b/fs/udf/super.c | |||
@@ -199,8 +199,8 @@ struct udf_options { | |||
199 | unsigned int rootdir; | 199 | unsigned int rootdir; |
200 | unsigned int flags; | 200 | unsigned int flags; |
201 | umode_t umask; | 201 | umode_t umask; |
202 | gid_t gid; | 202 | kgid_t gid; |
203 | uid_t uid; | 203 | kuid_t uid; |
204 | umode_t fmode; | 204 | umode_t fmode; |
205 | umode_t dmode; | 205 | umode_t dmode; |
206 | struct nls_table *nls_map; | 206 | struct nls_table *nls_map; |
@@ -335,9 +335,9 @@ static int udf_show_options(struct seq_file *seq, struct dentry *root) | |||
335 | if (UDF_QUERY_FLAG(sb, UDF_FLAG_GID_IGNORE)) | 335 | if (UDF_QUERY_FLAG(sb, UDF_FLAG_GID_IGNORE)) |
336 | seq_puts(seq, ",gid=ignore"); | 336 | seq_puts(seq, ",gid=ignore"); |
337 | if (UDF_QUERY_FLAG(sb, UDF_FLAG_UID_SET)) | 337 | if (UDF_QUERY_FLAG(sb, UDF_FLAG_UID_SET)) |
338 | seq_printf(seq, ",uid=%u", sbi->s_uid); | 338 | seq_printf(seq, ",uid=%u", from_kuid(&init_user_ns, sbi->s_uid)); |
339 | if (UDF_QUERY_FLAG(sb, UDF_FLAG_GID_SET)) | 339 | if (UDF_QUERY_FLAG(sb, UDF_FLAG_GID_SET)) |
340 | seq_printf(seq, ",gid=%u", sbi->s_gid); | 340 | seq_printf(seq, ",gid=%u", from_kgid(&init_user_ns, sbi->s_gid)); |
341 | if (sbi->s_umask != 0) | 341 | if (sbi->s_umask != 0) |
342 | seq_printf(seq, ",umask=%ho", sbi->s_umask); | 342 | seq_printf(seq, ",umask=%ho", sbi->s_umask); |
343 | if (sbi->s_fmode != UDF_INVALID_MODE) | 343 | if (sbi->s_fmode != UDF_INVALID_MODE) |
@@ -516,13 +516,17 @@ static int udf_parse_options(char *options, struct udf_options *uopt, | |||
516 | case Opt_gid: | 516 | case Opt_gid: |
517 | if (match_int(args, &option)) | 517 | if (match_int(args, &option)) |
518 | return 0; | 518 | return 0; |
519 | uopt->gid = option; | 519 | uopt->gid = make_kgid(current_user_ns(), option); |
520 | if (!gid_valid(uopt->gid)) | ||
521 | return 0; | ||
520 | uopt->flags |= (1 << UDF_FLAG_GID_SET); | 522 | uopt->flags |= (1 << UDF_FLAG_GID_SET); |
521 | break; | 523 | break; |
522 | case Opt_uid: | 524 | case Opt_uid: |
523 | if (match_int(args, &option)) | 525 | if (match_int(args, &option)) |
524 | return 0; | 526 | return 0; |
525 | uopt->uid = option; | 527 | uopt->uid = make_kuid(current_user_ns(), option); |
528 | if (!uid_valid(uopt->uid)) | ||
529 | return 0; | ||
526 | uopt->flags |= (1 << UDF_FLAG_UID_SET); | 530 | uopt->flags |= (1 << UDF_FLAG_UID_SET); |
527 | break; | 531 | break; |
528 | case Opt_umask: | 532 | case Opt_umask: |
@@ -1934,8 +1938,8 @@ static int udf_fill_super(struct super_block *sb, void *options, int silent) | |||
1934 | struct udf_sb_info *sbi; | 1938 | struct udf_sb_info *sbi; |
1935 | 1939 | ||
1936 | uopt.flags = (1 << UDF_FLAG_USE_AD_IN_ICB) | (1 << UDF_FLAG_STRICT); | 1940 | uopt.flags = (1 << UDF_FLAG_USE_AD_IN_ICB) | (1 << UDF_FLAG_STRICT); |
1937 | uopt.uid = -1; | 1941 | uopt.uid = INVALID_UID; |
1938 | uopt.gid = -1; | 1942 | uopt.gid = INVALID_GID; |
1939 | uopt.umask = 0; | 1943 | uopt.umask = 0; |
1940 | uopt.fmode = UDF_INVALID_MODE; | 1944 | uopt.fmode = UDF_INVALID_MODE; |
1941 | uopt.dmode = UDF_INVALID_MODE; | 1945 | uopt.dmode = UDF_INVALID_MODE; |
diff --git a/fs/udf/udf_sb.h b/fs/udf/udf_sb.h index 42ad69ac9576..5f027227f085 100644 --- a/fs/udf/udf_sb.h +++ b/fs/udf/udf_sb.h | |||
@@ -128,8 +128,8 @@ struct udf_sb_info { | |||
128 | 128 | ||
129 | /* Default permissions */ | 129 | /* Default permissions */ |
130 | umode_t s_umask; | 130 | umode_t s_umask; |
131 | gid_t s_gid; | 131 | kgid_t s_gid; |
132 | uid_t s_uid; | 132 | kuid_t s_uid; |
133 | umode_t s_fmode; | 133 | umode_t s_fmode; |
134 | umode_t s_dmode; | 134 | umode_t s_dmode; |
135 | /* Lock protecting consistency of above permission settings */ | 135 | /* Lock protecting consistency of above permission settings */ |