diff options
author | Eric W. Biederman <ebiederm@xmission.com> | 2012-02-10 14:40:34 -0500 |
---|---|---|
committer | Eric W. Biederman <ebiederm@xmission.com> | 2012-09-21 06:13:33 -0400 |
commit | c18cdc1a3ec643b5c6c0d65aac1a6bf8e461778f (patch) | |
tree | cf64715724bb73a7bb19cd15ba87188d0a31af38 | |
parent | 0cfe53d3c3875e1dd565b30737cd5c6691c00188 (diff) |
userns: Convert jfs to use kuid/kgid where appropriate
Cc: Dave Kleikamp <shaggy@kernel.org>
Signed-off-by: Eric W. Biederman <ebiederm@xmission.com>
-rw-r--r-- | fs/jfs/file.c | 4 | ||||
-rw-r--r-- | fs/jfs/jfs_imap.c | 22 | ||||
-rw-r--r-- | fs/jfs/jfs_incore.h | 8 | ||||
-rw-r--r-- | fs/jfs/super.c | 22 | ||||
-rw-r--r-- | init/Kconfig | 1 |
5 files changed, 33 insertions, 24 deletions
diff --git a/fs/jfs/file.c b/fs/jfs/file.c index 844f9460cb11..9d3afd157f99 100644 --- a/fs/jfs/file.c +++ b/fs/jfs/file.c | |||
@@ -108,8 +108,8 @@ int jfs_setattr(struct dentry *dentry, struct iattr *iattr) | |||
108 | 108 | ||
109 | if (is_quota_modification(inode, iattr)) | 109 | if (is_quota_modification(inode, iattr)) |
110 | dquot_initialize(inode); | 110 | dquot_initialize(inode); |
111 | if ((iattr->ia_valid & ATTR_UID && iattr->ia_uid != inode->i_uid) || | 111 | if ((iattr->ia_valid & ATTR_UID && !uid_eq(iattr->ia_uid, inode->i_uid)) || |
112 | (iattr->ia_valid & ATTR_GID && iattr->ia_gid != inode->i_gid)) { | 112 | (iattr->ia_valid & ATTR_GID && !gid_eq(iattr->ia_gid, inode->i_gid))) { |
113 | rc = dquot_transfer(inode, iattr); | 113 | rc = dquot_transfer(inode, iattr); |
114 | if (rc) | 114 | if (rc) |
115 | return rc; | 115 | return rc; |
diff --git a/fs/jfs/jfs_imap.c b/fs/jfs/jfs_imap.c index 1b6f15f191b3..6ba4006e011b 100644 --- a/fs/jfs/jfs_imap.c +++ b/fs/jfs/jfs_imap.c | |||
@@ -3078,15 +3078,15 @@ static int copy_from_dinode(struct dinode * dip, struct inode *ip) | |||
3078 | } | 3078 | } |
3079 | set_nlink(ip, le32_to_cpu(dip->di_nlink)); | 3079 | set_nlink(ip, le32_to_cpu(dip->di_nlink)); |
3080 | 3080 | ||
3081 | jfs_ip->saved_uid = le32_to_cpu(dip->di_uid); | 3081 | jfs_ip->saved_uid = make_kuid(&init_user_ns, le32_to_cpu(dip->di_uid)); |
3082 | if (sbi->uid == -1) | 3082 | if (!uid_valid(sbi->uid)) |
3083 | ip->i_uid = jfs_ip->saved_uid; | 3083 | ip->i_uid = jfs_ip->saved_uid; |
3084 | else { | 3084 | else { |
3085 | ip->i_uid = sbi->uid; | 3085 | ip->i_uid = sbi->uid; |
3086 | } | 3086 | } |
3087 | 3087 | ||
3088 | jfs_ip->saved_gid = le32_to_cpu(dip->di_gid); | 3088 | jfs_ip->saved_gid = make_kgid(&init_user_ns, le32_to_cpu(dip->di_gid)); |
3089 | if (sbi->gid == -1) | 3089 | if (!gid_valid(sbi->gid)) |
3090 | ip->i_gid = jfs_ip->saved_gid; | 3090 | ip->i_gid = jfs_ip->saved_gid; |
3091 | else { | 3091 | else { |
3092 | ip->i_gid = sbi->gid; | 3092 | ip->i_gid = sbi->gid; |
@@ -3150,14 +3150,16 @@ static void copy_to_dinode(struct dinode * dip, struct inode *ip) | |||
3150 | dip->di_size = cpu_to_le64(ip->i_size); | 3150 | dip->di_size = cpu_to_le64(ip->i_size); |
3151 | dip->di_nblocks = cpu_to_le64(PBLK2LBLK(ip->i_sb, ip->i_blocks)); | 3151 | dip->di_nblocks = cpu_to_le64(PBLK2LBLK(ip->i_sb, ip->i_blocks)); |
3152 | dip->di_nlink = cpu_to_le32(ip->i_nlink); | 3152 | dip->di_nlink = cpu_to_le32(ip->i_nlink); |
3153 | if (sbi->uid == -1) | 3153 | if (!uid_valid(sbi->uid)) |
3154 | dip->di_uid = cpu_to_le32(ip->i_uid); | 3154 | dip->di_uid = cpu_to_le32(i_uid_read(ip)); |
3155 | else | 3155 | else |
3156 | dip->di_uid = cpu_to_le32(jfs_ip->saved_uid); | 3156 | dip->di_uid =cpu_to_le32(from_kuid(&init_user_ns, |
3157 | if (sbi->gid == -1) | 3157 | jfs_ip->saved_uid)); |
3158 | dip->di_gid = cpu_to_le32(ip->i_gid); | 3158 | if (!gid_valid(sbi->gid)) |
3159 | dip->di_gid = cpu_to_le32(i_gid_read(ip)); | ||
3159 | else | 3160 | else |
3160 | dip->di_gid = cpu_to_le32(jfs_ip->saved_gid); | 3161 | dip->di_gid = cpu_to_le32(from_kgid(&init_user_ns, |
3162 | jfs_ip->saved_gid)); | ||
3161 | jfs_get_inode_flags(jfs_ip); | 3163 | jfs_get_inode_flags(jfs_ip); |
3162 | /* | 3164 | /* |
3163 | * mode2 is only needed for storing the higher order bits. | 3165 | * mode2 is only needed for storing the higher order bits. |
diff --git a/fs/jfs/jfs_incore.h b/fs/jfs/jfs_incore.h index 584a4a1a6e81..680605d7bf15 100644 --- a/fs/jfs/jfs_incore.h +++ b/fs/jfs/jfs_incore.h | |||
@@ -38,8 +38,8 @@ | |||
38 | struct jfs_inode_info { | 38 | struct jfs_inode_info { |
39 | int fileset; /* fileset number (always 16)*/ | 39 | int fileset; /* fileset number (always 16)*/ |
40 | uint mode2; /* jfs-specific mode */ | 40 | uint mode2; /* jfs-specific mode */ |
41 | uint saved_uid; /* saved for uid mount option */ | 41 | kuid_t saved_uid; /* saved for uid mount option */ |
42 | uint saved_gid; /* saved for gid mount option */ | 42 | kgid_t saved_gid; /* saved for gid mount option */ |
43 | pxd_t ixpxd; /* inode extent descriptor */ | 43 | pxd_t ixpxd; /* inode extent descriptor */ |
44 | dxd_t acl; /* dxd describing acl */ | 44 | dxd_t acl; /* dxd describing acl */ |
45 | dxd_t ea; /* dxd describing ea */ | 45 | dxd_t ea; /* dxd describing ea */ |
@@ -192,8 +192,8 @@ struct jfs_sb_info { | |||
192 | uint state; /* mount/recovery state */ | 192 | uint state; /* mount/recovery state */ |
193 | unsigned long flag; /* mount time flags */ | 193 | unsigned long flag; /* mount time flags */ |
194 | uint p_state; /* state prior to going no integrity */ | 194 | uint p_state; /* state prior to going no integrity */ |
195 | uint uid; /* uid to override on-disk uid */ | 195 | kuid_t uid; /* uid to override on-disk uid */ |
196 | uint gid; /* gid to override on-disk gid */ | 196 | kgid_t gid; /* gid to override on-disk gid */ |
197 | uint umask; /* umask to override on-disk umask */ | 197 | uint umask; /* umask to override on-disk umask */ |
198 | }; | 198 | }; |
199 | 199 | ||
diff --git a/fs/jfs/super.c b/fs/jfs/super.c index c55c7452d285..706692f24033 100644 --- a/fs/jfs/super.c +++ b/fs/jfs/super.c | |||
@@ -321,13 +321,19 @@ static int parse_options(char *options, struct super_block *sb, s64 *newLVSize, | |||
321 | case Opt_uid: | 321 | case Opt_uid: |
322 | { | 322 | { |
323 | char *uid = args[0].from; | 323 | char *uid = args[0].from; |
324 | sbi->uid = simple_strtoul(uid, &uid, 0); | 324 | uid_t val = simple_strtoul(uid, &uid, 0); |
325 | sbi->uid = make_kuid(current_user_ns(), val); | ||
326 | if (!uid_valid(sbi->uid)) | ||
327 | goto cleanup; | ||
325 | break; | 328 | break; |
326 | } | 329 | } |
327 | case Opt_gid: | 330 | case Opt_gid: |
328 | { | 331 | { |
329 | char *gid = args[0].from; | 332 | char *gid = args[0].from; |
330 | sbi->gid = simple_strtoul(gid, &gid, 0); | 333 | gid_t val = simple_strtoul(gid, &gid, 0); |
334 | sbi->gid = make_kgid(current_user_ns(), val); | ||
335 | if (!gid_valid(sbi->gid)) | ||
336 | goto cleanup; | ||
331 | break; | 337 | break; |
332 | } | 338 | } |
333 | case Opt_umask: | 339 | case Opt_umask: |
@@ -443,7 +449,9 @@ static int jfs_fill_super(struct super_block *sb, void *data, int silent) | |||
443 | sb->s_fs_info = sbi; | 449 | sb->s_fs_info = sbi; |
444 | sb->s_max_links = JFS_LINK_MAX; | 450 | sb->s_max_links = JFS_LINK_MAX; |
445 | sbi->sb = sb; | 451 | sbi->sb = sb; |
446 | sbi->uid = sbi->gid = sbi->umask = -1; | 452 | sbi->uid = INVALID_UID; |
453 | sbi->gid = INVALID_GID; | ||
454 | sbi->umask = -1; | ||
447 | 455 | ||
448 | /* initialize the mount flag and determine the default error handler */ | 456 | /* initialize the mount flag and determine the default error handler */ |
449 | flag = JFS_ERR_REMOUNT_RO; | 457 | flag = JFS_ERR_REMOUNT_RO; |
@@ -617,10 +625,10 @@ static int jfs_show_options(struct seq_file *seq, struct dentry *root) | |||
617 | { | 625 | { |
618 | struct jfs_sb_info *sbi = JFS_SBI(root->d_sb); | 626 | struct jfs_sb_info *sbi = JFS_SBI(root->d_sb); |
619 | 627 | ||
620 | if (sbi->uid != -1) | 628 | if (uid_valid(sbi->uid)) |
621 | seq_printf(seq, ",uid=%d", sbi->uid); | 629 | seq_printf(seq, ",uid=%d", from_kuid(&init_user_ns, sbi->uid)); |
622 | if (sbi->gid != -1) | 630 | if (gid_valid(sbi->gid)) |
623 | seq_printf(seq, ",gid=%d", sbi->gid); | 631 | seq_printf(seq, ",gid=%d", from_kgid(&init_user_ns, sbi->gid)); |
624 | if (sbi->umask != -1) | 632 | if (sbi->umask != -1) |
625 | seq_printf(seq, ",umask=%03o", sbi->umask); | 633 | seq_printf(seq, ",umask=%03o", sbi->umask); |
626 | if (sbi->flag & JFS_NOINTEGRITY) | 634 | if (sbi->flag & JFS_NOINTEGRITY) |
diff --git a/init/Kconfig b/init/Kconfig index cf2d50b82fe5..20d4a1bf3281 100644 --- a/init/Kconfig +++ b/init/Kconfig | |||
@@ -935,7 +935,6 @@ config UIDGID_CONVERTED | |||
935 | depends on CODA_FS = n | 935 | depends on CODA_FS = n |
936 | depends on FUSE_FS = n | 936 | depends on FUSE_FS = n |
937 | depends on GFS2_FS = n | 937 | depends on GFS2_FS = n |
938 | depends on JFS_FS = n | ||
939 | depends on NCP_FS = n | 938 | depends on NCP_FS = n |
940 | depends on NFSD = n | 939 | depends on NFSD = n |
941 | depends on NFS_FS = n | 940 | depends on NFS_FS = n |