Commit c010d1ff authored by Eric W. Biederman's avatar Eric W. Biederman

userns: Convert adfs to use kuid and kgid where appropriate

Acked-by: default avatarSerge Hallyn <serge.hallyn@canonical.com>
Signed-off-by: default avatarEric W. Biederman <ebiederm@xmission.com>
parent 9a11f451
...@@ -46,8 +46,8 @@ struct adfs_sb_info { ...@@ -46,8 +46,8 @@ struct adfs_sb_info {
struct adfs_discmap *s_map; /* bh list containing map */ struct adfs_discmap *s_map; /* bh list containing map */
struct adfs_dir_ops *s_dir; /* directory operations */ struct adfs_dir_ops *s_dir; /* directory operations */
uid_t s_uid; /* owner uid */ kuid_t s_uid; /* owner uid */
gid_t s_gid; /* owner gid */ kgid_t s_gid; /* owner gid */
umode_t s_owner_mask; /* ADFS owner perm -> unix perm */ umode_t s_owner_mask; /* ADFS owner perm -> unix perm */
umode_t s_other_mask; /* ADFS other perm -> unix perm */ umode_t s_other_mask; /* ADFS other perm -> unix perm */
int s_ftsuffix; /* ,xyz hex filetype suffix option */ int s_ftsuffix; /* ,xyz hex filetype suffix option */
......
...@@ -304,8 +304,8 @@ adfs_notify_change(struct dentry *dentry, struct iattr *attr) ...@@ -304,8 +304,8 @@ adfs_notify_change(struct dentry *dentry, struct iattr *attr)
* we can't change the UID or GID of any file - * we can't change the UID or GID of any file -
* we have a global UID/GID in the superblock * we have a global UID/GID in the superblock
*/ */
if ((ia_valid & ATTR_UID && attr->ia_uid != ADFS_SB(sb)->s_uid) || if ((ia_valid & ATTR_UID && !uid_eq(attr->ia_uid, ADFS_SB(sb)->s_uid)) ||
(ia_valid & ATTR_GID && attr->ia_gid != ADFS_SB(sb)->s_gid)) (ia_valid & ATTR_GID && !gid_eq(attr->ia_gid, ADFS_SB(sb)->s_gid)))
error = -EPERM; error = -EPERM;
if (error) if (error)
......
...@@ -15,6 +15,7 @@ ...@@ -15,6 +15,7 @@
#include <linux/seq_file.h> #include <linux/seq_file.h>
#include <linux/slab.h> #include <linux/slab.h>
#include <linux/statfs.h> #include <linux/statfs.h>
#include <linux/user_namespace.h>
#include "adfs.h" #include "adfs.h"
#include "dir_f.h" #include "dir_f.h"
#include "dir_fplus.h" #include "dir_fplus.h"
...@@ -130,10 +131,10 @@ static int adfs_show_options(struct seq_file *seq, struct dentry *root) ...@@ -130,10 +131,10 @@ static int adfs_show_options(struct seq_file *seq, struct dentry *root)
{ {
struct adfs_sb_info *asb = ADFS_SB(root->d_sb); struct adfs_sb_info *asb = ADFS_SB(root->d_sb);
if (asb->s_uid != 0) if (!uid_eq(asb->s_uid, GLOBAL_ROOT_UID))
seq_printf(seq, ",uid=%u", asb->s_uid); seq_printf(seq, ",uid=%u", from_kuid_munged(&init_user_ns, asb->s_uid));
if (asb->s_gid != 0) if (!gid_eq(asb->s_gid, GLOBAL_ROOT_GID))
seq_printf(seq, ",gid=%u", asb->s_gid); seq_printf(seq, ",gid=%u", from_kgid_munged(&init_user_ns, asb->s_gid));
if (asb->s_owner_mask != ADFS_DEFAULT_OWNER_MASK) if (asb->s_owner_mask != ADFS_DEFAULT_OWNER_MASK)
seq_printf(seq, ",ownmask=%o", asb->s_owner_mask); seq_printf(seq, ",ownmask=%o", asb->s_owner_mask);
if (asb->s_other_mask != ADFS_DEFAULT_OTHER_MASK) if (asb->s_other_mask != ADFS_DEFAULT_OTHER_MASK)
...@@ -175,12 +176,16 @@ static int parse_options(struct super_block *sb, char *options) ...@@ -175,12 +176,16 @@ static int parse_options(struct super_block *sb, char *options)
case Opt_uid: case Opt_uid:
if (match_int(args, &option)) if (match_int(args, &option))
return -EINVAL; return -EINVAL;
asb->s_uid = option; asb->s_uid = make_kuid(current_user_ns(), option);
if (!uid_valid(asb->s_uid))
return -EINVAL;
break; break;
case Opt_gid: case Opt_gid:
if (match_int(args, &option)) if (match_int(args, &option))
return -EINVAL; return -EINVAL;
asb->s_gid = option; asb->s_gid = make_kgid(current_user_ns(), option);
if (!gid_valid(asb->s_gid))
return -EINVAL;
break; break;
case Opt_ownmask: case Opt_ownmask:
if (match_octal(args, &option)) if (match_octal(args, &option))
...@@ -369,8 +374,8 @@ static int adfs_fill_super(struct super_block *sb, void *data, int silent) ...@@ -369,8 +374,8 @@ static int adfs_fill_super(struct super_block *sb, void *data, int silent)
sb->s_fs_info = asb; sb->s_fs_info = asb;
/* set default options */ /* set default options */
asb->s_uid = 0; asb->s_uid = GLOBAL_ROOT_UID;
asb->s_gid = 0; asb->s_gid = GLOBAL_ROOT_GID;
asb->s_owner_mask = ADFS_DEFAULT_OWNER_MASK; asb->s_owner_mask = ADFS_DEFAULT_OWNER_MASK;
asb->s_other_mask = ADFS_DEFAULT_OTHER_MASK; asb->s_other_mask = ADFS_DEFAULT_OTHER_MASK;
asb->s_ftsuffix = 0; asb->s_ftsuffix = 0;
......
...@@ -933,7 +933,6 @@ config UIDGID_CONVERTED ...@@ -933,7 +933,6 @@ config UIDGID_CONVERTED
# Filesystems # Filesystems
depends on 9P_FS = n depends on 9P_FS = n
depends on ADFS_FS = n
depends on AFFS_FS = n depends on AFFS_FS = n
depends on AFS_FS = n depends on AFS_FS = n
depends on AUTOFS4_FS = n depends on AUTOFS4_FS = n
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment