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

userns: Convert the udf filesystem to use kuid/kgid where appropriate

Cc: Jan Kara <jack@suse.cz>
Signed-off-by: default avatarEric W. Biederman <ebiederm@xmission.com>
parent 39241beb
...@@ -1309,14 +1309,14 @@ static void udf_fill_inode(struct inode *inode, struct buffer_head *bh) ...@@ -1309,14 +1309,14 @@ static void udf_fill_inode(struct inode *inode, struct buffer_head *bh)
} }
read_lock(&sbi->s_cred_lock); read_lock(&sbi->s_cred_lock);
inode->i_uid = le32_to_cpu(fe->uid); i_uid_write(inode, le32_to_cpu(fe->uid));
if (inode->i_uid == -1 || if (!uid_valid(inode->i_uid) ||
UDF_QUERY_FLAG(inode->i_sb, UDF_FLAG_UID_IGNORE) || UDF_QUERY_FLAG(inode->i_sb, UDF_FLAG_UID_IGNORE) ||
UDF_QUERY_FLAG(inode->i_sb, UDF_FLAG_UID_SET)) UDF_QUERY_FLAG(inode->i_sb, UDF_FLAG_UID_SET))
inode->i_uid = UDF_SB(inode->i_sb)->s_uid; inode->i_uid = UDF_SB(inode->i_sb)->s_uid;
inode->i_gid = le32_to_cpu(fe->gid); i_gid_write(inode, le32_to_cpu(fe->gid));
if (inode->i_gid == -1 || if (!gid_valid(inode->i_gid) ||
UDF_QUERY_FLAG(inode->i_sb, UDF_FLAG_GID_IGNORE) || UDF_QUERY_FLAG(inode->i_sb, UDF_FLAG_GID_IGNORE) ||
UDF_QUERY_FLAG(inode->i_sb, UDF_FLAG_GID_SET)) UDF_QUERY_FLAG(inode->i_sb, UDF_FLAG_GID_SET))
inode->i_gid = UDF_SB(inode->i_sb)->s_gid; inode->i_gid = UDF_SB(inode->i_sb)->s_gid;
...@@ -1539,12 +1539,12 @@ static int udf_update_inode(struct inode *inode, int do_sync) ...@@ -1539,12 +1539,12 @@ static int udf_update_inode(struct inode *inode, int do_sync)
if (UDF_QUERY_FLAG(inode->i_sb, UDF_FLAG_UID_FORGET)) if (UDF_QUERY_FLAG(inode->i_sb, UDF_FLAG_UID_FORGET))
fe->uid = cpu_to_le32(-1); fe->uid = cpu_to_le32(-1);
else else
fe->uid = cpu_to_le32(inode->i_uid); fe->uid = cpu_to_le32(i_uid_read(inode));
if (UDF_QUERY_FLAG(inode->i_sb, UDF_FLAG_GID_FORGET)) if (UDF_QUERY_FLAG(inode->i_sb, UDF_FLAG_GID_FORGET))
fe->gid = cpu_to_le32(-1); fe->gid = cpu_to_le32(-1);
else else
fe->gid = cpu_to_le32(inode->i_gid); fe->gid = cpu_to_le32(i_gid_read(inode));
udfperms = ((inode->i_mode & S_IRWXO)) | udfperms = ((inode->i_mode & S_IRWXO)) |
((inode->i_mode & S_IRWXG) << 2) | ((inode->i_mode & S_IRWXG) << 2) |
......
...@@ -199,8 +199,8 @@ struct udf_options { ...@@ -199,8 +199,8 @@ struct udf_options {
unsigned int rootdir; unsigned int rootdir;
unsigned int flags; unsigned int flags;
umode_t umask; umode_t umask;
gid_t gid; kgid_t gid;
uid_t uid; kuid_t uid;
umode_t fmode; umode_t fmode;
umode_t dmode; umode_t dmode;
struct nls_table *nls_map; struct nls_table *nls_map;
...@@ -335,9 +335,9 @@ static int udf_show_options(struct seq_file *seq, struct dentry *root) ...@@ -335,9 +335,9 @@ static int udf_show_options(struct seq_file *seq, struct dentry *root)
if (UDF_QUERY_FLAG(sb, UDF_FLAG_GID_IGNORE)) if (UDF_QUERY_FLAG(sb, UDF_FLAG_GID_IGNORE))
seq_puts(seq, ",gid=ignore"); seq_puts(seq, ",gid=ignore");
if (UDF_QUERY_FLAG(sb, UDF_FLAG_UID_SET)) if (UDF_QUERY_FLAG(sb, UDF_FLAG_UID_SET))
seq_printf(seq, ",uid=%u", sbi->s_uid); seq_printf(seq, ",uid=%u", from_kuid(&init_user_ns, sbi->s_uid));
if (UDF_QUERY_FLAG(sb, UDF_FLAG_GID_SET)) if (UDF_QUERY_FLAG(sb, UDF_FLAG_GID_SET))
seq_printf(seq, ",gid=%u", sbi->s_gid); seq_printf(seq, ",gid=%u", from_kgid(&init_user_ns, sbi->s_gid));
if (sbi->s_umask != 0) if (sbi->s_umask != 0)
seq_printf(seq, ",umask=%ho", sbi->s_umask); seq_printf(seq, ",umask=%ho", sbi->s_umask);
if (sbi->s_fmode != UDF_INVALID_MODE) if (sbi->s_fmode != UDF_INVALID_MODE)
...@@ -516,13 +516,17 @@ static int udf_parse_options(char *options, struct udf_options *uopt, ...@@ -516,13 +516,17 @@ static int udf_parse_options(char *options, struct udf_options *uopt,
case Opt_gid: case Opt_gid:
if (match_int(args, &option)) if (match_int(args, &option))
return 0; return 0;
uopt->gid = option; uopt->gid = make_kgid(current_user_ns(), option);
if (!gid_valid(uopt->gid))
return 0;
uopt->flags |= (1 << UDF_FLAG_GID_SET); uopt->flags |= (1 << UDF_FLAG_GID_SET);
break; break;
case Opt_uid: case Opt_uid:
if (match_int(args, &option)) if (match_int(args, &option))
return 0; return 0;
uopt->uid = option; uopt->uid = make_kuid(current_user_ns(), option);
if (!uid_valid(uopt->uid))
return 0;
uopt->flags |= (1 << UDF_FLAG_UID_SET); uopt->flags |= (1 << UDF_FLAG_UID_SET);
break; break;
case Opt_umask: case Opt_umask:
...@@ -1931,8 +1935,8 @@ static int udf_fill_super(struct super_block *sb, void *options, int silent) ...@@ -1931,8 +1935,8 @@ static int udf_fill_super(struct super_block *sb, void *options, int silent)
struct udf_sb_info *sbi; struct udf_sb_info *sbi;
uopt.flags = (1 << UDF_FLAG_USE_AD_IN_ICB) | (1 << UDF_FLAG_STRICT); uopt.flags = (1 << UDF_FLAG_USE_AD_IN_ICB) | (1 << UDF_FLAG_STRICT);
uopt.uid = -1; uopt.uid = INVALID_UID;
uopt.gid = -1; uopt.gid = INVALID_GID;
uopt.umask = 0; uopt.umask = 0;
uopt.fmode = UDF_INVALID_MODE; uopt.fmode = UDF_INVALID_MODE;
uopt.dmode = UDF_INVALID_MODE; uopt.dmode = UDF_INVALID_MODE;
......
...@@ -128,8 +128,8 @@ struct udf_sb_info { ...@@ -128,8 +128,8 @@ struct udf_sb_info {
/* Default permissions */ /* Default permissions */
umode_t s_umask; umode_t s_umask;
gid_t s_gid; kgid_t s_gid;
uid_t s_uid; kuid_t s_uid;
umode_t s_fmode; umode_t s_fmode;
umode_t s_dmode; umode_t s_dmode;
/* Lock protecting consistency of above permission settings */ /* Lock protecting consistency of above permission settings */
......
...@@ -939,7 +939,6 @@ config UIDGID_CONVERTED ...@@ -939,7 +939,6 @@ config UIDGID_CONVERTED
depends on NFSD = n depends on NFSD = n
depends on NFS_FS = n depends on NFS_FS = n
depends on OCFS2_FS = n depends on OCFS2_FS = n
depends on UDF_FS = n
depends on UFS_FS = n depends on UFS_FS = n
depends on XFS_FS = n depends on XFS_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