ANDROID: sdcardfs: Add default_normal option
The default_normal option causes mounts with the gid set to AID_SDCARD_RW to have user specific gids, as in the normal case. Signed-off-by: Daniel Rosenberg <drosen@google.com> Change-Id: I9619b8ac55f41415df943484dc8db1ea986cef6f Bug: 64672411
This commit is contained in:
parent
95c3511a98
commit
ae426831ef
4 changed files with 19 additions and 6 deletions
|
@ -648,7 +648,7 @@ static int sdcardfs_permission(struct vfsmount *mnt, struct inode *inode, int ma
|
||||||
*/
|
*/
|
||||||
copy_attrs(&tmp, inode);
|
copy_attrs(&tmp, inode);
|
||||||
tmp.i_uid = make_kuid(&init_user_ns, top->d_uid);
|
tmp.i_uid = make_kuid(&init_user_ns, top->d_uid);
|
||||||
tmp.i_gid = make_kgid(&init_user_ns, get_gid(mnt, top));
|
tmp.i_gid = make_kgid(&init_user_ns, get_gid(mnt, inode->i_sb, top));
|
||||||
tmp.i_mode = (inode->i_mode & S_IFMT)
|
tmp.i_mode = (inode->i_mode & S_IFMT)
|
||||||
| get_mode(mnt, SDCARDFS_I(inode), top);
|
| get_mode(mnt, SDCARDFS_I(inode), top);
|
||||||
data_put(top);
|
data_put(top);
|
||||||
|
@ -727,7 +727,7 @@ static int sdcardfs_setattr(struct vfsmount *mnt, struct dentry *dentry, struct
|
||||||
*/
|
*/
|
||||||
copy_attrs(&tmp, inode);
|
copy_attrs(&tmp, inode);
|
||||||
tmp.i_uid = make_kuid(&init_user_ns, top->d_uid);
|
tmp.i_uid = make_kuid(&init_user_ns, top->d_uid);
|
||||||
tmp.i_gid = make_kgid(&init_user_ns, get_gid(mnt, top));
|
tmp.i_gid = make_kgid(&init_user_ns, get_gid(mnt, dentry->d_sb, top));
|
||||||
tmp.i_mode = (inode->i_mode & S_IFMT)
|
tmp.i_mode = (inode->i_mode & S_IFMT)
|
||||||
| get_mode(mnt, SDCARDFS_I(inode), top);
|
| get_mode(mnt, SDCARDFS_I(inode), top);
|
||||||
tmp.i_size = i_size_read(inode);
|
tmp.i_size = i_size_read(inode);
|
||||||
|
@ -829,6 +829,7 @@ static int sdcardfs_fillattr(struct vfsmount *mnt,
|
||||||
{
|
{
|
||||||
struct sdcardfs_inode_info *info = SDCARDFS_I(inode);
|
struct sdcardfs_inode_info *info = SDCARDFS_I(inode);
|
||||||
struct sdcardfs_inode_data *top = top_data_get(info);
|
struct sdcardfs_inode_data *top = top_data_get(info);
|
||||||
|
struct super_block *sb = inode->i_sb;
|
||||||
|
|
||||||
if (!top)
|
if (!top)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
@ -838,7 +839,7 @@ static int sdcardfs_fillattr(struct vfsmount *mnt,
|
||||||
stat->mode = (inode->i_mode & S_IFMT) | get_mode(mnt, info, top);
|
stat->mode = (inode->i_mode & S_IFMT) | get_mode(mnt, info, top);
|
||||||
stat->nlink = inode->i_nlink;
|
stat->nlink = inode->i_nlink;
|
||||||
stat->uid = make_kuid(&init_user_ns, top->d_uid);
|
stat->uid = make_kuid(&init_user_ns, top->d_uid);
|
||||||
stat->gid = make_kgid(&init_user_ns, get_gid(mnt, top));
|
stat->gid = make_kgid(&init_user_ns, get_gid(mnt, sb, top));
|
||||||
stat->rdev = inode->i_rdev;
|
stat->rdev = inode->i_rdev;
|
||||||
stat->size = i_size_read(inode);
|
stat->size = i_size_read(inode);
|
||||||
stat->atime = inode->i_atime;
|
stat->atime = inode->i_atime;
|
||||||
|
|
|
@ -33,6 +33,7 @@ enum {
|
||||||
Opt_userid,
|
Opt_userid,
|
||||||
Opt_reserved_mb,
|
Opt_reserved_mb,
|
||||||
Opt_gid_derivation,
|
Opt_gid_derivation,
|
||||||
|
Opt_default_normal,
|
||||||
Opt_err,
|
Opt_err,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -45,6 +46,7 @@ static const match_table_t sdcardfs_tokens = {
|
||||||
{Opt_userid, "userid=%d"},
|
{Opt_userid, "userid=%d"},
|
||||||
{Opt_multiuser, "multiuser"},
|
{Opt_multiuser, "multiuser"},
|
||||||
{Opt_gid_derivation, "derive_gid"},
|
{Opt_gid_derivation, "derive_gid"},
|
||||||
|
{Opt_default_normal, "default_normal"},
|
||||||
{Opt_reserved_mb, "reserved_mb=%u"},
|
{Opt_reserved_mb, "reserved_mb=%u"},
|
||||||
{Opt_err, NULL}
|
{Opt_err, NULL}
|
||||||
};
|
};
|
||||||
|
@ -68,6 +70,7 @@ static int parse_options(struct super_block *sb, char *options, int silent,
|
||||||
opts->reserved_mb = 0;
|
opts->reserved_mb = 0;
|
||||||
/* by default, gid derivation is off */
|
/* by default, gid derivation is off */
|
||||||
opts->gid_derivation = false;
|
opts->gid_derivation = false;
|
||||||
|
opts->default_normal = false;
|
||||||
|
|
||||||
*debug = 0;
|
*debug = 0;
|
||||||
|
|
||||||
|
@ -122,6 +125,9 @@ static int parse_options(struct super_block *sb, char *options, int silent,
|
||||||
case Opt_gid_derivation:
|
case Opt_gid_derivation:
|
||||||
opts->gid_derivation = true;
|
opts->gid_derivation = true;
|
||||||
break;
|
break;
|
||||||
|
case Opt_default_normal:
|
||||||
|
opts->default_normal = true;
|
||||||
|
break;
|
||||||
/* unknown option */
|
/* unknown option */
|
||||||
default:
|
default:
|
||||||
if (!silent)
|
if (!silent)
|
||||||
|
@ -175,6 +181,7 @@ int parse_options_remount(struct super_block *sb, char *options, int silent,
|
||||||
return 0;
|
return 0;
|
||||||
vfsopts->mask = option;
|
vfsopts->mask = option;
|
||||||
break;
|
break;
|
||||||
|
case Opt_default_normal:
|
||||||
case Opt_multiuser:
|
case Opt_multiuser:
|
||||||
case Opt_userid:
|
case Opt_userid:
|
||||||
case Opt_fsuid:
|
case Opt_fsuid:
|
||||||
|
|
|
@ -220,6 +220,7 @@ struct sdcardfs_mount_options {
|
||||||
userid_t fs_user_id;
|
userid_t fs_user_id;
|
||||||
bool multiuser;
|
bool multiuser;
|
||||||
bool gid_derivation;
|
bool gid_derivation;
|
||||||
|
bool default_normal;
|
||||||
unsigned int reserved_mb;
|
unsigned int reserved_mb;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -413,11 +414,13 @@ static inline void set_top(struct sdcardfs_inode_info *info,
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline int get_gid(struct vfsmount *mnt,
|
static inline int get_gid(struct vfsmount *mnt,
|
||||||
|
struct super_block *sb,
|
||||||
struct sdcardfs_inode_data *data)
|
struct sdcardfs_inode_data *data)
|
||||||
{
|
{
|
||||||
struct sdcardfs_vfsmount_options *opts = mnt->data;
|
struct sdcardfs_vfsmount_options *vfsopts = mnt->data;
|
||||||
|
struct sdcardfs_sb_info *sbi = SDCARDFS_SB(sb);
|
||||||
|
|
||||||
if (opts->gid == AID_SDCARD_RW)
|
if (vfsopts->gid == AID_SDCARD_RW && !sbi->options.default_normal)
|
||||||
/* As an optimization, certain trusted system components only run
|
/* As an optimization, certain trusted system components only run
|
||||||
* as owner but operate across all users. Since we're now handing
|
* as owner but operate across all users. Since we're now handing
|
||||||
* out the sdcard_rw GID only to trusted apps, we're okay relaxing
|
* out the sdcard_rw GID only to trusted apps, we're okay relaxing
|
||||||
|
@ -426,7 +429,7 @@ static inline int get_gid(struct vfsmount *mnt,
|
||||||
*/
|
*/
|
||||||
return AID_SDCARD_RW;
|
return AID_SDCARD_RW;
|
||||||
else
|
else
|
||||||
return multiuser_get_uid(data->userid, opts->gid);
|
return multiuser_get_uid(data->userid, vfsopts->gid);
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline int get_mode(struct vfsmount *mnt,
|
static inline int get_mode(struct vfsmount *mnt,
|
||||||
|
|
|
@ -304,6 +304,8 @@ static int sdcardfs_show_options(struct vfsmount *mnt, struct seq_file *m,
|
||||||
seq_printf(m, ",userid=%u", opts->fs_user_id);
|
seq_printf(m, ",userid=%u", opts->fs_user_id);
|
||||||
if (opts->gid_derivation)
|
if (opts->gid_derivation)
|
||||||
seq_puts(m, ",derive_gid");
|
seq_puts(m, ",derive_gid");
|
||||||
|
if (opts->default_normal)
|
||||||
|
seq_puts(m, ",default_normal");
|
||||||
if (opts->reserved_mb != 0)
|
if (opts->reserved_mb != 0)
|
||||||
seq_printf(m, ",reserved=%uMB", opts->reserved_mb);
|
seq_printf(m, ",reserved=%uMB", opts->reserved_mb);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue