Skip to content

Commit c010d1f

Browse files
committed
userns: Convert adfs to use kuid and kgid where appropriate
Acked-by: Serge Hallyn <serge.hallyn@canonical.com> Signed-off-by: Eric W. Biederman <ebiederm@xmission.com>
1 parent 9a11f45 commit c010d1f

4 files changed

Lines changed: 17 additions & 13 deletions

File tree

‎fs/adfs/adfs.h‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,8 @@ struct adfs_sb_info {
4646
struct adfs_discmap *s_map; /* bh list containing map */
4747
struct adfs_dir_ops *s_dir; /* directory operations */
4848

49-
uid_t s_uid; /* owner uid */
50-
gid_t s_gid; /* owner gid */
49+
kuid_t s_uid; /* owner uid */
50+
kgid_t s_gid; /* owner gid */
5151
umode_t s_owner_mask; /* ADFS owner perm -> unix perm */
5252
umode_t s_other_mask; /* ADFS other perm -> unix perm */
5353
int s_ftsuffix; /* ,xyz hex filetype suffix option */

‎fs/adfs/inode.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -304,8 +304,8 @@ adfs_notify_change(struct dentry *dentry, struct iattr *attr)
304304
* we can't change the UID or GID of any file -
305305
* we have a global UID/GID in the superblock
306306
*/
307-
if ((ia_valid & ATTR_UID && attr->ia_uid != ADFS_SB(sb)->s_uid) ||
308-
(ia_valid & ATTR_GID && attr->ia_gid != ADFS_SB(sb)->s_gid))
307+
if ((ia_valid & ATTR_UID && !uid_eq(attr->ia_uid, ADFS_SB(sb)->s_uid)) ||
308+
(ia_valid & ATTR_GID && !gid_eq(attr->ia_gid, ADFS_SB(sb)->s_gid)))
309309
error = -EPERM;
310310

311311
if (error)

‎fs/adfs/super.c‎

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
#include <linux/seq_file.h>
1616
#include <linux/slab.h>
1717
#include <linux/statfs.h>
18+
#include <linux/user_namespace.h>
1819
#include "adfs.h"
1920
#include "dir_f.h"
2021
#include "dir_fplus.h"
@@ -130,10 +131,10 @@ static int adfs_show_options(struct seq_file *seq, struct dentry *root)
130131
{
131132
struct adfs_sb_info *asb = ADFS_SB(root->d_sb);
132133

133-
if (asb->s_uid != 0)
134-
seq_printf(seq, ",uid=%u", asb->s_uid);
135-
if (asb->s_gid != 0)
136-
seq_printf(seq, ",gid=%u", asb->s_gid);
134+
if (!uid_eq(asb->s_uid, GLOBAL_ROOT_UID))
135+
seq_printf(seq, ",uid=%u", from_kuid_munged(&init_user_ns, asb->s_uid));
136+
if (!gid_eq(asb->s_gid, GLOBAL_ROOT_GID))
137+
seq_printf(seq, ",gid=%u", from_kgid_munged(&init_user_ns, asb->s_gid));
137138
if (asb->s_owner_mask != ADFS_DEFAULT_OWNER_MASK)
138139
seq_printf(seq, ",ownmask=%o", asb->s_owner_mask);
139140
if (asb->s_other_mask != ADFS_DEFAULT_OTHER_MASK)
@@ -175,12 +176,16 @@ static int parse_options(struct super_block *sb, char *options)
175176
case Opt_uid:
176177
if (match_int(args, &option))
177178
return -EINVAL;
178-
asb->s_uid = option;
179+
asb->s_uid = make_kuid(current_user_ns(), option);
180+
if (!uid_valid(asb->s_uid))
181+
return -EINVAL;
179182
break;
180183
case Opt_gid:
181184
if (match_int(args, &option))
182185
return -EINVAL;
183-
asb->s_gid = option;
186+
asb->s_gid = make_kgid(current_user_ns(), option);
187+
if (!gid_valid(asb->s_gid))
188+
return -EINVAL;
184189
break;
185190
case Opt_ownmask:
186191
if (match_octal(args, &option))
@@ -369,8 +374,8 @@ static int adfs_fill_super(struct super_block *sb, void *data, int silent)
369374
sb->s_fs_info = asb;
370375

371376
/* set default options */
372-
asb->s_uid = 0;
373-
asb->s_gid = 0;
377+
asb->s_uid = GLOBAL_ROOT_UID;
378+
asb->s_gid = GLOBAL_ROOT_GID;
374379
asb->s_owner_mask = ADFS_DEFAULT_OWNER_MASK;
375380
asb->s_other_mask = ADFS_DEFAULT_OTHER_MASK;
376381
asb->s_ftsuffix = 0;

‎init/Kconfig‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -933,7 +933,6 @@ config UIDGID_CONVERTED
933933

934934
# Filesystems
935935
depends on 9P_FS = n
936-
depends on ADFS_FS = n
937936
depends on AFFS_FS = n
938937
depends on AFS_FS = n
939938
depends on AUTOFS4_FS = n

0 commit comments

Comments
 (0)