mirror of
https://github.com/hardkernel/linux.git
synced 2026-06-10 04:48:04 +09:00
ANDROID: sdcardfs: Fix formatting
This fixes various spacing and bracket related issues pointed out by checkpatch. Signed-off-by: Daniel Rosenberg <drosen@google.com> Bug: 35331000 Change-Id: I6e248833a7a04e3899f3ae9462d765cfcaa70c96
This commit is contained in:
committed by
Amit Pundir
parent
0084d2b319
commit
8fed3ac5ac
@@ -46,7 +46,8 @@ static int sdcardfs_d_revalidate(struct dentry *dentry, unsigned int flags)
|
||||
spin_unlock(&dentry->d_lock);
|
||||
|
||||
/* check uninitialized obb_dentry and
|
||||
* whether the base obbpath has been changed or not */
|
||||
* whether the base obbpath has been changed or not
|
||||
*/
|
||||
if (is_obbpath_invalid(dentry)) {
|
||||
d_drop(dentry);
|
||||
return 0;
|
||||
@@ -106,12 +107,10 @@ out:
|
||||
static void sdcardfs_d_release(struct dentry *dentry)
|
||||
{
|
||||
/* release and reset the lower paths */
|
||||
if(has_graft_path(dentry)) {
|
||||
if (has_graft_path(dentry))
|
||||
sdcardfs_put_reset_orig_path(dentry);
|
||||
}
|
||||
sdcardfs_put_reset_lower_path(dentry);
|
||||
free_dentry_private_data(dentry);
|
||||
return;
|
||||
}
|
||||
|
||||
static int sdcardfs_hash_ci(const struct dentry *dentry,
|
||||
@@ -168,14 +167,16 @@ static int sdcardfs_cmp_ci(const struct dentry *parent,
|
||||
return 1;
|
||||
}
|
||||
|
||||
static void sdcardfs_canonical_path(const struct path *path, struct path *actual_path) {
|
||||
static void sdcardfs_canonical_path(const struct path *path,
|
||||
struct path *actual_path)
|
||||
{
|
||||
sdcardfs_get_real_lower(path->dentry, actual_path);
|
||||
}
|
||||
|
||||
const struct dentry_operations sdcardfs_ci_dops = {
|
||||
.d_revalidate = sdcardfs_d_revalidate,
|
||||
.d_release = sdcardfs_d_release,
|
||||
.d_hash = sdcardfs_hash_ci,
|
||||
.d_hash = sdcardfs_hash_ci,
|
||||
.d_compare = sdcardfs_cmp_ci,
|
||||
.d_canonical_path = sdcardfs_canonical_path,
|
||||
};
|
||||
|
||||
@@ -37,7 +37,8 @@ static void inherit_derived_state(struct inode *parent, struct inode *child)
|
||||
|
||||
/* helper function for derived state */
|
||||
void setup_derived_state(struct inode *inode, perm_t perm, userid_t userid,
|
||||
uid_t uid, bool under_android, struct inode *top)
|
||||
uid_t uid, bool under_android,
|
||||
struct inode *top)
|
||||
{
|
||||
struct sdcardfs_inode_info *info = SDCARDFS_I(inode);
|
||||
|
||||
@@ -50,11 +51,14 @@ void setup_derived_state(struct inode *inode, perm_t perm, userid_t userid,
|
||||
set_top(info, top);
|
||||
}
|
||||
|
||||
/* While renaming, there is a point where we want the path from dentry, but the name from newdentry */
|
||||
void get_derived_permission_new(struct dentry *parent, struct dentry *dentry, const struct qstr *name)
|
||||
/* While renaming, there is a point where we want the path from dentry,
|
||||
* but the name from newdentry
|
||||
*/
|
||||
void get_derived_permission_new(struct dentry *parent, struct dentry *dentry,
|
||||
const struct qstr *name)
|
||||
{
|
||||
struct sdcardfs_inode_info *info = SDCARDFS_I(d_inode(dentry));
|
||||
struct sdcardfs_inode_info *parent_info= SDCARDFS_I(d_inode(parent));
|
||||
struct sdcardfs_inode_info *parent_info = SDCARDFS_I(d_inode(parent));
|
||||
appid_t appid;
|
||||
struct qstr q_Android = QSTR_LITERAL("Android");
|
||||
struct qstr q_data = QSTR_LITERAL("data");
|
||||
@@ -77,58 +81,57 @@ void get_derived_permission_new(struct dentry *parent, struct dentry *dentry, co
|
||||
return;
|
||||
/* Derive custom permissions based on parent and current node */
|
||||
switch (parent_info->perm) {
|
||||
case PERM_INHERIT:
|
||||
case PERM_ANDROID_PACKAGE_CACHE:
|
||||
/* Already inherited above */
|
||||
break;
|
||||
case PERM_PRE_ROOT:
|
||||
/* Legacy internal layout places users at top level */
|
||||
info->perm = PERM_ROOT;
|
||||
info->userid = simple_strtoul(name->name, NULL, 10);
|
||||
case PERM_INHERIT:
|
||||
case PERM_ANDROID_PACKAGE_CACHE:
|
||||
/* Already inherited above */
|
||||
break;
|
||||
case PERM_PRE_ROOT:
|
||||
/* Legacy internal layout places users at top level */
|
||||
info->perm = PERM_ROOT;
|
||||
info->userid = simple_strtoul(name->name, NULL, 10);
|
||||
set_top(info, &info->vfs_inode);
|
||||
break;
|
||||
case PERM_ROOT:
|
||||
/* Assume masked off by default. */
|
||||
if (qstr_case_eq(name, &q_Android)) {
|
||||
/* App-specific directories inside; let anyone traverse */
|
||||
info->perm = PERM_ANDROID;
|
||||
info->under_android = true;
|
||||
set_top(info, &info->vfs_inode);
|
||||
break;
|
||||
case PERM_ROOT:
|
||||
/* Assume masked off by default. */
|
||||
if (qstr_case_eq(name, &q_Android)) {
|
||||
/* App-specific directories inside; let anyone traverse */
|
||||
info->perm = PERM_ANDROID;
|
||||
info->under_android = true;
|
||||
set_top(info, &info->vfs_inode);
|
||||
}
|
||||
break;
|
||||
case PERM_ANDROID:
|
||||
if (qstr_case_eq(name, &q_data)) {
|
||||
/* App-specific directories inside; let anyone traverse */
|
||||
info->perm = PERM_ANDROID_DATA;
|
||||
set_top(info, &info->vfs_inode);
|
||||
} else if (qstr_case_eq(name, &q_obb)) {
|
||||
/* App-specific directories inside; let anyone traverse */
|
||||
info->perm = PERM_ANDROID_OBB;
|
||||
info->under_obb = true;
|
||||
set_top(info, &info->vfs_inode);
|
||||
/* Single OBB directory is always shared */
|
||||
} else if (qstr_case_eq(name, &q_media)) {
|
||||
/* App-specific directories inside; let anyone traverse */
|
||||
info->perm = PERM_ANDROID_MEDIA;
|
||||
set_top(info, &info->vfs_inode);
|
||||
}
|
||||
break;
|
||||
case PERM_ANDROID_OBB:
|
||||
case PERM_ANDROID_DATA:
|
||||
case PERM_ANDROID_MEDIA:
|
||||
info->perm = PERM_ANDROID_PACKAGE;
|
||||
appid = get_appid(name->name);
|
||||
if (appid != 0 && !is_excluded(name->name, parent_info->userid)) {
|
||||
info->d_uid = multiuser_get_uid(parent_info->userid, appid);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case PERM_ANDROID:
|
||||
if (qstr_case_eq(name, &q_data)) {
|
||||
/* App-specific directories inside; let anyone traverse */
|
||||
info->perm = PERM_ANDROID_DATA;
|
||||
set_top(info, &info->vfs_inode);
|
||||
break;
|
||||
case PERM_ANDROID_PACKAGE:
|
||||
if (qstr_case_eq(name, &q_cache)) {
|
||||
info->perm = PERM_ANDROID_PACKAGE_CACHE;
|
||||
info->under_cache = true;
|
||||
}
|
||||
break;
|
||||
} else if (qstr_case_eq(name, &q_obb)) {
|
||||
/* App-specific directories inside; let anyone traverse */
|
||||
info->perm = PERM_ANDROID_OBB;
|
||||
info->under_obb = true;
|
||||
set_top(info, &info->vfs_inode);
|
||||
/* Single OBB directory is always shared */
|
||||
} else if (qstr_case_eq(name, &q_media)) {
|
||||
/* App-specific directories inside; let anyone traverse */
|
||||
info->perm = PERM_ANDROID_MEDIA;
|
||||
set_top(info, &info->vfs_inode);
|
||||
}
|
||||
break;
|
||||
case PERM_ANDROID_OBB:
|
||||
case PERM_ANDROID_DATA:
|
||||
case PERM_ANDROID_MEDIA:
|
||||
info->perm = PERM_ANDROID_PACKAGE;
|
||||
appid = get_appid(name->name);
|
||||
if (appid != 0 && !is_excluded(name->name, parent_info->userid))
|
||||
info->d_uid = multiuser_get_uid(parent_info->userid, appid);
|
||||
set_top(info, &info->vfs_inode);
|
||||
break;
|
||||
case PERM_ANDROID_PACKAGE:
|
||||
if (qstr_case_eq(name, &q_cache)) {
|
||||
info->perm = PERM_ANDROID_PACKAGE_CACHE;
|
||||
info->under_cache = true;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -137,7 +140,8 @@ void get_derived_permission(struct dentry *parent, struct dentry *dentry)
|
||||
get_derived_permission_new(parent, dentry, &dentry->d_name);
|
||||
}
|
||||
|
||||
static appid_t get_type(const char *name) {
|
||||
static appid_t get_type(const char *name)
|
||||
{
|
||||
const char *ext = strrchr(name, '.');
|
||||
appid_t id;
|
||||
|
||||
@@ -149,7 +153,8 @@ static appid_t get_type(const char *name) {
|
||||
return AID_MEDIA_RW;
|
||||
}
|
||||
|
||||
void fixup_lower_ownership(struct dentry* dentry, const char *name) {
|
||||
void fixup_lower_ownership(struct dentry *dentry, const char *name)
|
||||
{
|
||||
struct path path;
|
||||
struct inode *inode;
|
||||
struct inode *delegated_inode = NULL;
|
||||
@@ -175,49 +180,49 @@ void fixup_lower_ownership(struct dentry* dentry, const char *name) {
|
||||
}
|
||||
|
||||
switch (perm) {
|
||||
case PERM_ROOT:
|
||||
case PERM_ANDROID:
|
||||
case PERM_ANDROID_DATA:
|
||||
case PERM_ANDROID_MEDIA:
|
||||
case PERM_ANDROID_PACKAGE:
|
||||
case PERM_ANDROID_PACKAGE_CACHE:
|
||||
uid = multiuser_get_uid(info->userid, uid);
|
||||
break;
|
||||
case PERM_ANDROID_OBB:
|
||||
uid = AID_MEDIA_OBB;
|
||||
break;
|
||||
case PERM_PRE_ROOT:
|
||||
default:
|
||||
break;
|
||||
case PERM_ROOT:
|
||||
case PERM_ANDROID:
|
||||
case PERM_ANDROID_DATA:
|
||||
case PERM_ANDROID_MEDIA:
|
||||
case PERM_ANDROID_PACKAGE:
|
||||
case PERM_ANDROID_PACKAGE_CACHE:
|
||||
uid = multiuser_get_uid(info->userid, uid);
|
||||
break;
|
||||
case PERM_ANDROID_OBB:
|
||||
uid = AID_MEDIA_OBB;
|
||||
break;
|
||||
case PERM_PRE_ROOT:
|
||||
default:
|
||||
break;
|
||||
}
|
||||
switch (perm) {
|
||||
case PERM_ROOT:
|
||||
case PERM_ANDROID:
|
||||
case PERM_ANDROID_DATA:
|
||||
case PERM_ANDROID_MEDIA:
|
||||
if (S_ISDIR(d_inode(dentry)->i_mode))
|
||||
gid = multiuser_get_uid(info->userid, AID_MEDIA_RW);
|
||||
else
|
||||
gid = multiuser_get_uid(info->userid, get_type(name));
|
||||
break;
|
||||
case PERM_ANDROID_OBB:
|
||||
gid = AID_MEDIA_OBB;
|
||||
break;
|
||||
case PERM_ANDROID_PACKAGE:
|
||||
if (info->d_uid != 0)
|
||||
gid = multiuser_get_ext_gid(info->d_uid);
|
||||
else
|
||||
gid = multiuser_get_uid(info->userid, uid);
|
||||
break;
|
||||
case PERM_ANDROID_PACKAGE_CACHE:
|
||||
if (info->d_uid != 0)
|
||||
gid = multiuser_get_cache_gid(info->d_uid);
|
||||
else
|
||||
gid = multiuser_get_uid(info->userid, uid);
|
||||
break;
|
||||
case PERM_PRE_ROOT:
|
||||
default:
|
||||
break;
|
||||
case PERM_ROOT:
|
||||
case PERM_ANDROID:
|
||||
case PERM_ANDROID_DATA:
|
||||
case PERM_ANDROID_MEDIA:
|
||||
if (S_ISDIR(d_inode(dentry)->i_mode))
|
||||
gid = multiuser_get_uid(info->userid, AID_MEDIA_RW);
|
||||
else
|
||||
gid = multiuser_get_uid(info->userid, get_type(name));
|
||||
break;
|
||||
case PERM_ANDROID_OBB:
|
||||
gid = AID_MEDIA_OBB;
|
||||
break;
|
||||
case PERM_ANDROID_PACKAGE:
|
||||
if (info->d_uid != 0)
|
||||
gid = multiuser_get_ext_gid(info->d_uid);
|
||||
else
|
||||
gid = multiuser_get_uid(info->userid, uid);
|
||||
break;
|
||||
case PERM_ANDROID_PACKAGE_CACHE:
|
||||
if (info->d_uid != 0)
|
||||
gid = multiuser_get_cache_gid(info->d_uid);
|
||||
else
|
||||
gid = multiuser_get_uid(info->userid, uid);
|
||||
break;
|
||||
case PERM_PRE_ROOT:
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
sdcardfs_get_lower_path(dentry, &path);
|
||||
@@ -246,7 +251,8 @@ retry_deleg:
|
||||
sdcardfs_put_lower_path(dentry, &path);
|
||||
}
|
||||
|
||||
static int descendant_may_need_fixup(struct sdcardfs_inode_info *info, struct limit_search *limit) {
|
||||
static int descendant_may_need_fixup(struct sdcardfs_inode_info *info, struct limit_search *limit)
|
||||
{
|
||||
if (info->perm == PERM_ROOT)
|
||||
return (limit->flags & BY_USERID)?info->userid == limit->userid:1;
|
||||
if (info->perm == PERM_PRE_ROOT || info->perm == PERM_ANDROID)
|
||||
@@ -254,7 +260,8 @@ static int descendant_may_need_fixup(struct sdcardfs_inode_info *info, struct li
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int needs_fixup(perm_t perm) {
|
||||
static int needs_fixup(perm_t perm)
|
||||
{
|
||||
if (perm == PERM_ANDROID_DATA || perm == PERM_ANDROID_OBB
|
||||
|| perm == PERM_ANDROID_MEDIA)
|
||||
return 1;
|
||||
@@ -292,9 +299,9 @@ static void __fixup_perms_recursive(struct dentry *dentry, struct limit_search *
|
||||
}
|
||||
spin_unlock(&child->d_lock);
|
||||
}
|
||||
} else if (descendant_may_need_fixup(info, limit)) {
|
||||
} else if (descendant_may_need_fixup(info, limit)) {
|
||||
list_for_each_entry(child, &dentry->d_subdirs, d_child) {
|
||||
__fixup_perms_recursive(child, limit, depth + 1);
|
||||
__fixup_perms_recursive(child, limit, depth + 1);
|
||||
}
|
||||
}
|
||||
spin_unlock(&dentry->d_lock);
|
||||
@@ -310,7 +317,7 @@ inline void update_derived_permission_lock(struct dentry *dentry)
|
||||
{
|
||||
struct dentry *parent;
|
||||
|
||||
if(!dentry || !d_inode(dentry)) {
|
||||
if (!dentry || !d_inode(dentry)) {
|
||||
printk(KERN_ERR "sdcardfs: %s: invalid dentry\n", __func__);
|
||||
return;
|
||||
}
|
||||
@@ -318,11 +325,11 @@ inline void update_derived_permission_lock(struct dentry *dentry)
|
||||
* 1. need to check whether the dentry is updated or not
|
||||
* 2. remove the root dentry update
|
||||
*/
|
||||
if(IS_ROOT(dentry)) {
|
||||
if (IS_ROOT(dentry)) {
|
||||
//setup_default_pre_root_state(d_inode(dentry));
|
||||
} else {
|
||||
parent = dget_parent(dentry);
|
||||
if(parent) {
|
||||
if (parent) {
|
||||
get_derived_permission(parent, dentry);
|
||||
dput(parent);
|
||||
}
|
||||
@@ -334,15 +341,15 @@ int need_graft_path(struct dentry *dentry)
|
||||
{
|
||||
int ret = 0;
|
||||
struct dentry *parent = dget_parent(dentry);
|
||||
struct sdcardfs_inode_info *parent_info= SDCARDFS_I(d_inode(parent));
|
||||
struct sdcardfs_inode_info *parent_info = SDCARDFS_I(d_inode(parent));
|
||||
struct sdcardfs_sb_info *sbi = SDCARDFS_SB(dentry->d_sb);
|
||||
struct qstr obb = QSTR_LITERAL("obb");
|
||||
|
||||
if(parent_info->perm == PERM_ANDROID &&
|
||||
if (parent_info->perm == PERM_ANDROID &&
|
||||
qstr_case_eq(&dentry->d_name, &obb)) {
|
||||
|
||||
/* /Android/obb is the base obbpath of DERIVED_UNIFIED */
|
||||
if(!(sbi->options.multiuser == false
|
||||
if (!(sbi->options.multiuser == false
|
||||
&& parent_info->userid == 0)) {
|
||||
ret = 1;
|
||||
}
|
||||
@@ -362,17 +369,18 @@ int is_obbpath_invalid(struct dentry *dent)
|
||||
|
||||
/* check the base obbpath has been changed.
|
||||
* this routine can check an uninitialized obb dentry as well.
|
||||
* regarding the uninitialized obb, refer to the sdcardfs_mkdir() */
|
||||
* regarding the uninitialized obb, refer to the sdcardfs_mkdir()
|
||||
*/
|
||||
spin_lock(&di->lock);
|
||||
if(di->orig_path.dentry) {
|
||||
if(!di->lower_path.dentry) {
|
||||
if (di->orig_path.dentry) {
|
||||
if (!di->lower_path.dentry) {
|
||||
ret = 1;
|
||||
} else {
|
||||
path_get(&di->lower_path);
|
||||
//lower_parent = lock_parent(lower_path->dentry);
|
||||
|
||||
path_buf = kmalloc(PATH_MAX, GFP_ATOMIC);
|
||||
if(!path_buf) {
|
||||
if (!path_buf) {
|
||||
ret = 1;
|
||||
printk(KERN_ERR "sdcardfs: fail to allocate path_buf in %s.\n", __func__);
|
||||
} else {
|
||||
@@ -399,13 +407,13 @@ int is_base_obbpath(struct dentry *dentry)
|
||||
{
|
||||
int ret = 0;
|
||||
struct dentry *parent = dget_parent(dentry);
|
||||
struct sdcardfs_inode_info *parent_info= SDCARDFS_I(d_inode(parent));
|
||||
struct sdcardfs_inode_info *parent_info = SDCARDFS_I(d_inode(parent));
|
||||
struct sdcardfs_sb_info *sbi = SDCARDFS_SB(dentry->d_sb);
|
||||
struct qstr q_obb = QSTR_LITERAL("obb");
|
||||
|
||||
spin_lock(&SDCARDFS_D(dentry)->lock);
|
||||
if (sbi->options.multiuser) {
|
||||
if(parent_info->perm == PERM_PRE_ROOT &&
|
||||
if (parent_info->perm == PERM_PRE_ROOT &&
|
||||
qstr_case_eq(&dentry->d_name, &q_obb)) {
|
||||
ret = 1;
|
||||
}
|
||||
@@ -420,7 +428,8 @@ int is_base_obbpath(struct dentry *dentry)
|
||||
/* The lower_path will be stored to the dentry's orig_path
|
||||
* and the base obbpath will be copyed to the lower_path variable.
|
||||
* if an error returned, there's no change in the lower_path
|
||||
* returns: -ERRNO if error (0: no error) */
|
||||
* returns: -ERRNO if error (0: no error)
|
||||
*/
|
||||
int setup_obb_dentry(struct dentry *dentry, struct path *lower_path)
|
||||
{
|
||||
int err = 0;
|
||||
@@ -435,7 +444,7 @@ int setup_obb_dentry(struct dentry *dentry, struct path *lower_path)
|
||||
err = kern_path(sbi->obbpath_s,
|
||||
LOOKUP_FOLLOW | LOOKUP_DIRECTORY, &obbpath);
|
||||
|
||||
if(!err) {
|
||||
if (!err) {
|
||||
/* the obbpath base has been found */
|
||||
pathcpy(lower_path, &obbpath);
|
||||
} else {
|
||||
@@ -443,7 +452,8 @@ int setup_obb_dentry(struct dentry *dentry, struct path *lower_path)
|
||||
* setup the lower_path with its orig_path.
|
||||
* but, the current implementation just returns an error
|
||||
* because the sdcard daemon also regards this case as
|
||||
* a lookup fail. */
|
||||
* a lookup fail.
|
||||
*/
|
||||
printk(KERN_INFO "sdcardfs: the sbi->obbpath is not available\n");
|
||||
}
|
||||
return err;
|
||||
|
||||
@@ -216,7 +216,7 @@ static int sdcardfs_open(struct inode *inode, struct file *file)
|
||||
goto out_err;
|
||||
}
|
||||
|
||||
if(!check_caller_access_to_name(d_inode(parent), &dentry->d_name)) {
|
||||
if (!check_caller_access_to_name(d_inode(parent), &dentry->d_name)) {
|
||||
err = -EACCES;
|
||||
goto out_err;
|
||||
}
|
||||
@@ -248,9 +248,8 @@ static int sdcardfs_open(struct inode *inode, struct file *file)
|
||||
|
||||
if (err)
|
||||
kfree(SDCARDFS_F(file));
|
||||
else {
|
||||
else
|
||||
sdcardfs_copy_and_fix_attrs(inode, sdcardfs_lower_inode(inode));
|
||||
}
|
||||
|
||||
out_revert_cred:
|
||||
REVERT_CRED(saved_cred);
|
||||
|
||||
@@ -23,10 +23,10 @@
|
||||
#include <linux/ratelimit.h>
|
||||
|
||||
/* Do not directly use this function. Use OVERRIDE_CRED() instead. */
|
||||
const struct cred * override_fsids(struct sdcardfs_sb_info* sbi, struct sdcardfs_inode_info *info)
|
||||
const struct cred *override_fsids(struct sdcardfs_sb_info *sbi, struct sdcardfs_inode_info *info)
|
||||
{
|
||||
struct cred * cred;
|
||||
const struct cred * old_cred;
|
||||
struct cred *cred;
|
||||
const struct cred *old_cred;
|
||||
uid_t uid;
|
||||
|
||||
cred = prepare_creds();
|
||||
@@ -46,9 +46,9 @@ const struct cred * override_fsids(struct sdcardfs_sb_info* sbi, struct sdcardfs
|
||||
}
|
||||
|
||||
/* Do not directly use this function, use REVERT_CRED() instead. */
|
||||
void revert_fsids(const struct cred * old_cred)
|
||||
void revert_fsids(const struct cred *old_cred)
|
||||
{
|
||||
const struct cred * cur_cred;
|
||||
const struct cred *cur_cred;
|
||||
|
||||
cur_cred = current->cred;
|
||||
revert_creds(old_cred);
|
||||
@@ -67,7 +67,7 @@ static int sdcardfs_create(struct inode *dir, struct dentry *dentry,
|
||||
struct fs_struct *saved_fs;
|
||||
struct fs_struct *copied_fs;
|
||||
|
||||
if(!check_caller_access_to_name(dir, &dentry->d_name)) {
|
||||
if (!check_caller_access_to_name(dir, &dentry->d_name)) {
|
||||
err = -EACCES;
|
||||
goto out_eacces;
|
||||
}
|
||||
@@ -166,7 +166,7 @@ static int sdcardfs_unlink(struct inode *dir, struct dentry *dentry)
|
||||
struct path lower_path;
|
||||
const struct cred *saved_cred = NULL;
|
||||
|
||||
if(!check_caller_access_to_name(dir, &dentry->d_name)) {
|
||||
if (!check_caller_access_to_name(dir, &dentry->d_name)) {
|
||||
err = -EACCES;
|
||||
goto out_eacces;
|
||||
}
|
||||
@@ -240,13 +240,14 @@ out:
|
||||
}
|
||||
#endif
|
||||
|
||||
static int touch(char *abs_path, mode_t mode) {
|
||||
static int touch(char *abs_path, mode_t mode)
|
||||
{
|
||||
struct file *filp = filp_open(abs_path, O_RDWR|O_CREAT|O_EXCL|O_NOFOLLOW, mode);
|
||||
|
||||
if (IS_ERR(filp)) {
|
||||
if (PTR_ERR(filp) == -EEXIST) {
|
||||
return 0;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
printk(KERN_ERR "sdcardfs: failed to open(%s): %ld\n",
|
||||
abs_path, PTR_ERR(filp));
|
||||
return PTR_ERR(filp);
|
||||
@@ -273,7 +274,7 @@ static int sdcardfs_mkdir(struct inode *dir, struct dentry *dentry, umode_t mode
|
||||
struct qstr q_obb = QSTR_LITERAL("obb");
|
||||
struct qstr q_data = QSTR_LITERAL("data");
|
||||
|
||||
if(!check_caller_access_to_name(dir, &dentry->d_name)) {
|
||||
if (!check_caller_access_to_name(dir, &dentry->d_name)) {
|
||||
err = -EACCES;
|
||||
goto out_eacces;
|
||||
}
|
||||
@@ -315,19 +316,21 @@ static int sdcardfs_mkdir(struct inode *dir, struct dentry *dentry, umode_t mode
|
||||
}
|
||||
|
||||
/* if it is a local obb dentry, setup it with the base obbpath */
|
||||
if(need_graft_path(dentry)) {
|
||||
if (need_graft_path(dentry)) {
|
||||
|
||||
err = setup_obb_dentry(dentry, &lower_path);
|
||||
if(err) {
|
||||
if (err) {
|
||||
/* if the sbi->obbpath is not available, the lower_path won't be
|
||||
* changed by setup_obb_dentry() but the lower path is saved to
|
||||
* its orig_path. this dentry will be revalidated later.
|
||||
* but now, the lower_path should be NULL */
|
||||
* but now, the lower_path should be NULL
|
||||
*/
|
||||
sdcardfs_put_reset_lower_path(dentry);
|
||||
|
||||
/* the newly created lower path which saved to its orig_path or
|
||||
* the lower_path is the base obbpath.
|
||||
* therefore, an additional path_get is required */
|
||||
* therefore, an additional path_get is required
|
||||
*/
|
||||
path_get(&lower_path);
|
||||
} else
|
||||
make_nomedia_in_obb = 1;
|
||||
@@ -382,7 +385,7 @@ static int sdcardfs_rmdir(struct inode *dir, struct dentry *dentry)
|
||||
struct path lower_path;
|
||||
const struct cred *saved_cred = NULL;
|
||||
|
||||
if(!check_caller_access_to_name(dir, &dentry->d_name)) {
|
||||
if (!check_caller_access_to_name(dir, &dentry->d_name)) {
|
||||
err = -EACCES;
|
||||
goto out_eacces;
|
||||
}
|
||||
@@ -391,7 +394,8 @@ static int sdcardfs_rmdir(struct inode *dir, struct dentry *dentry)
|
||||
OVERRIDE_CRED(SDCARDFS_SB(dir->i_sb), saved_cred, SDCARDFS_I(dir));
|
||||
|
||||
/* sdcardfs_get_real_lower(): in case of remove an user's obb dentry
|
||||
* the dentry on the original path should be deleted. */
|
||||
* the dentry on the original path should be deleted.
|
||||
*/
|
||||
sdcardfs_get_real_lower(dentry, &lower_path);
|
||||
|
||||
lower_dentry = lower_path.dentry;
|
||||
@@ -467,7 +471,7 @@ static int sdcardfs_rename(struct inode *old_dir, struct dentry *old_dentry,
|
||||
struct path lower_old_path, lower_new_path;
|
||||
const struct cred *saved_cred = NULL;
|
||||
|
||||
if(!check_caller_access_to_name(old_dir, &old_dentry->d_name) ||
|
||||
if (!check_caller_access_to_name(old_dir, &old_dentry->d_name) ||
|
||||
!check_caller_access_to_name(new_dir, &new_dentry->d_name)) {
|
||||
err = -EACCES;
|
||||
goto out_eacces;
|
||||
@@ -656,6 +660,7 @@ static int sdcardfs_permission(struct vfsmount *mnt, struct inode *inode, int ma
|
||||
* we check it with AID_MEDIA_RW permission
|
||||
*/
|
||||
struct inode *lower_inode;
|
||||
|
||||
OVERRIDE_CRED(SDCARDFS_SB(inode->sb));
|
||||
|
||||
lower_inode = sdcardfs_lower_inode(inode);
|
||||
@@ -724,7 +729,8 @@ static int sdcardfs_setattr(struct vfsmount *mnt, struct dentry *dentry, struct
|
||||
/* prepare our own lower struct iattr (with the lower file) */
|
||||
memcpy(&lower_ia, ia, sizeof(lower_ia));
|
||||
/* Allow touch updating timestamps. A previous permission check ensures
|
||||
* we have write access. Changes to mode, owner, and group are ignored*/
|
||||
* we have write access. Changes to mode, owner, and group are ignored
|
||||
*/
|
||||
ia->ia_valid |= ATTR_FORCE;
|
||||
err = inode_change_ok(&tmp, ia);
|
||||
|
||||
@@ -810,10 +816,12 @@ out_err:
|
||||
return err;
|
||||
}
|
||||
|
||||
static int sdcardfs_fillattr(struct vfsmount *mnt, struct inode *inode, struct kstat *stat)
|
||||
static int sdcardfs_fillattr(struct vfsmount *mnt,
|
||||
struct inode *inode, struct kstat *stat)
|
||||
{
|
||||
struct sdcardfs_inode_info *info = SDCARDFS_I(inode);
|
||||
struct inode *top = grab_top(info);
|
||||
|
||||
if (!top)
|
||||
return -EINVAL;
|
||||
|
||||
@@ -843,7 +851,7 @@ static int sdcardfs_getattr(struct vfsmount *mnt, struct dentry *dentry,
|
||||
int err;
|
||||
|
||||
parent = dget_parent(dentry);
|
||||
if(!check_caller_access_to_name(d_inode(parent), &dentry->d_name)) {
|
||||
if (!check_caller_access_to_name(d_inode(parent), &dentry->d_name)) {
|
||||
dput(parent);
|
||||
return -EACCES;
|
||||
}
|
||||
|
||||
@@ -73,6 +73,7 @@ static int sdcardfs_inode_test(struct inode *inode, void *candidate_data/*void *
|
||||
{
|
||||
struct inode *current_lower_inode = sdcardfs_lower_inode(inode);
|
||||
userid_t current_userid = SDCARDFS_I(inode)->userid;
|
||||
|
||||
if (current_lower_inode == ((struct inode_data *)candidate_data)->lower_inode &&
|
||||
current_userid == ((struct inode_data *)candidate_data)->id)
|
||||
return 1; /* found a match */
|
||||
@@ -102,7 +103,7 @@ struct inode *sdcardfs_iget(struct super_block *sb, struct inode *lower_inode, u
|
||||
* instead.
|
||||
*/
|
||||
lower_inode->i_ino, /* hashval */
|
||||
sdcardfs_inode_test, /* inode comparison function */
|
||||
sdcardfs_inode_test, /* inode comparison function */
|
||||
sdcardfs_inode_set, /* inode init function */
|
||||
&data); /* data passed to test+set fxns */
|
||||
if (!inode) {
|
||||
@@ -213,8 +214,8 @@ struct sdcardfs_name_data {
|
||||
bool found;
|
||||
};
|
||||
|
||||
static int sdcardfs_name_match(struct dir_context *ctx, const char *name, int namelen,
|
||||
loff_t offset, u64 ino, unsigned int d_type)
|
||||
static int sdcardfs_name_match(struct dir_context *ctx, const char *name,
|
||||
int namelen, loff_t offset, u64 ino, unsigned int d_type)
|
||||
{
|
||||
struct sdcardfs_name_data *buf = container_of(ctx, struct sdcardfs_name_data, ctx);
|
||||
struct qstr candidate = QSTR_INIT(name, namelen);
|
||||
@@ -303,23 +304,26 @@ put_name:
|
||||
if (!err) {
|
||||
/* check if the dentry is an obb dentry
|
||||
* if true, the lower_inode must be replaced with
|
||||
* the inode of the graft path */
|
||||
* the inode of the graft path
|
||||
*/
|
||||
|
||||
if(need_graft_path(dentry)) {
|
||||
if (need_graft_path(dentry)) {
|
||||
|
||||
/* setup_obb_dentry()
|
||||
* The lower_path will be stored to the dentry's orig_path
|
||||
* The lower_path will be stored to the dentry's orig_path
|
||||
* and the base obbpath will be copyed to the lower_path variable.
|
||||
* if an error returned, there's no change in the lower_path
|
||||
* returns: -ERRNO if error (0: no error) */
|
||||
* returns: -ERRNO if error (0: no error)
|
||||
*/
|
||||
err = setup_obb_dentry(dentry, &lower_path);
|
||||
|
||||
if(err) {
|
||||
if (err) {
|
||||
/* if the sbi->obbpath is not available, we can optionally
|
||||
* setup the lower_path with its orig_path.
|
||||
* but, the current implementation just returns an error
|
||||
* because the sdcard daemon also regards this case as
|
||||
* a lookup fail. */
|
||||
* a lookup fail.
|
||||
*/
|
||||
printk(KERN_INFO "sdcardfs: base obbpath is not available\n");
|
||||
sdcardfs_put_reset_orig_path(dentry);
|
||||
goto out;
|
||||
@@ -374,9 +378,9 @@ out:
|
||||
|
||||
/*
|
||||
* On success:
|
||||
* fills dentry object appropriate values and returns NULL.
|
||||
* fills dentry object appropriate values and returns NULL.
|
||||
* On fail (== error)
|
||||
* returns error ptr
|
||||
* returns error ptr
|
||||
*
|
||||
* @dir : Parent inode. It is locked (dir->i_mutex)
|
||||
* @dentry : Target dentry to lookup. we should set each of fields.
|
||||
@@ -393,10 +397,10 @@ struct dentry *sdcardfs_lookup(struct inode *dir, struct dentry *dentry,
|
||||
|
||||
parent = dget_parent(dentry);
|
||||
|
||||
if(!check_caller_access_to_name(d_inode(parent), &dentry->d_name)) {
|
||||
if (!check_caller_access_to_name(d_inode(parent), &dentry->d_name)) {
|
||||
ret = ERR_PTR(-EACCES);
|
||||
goto out_err;
|
||||
}
|
||||
}
|
||||
|
||||
/* save current_cred and override it */
|
||||
OVERRIDE_CRED_PTR(SDCARDFS_SB(dir->i_sb), saved_cred, SDCARDFS_I(dir));
|
||||
@@ -412,9 +416,7 @@ struct dentry *sdcardfs_lookup(struct inode *dir, struct dentry *dentry,
|
||||
|
||||
ret = __sdcardfs_lookup(dentry, flags, &lower_parent_path, SDCARDFS_I(dir)->userid);
|
||||
if (IS_ERR(ret))
|
||||
{
|
||||
goto out;
|
||||
}
|
||||
if (ret)
|
||||
dentry = ret;
|
||||
if (d_inode(dentry)) {
|
||||
|
||||
@@ -72,6 +72,7 @@ static int parse_options(struct super_block *sb, char *options, int silent,
|
||||
|
||||
while ((p = strsep(&options, ",")) != NULL) {
|
||||
int token;
|
||||
|
||||
if (!*p)
|
||||
continue;
|
||||
|
||||
@@ -148,6 +149,7 @@ int parse_options_remount(struct super_block *sb, char *options, int silent,
|
||||
|
||||
while ((p = strsep(&options, ",")) != NULL) {
|
||||
int token;
|
||||
|
||||
if (!*p)
|
||||
continue;
|
||||
|
||||
@@ -223,8 +225,8 @@ static struct dentry *sdcardfs_d_alloc_root(struct super_block *sb)
|
||||
#endif
|
||||
|
||||
DEFINE_MUTEX(sdcardfs_super_list_lock);
|
||||
LIST_HEAD(sdcardfs_super_list);
|
||||
EXPORT_SYMBOL_GPL(sdcardfs_super_list_lock);
|
||||
LIST_HEAD(sdcardfs_super_list);
|
||||
EXPORT_SYMBOL_GPL(sdcardfs_super_list);
|
||||
|
||||
/*
|
||||
@@ -328,14 +330,15 @@ static int sdcardfs_read_super(struct vfsmount *mnt, struct super_block *sb,
|
||||
/* setup permission policy */
|
||||
sb_info->obbpath_s = kzalloc(PATH_MAX, GFP_KERNEL);
|
||||
mutex_lock(&sdcardfs_super_list_lock);
|
||||
if(sb_info->options.multiuser) {
|
||||
setup_derived_state(d_inode(sb->s_root), PERM_PRE_ROOT, sb_info->options.fs_user_id, AID_ROOT, false, d_inode(sb->s_root));
|
||||
if (sb_info->options.multiuser) {
|
||||
setup_derived_state(d_inode(sb->s_root), PERM_PRE_ROOT,
|
||||
sb_info->options.fs_user_id, AID_ROOT,
|
||||
false, d_inode(sb->s_root));
|
||||
snprintf(sb_info->obbpath_s, PATH_MAX, "%s/obb", dev_name);
|
||||
/*err = prepare_dir(sb_info->obbpath_s,
|
||||
sb_info->options.fs_low_uid,
|
||||
sb_info->options.fs_low_gid, 00755);*/
|
||||
} else {
|
||||
setup_derived_state(d_inode(sb->s_root), PERM_ROOT, sb_info->options.fs_user_id, AID_ROOT, false, d_inode(sb->s_root));
|
||||
setup_derived_state(d_inode(sb->s_root), PERM_ROOT,
|
||||
sb_info->options.fs_user_id, AID_ROOT,
|
||||
false, d_inode(sb->s_root));
|
||||
snprintf(sb_info->obbpath_s, PATH_MAX, "%s/Android/obb", dev_name);
|
||||
}
|
||||
fixup_tmp_permissions(d_inode(sb->s_root));
|
||||
@@ -368,8 +371,10 @@ out:
|
||||
|
||||
/* A feature which supports mount_nodev() with options */
|
||||
static struct dentry *mount_nodev_with_options(struct vfsmount *mnt,
|
||||
struct file_system_type *fs_type, int flags, const char *dev_name, void *data,
|
||||
int (*fill_super)(struct vfsmount *, struct super_block *, const char *, void *, int))
|
||||
struct file_system_type *fs_type, int flags,
|
||||
const char *dev_name, void *data,
|
||||
int (*fill_super)(struct vfsmount *, struct super_block *,
|
||||
const char *, void *, int))
|
||||
|
||||
{
|
||||
int error;
|
||||
@@ -401,19 +406,22 @@ static struct dentry *sdcardfs_mount(struct vfsmount *mnt,
|
||||
raw_data, sdcardfs_read_super);
|
||||
}
|
||||
|
||||
static struct dentry *sdcardfs_mount_wrn(struct file_system_type *fs_type, int flags,
|
||||
const char *dev_name, void *raw_data)
|
||||
static struct dentry *sdcardfs_mount_wrn(struct file_system_type *fs_type,
|
||||
int flags, const char *dev_name, void *raw_data)
|
||||
{
|
||||
WARN(1, "sdcardfs does not support mount. Use mount2.\n");
|
||||
return ERR_PTR(-EINVAL);
|
||||
}
|
||||
|
||||
void *sdcardfs_alloc_mnt_data(void) {
|
||||
void *sdcardfs_alloc_mnt_data(void)
|
||||
{
|
||||
return kmalloc(sizeof(struct sdcardfs_vfsmount_options), GFP_KERNEL);
|
||||
}
|
||||
|
||||
void sdcardfs_kill_sb(struct super_block *sb) {
|
||||
void sdcardfs_kill_sb(struct super_block *sb)
|
||||
{
|
||||
struct sdcardfs_sb_info *sbi;
|
||||
|
||||
if (sb->s_magic == SDCARDFS_SUPER_MAGIC) {
|
||||
sbi = SDCARDFS_SB(sb);
|
||||
mutex_lock(&sdcardfs_super_list_lock);
|
||||
|
||||
@@ -61,7 +61,8 @@ static inline void qstr_init(struct qstr *q, const char *name)
|
||||
q->hash = full_name_case_hash(q->name, q->len);
|
||||
}
|
||||
|
||||
static inline int qstr_copy(const struct qstr *src, struct qstr *dest) {
|
||||
static inline int qstr_copy(const struct qstr *src, struct qstr *dest)
|
||||
{
|
||||
dest->name = kstrdup(src->name, GFP_KERNEL);
|
||||
dest->hash_len = src->hash_len;
|
||||
return !!dest->name;
|
||||
@@ -89,6 +90,7 @@ static appid_t __get_appid(const struct qstr *key)
|
||||
appid_t get_appid(const char *key)
|
||||
{
|
||||
struct qstr q;
|
||||
|
||||
qstr_init(&q, key);
|
||||
return __get_appid(&q);
|
||||
}
|
||||
@@ -114,6 +116,7 @@ static appid_t __get_ext_gid(const struct qstr *key)
|
||||
appid_t get_ext_gid(const char *key)
|
||||
{
|
||||
struct qstr q;
|
||||
|
||||
qstr_init(&q, key);
|
||||
return __get_ext_gid(&q);
|
||||
}
|
||||
@@ -144,8 +147,10 @@ appid_t is_excluded(const char *key, userid_t user)
|
||||
|
||||
/* Kernel has already enforced everything we returned through
|
||||
* derive_permissions_locked(), so this is used to lock down access
|
||||
* even further, such as enforcing that apps hold sdcard_rw. */
|
||||
int check_caller_access_to_name(struct inode *parent_node, const struct qstr *name) {
|
||||
* even further, such as enforcing that apps hold sdcard_rw.
|
||||
*/
|
||||
int check_caller_access_to_name(struct inode *parent_node, const struct qstr *name)
|
||||
{
|
||||
struct qstr q_autorun = QSTR_LITERAL("autorun.inf");
|
||||
struct qstr q__android_secure = QSTR_LITERAL(".android_secure");
|
||||
struct qstr q_android_secure = QSTR_LITERAL("android_secure");
|
||||
@@ -160,26 +165,26 @@ int check_caller_access_to_name(struct inode *parent_node, const struct qstr *na
|
||||
}
|
||||
|
||||
/* Root always has access; access for any other UIDs should always
|
||||
* be controlled through packages.list. */
|
||||
if (from_kuid(&init_user_ns, current_fsuid()) == 0) {
|
||||
* be controlled through packages.list.
|
||||
*/
|
||||
if (from_kuid(&init_user_ns, current_fsuid()) == 0)
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* No extra permissions to enforce */
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* This function is used when file opening. The open flags must be
|
||||
* checked before calling check_caller_access_to_name() */
|
||||
int open_flags_to_access_mode(int open_flags) {
|
||||
if((open_flags & O_ACCMODE) == O_RDONLY) {
|
||||
* checked before calling check_caller_access_to_name()
|
||||
*/
|
||||
int open_flags_to_access_mode(int open_flags)
|
||||
{
|
||||
if ((open_flags & O_ACCMODE) == O_RDONLY)
|
||||
return 0; /* R_OK */
|
||||
} else if ((open_flags & O_ACCMODE) == O_WRONLY) {
|
||||
if ((open_flags & O_ACCMODE) == O_WRONLY)
|
||||
return 1; /* W_OK */
|
||||
} else {
|
||||
/* Probably O_RDRW, but treat as default to be safe */
|
||||
/* Probably O_RDRW, but treat as default to be safe */
|
||||
return 1; /* R_OK | W_OK */
|
||||
}
|
||||
}
|
||||
|
||||
static struct hashtable_entry *alloc_hashtable_entry(const struct qstr *key,
|
||||
@@ -371,7 +376,6 @@ static void remove_packagelist_entry(const struct qstr *key)
|
||||
remove_packagelist_entry_locked(key);
|
||||
fixup_all_perms_name(key);
|
||||
mutex_unlock(&sdcardfs_super_list_lock);
|
||||
return;
|
||||
}
|
||||
|
||||
static void remove_ext_gid_entry_locked(const struct qstr *key, gid_t group)
|
||||
@@ -394,7 +398,6 @@ static void remove_ext_gid_entry(const struct qstr *key, gid_t group)
|
||||
mutex_lock(&sdcardfs_super_list_lock);
|
||||
remove_ext_gid_entry_locked(key, group);
|
||||
mutex_unlock(&sdcardfs_super_list_lock);
|
||||
return;
|
||||
}
|
||||
|
||||
static void remove_userid_all_entry_locked(userid_t userid)
|
||||
@@ -422,7 +425,6 @@ static void remove_userid_all_entry(userid_t userid)
|
||||
remove_userid_all_entry_locked(userid);
|
||||
fixup_all_perms_userid(userid);
|
||||
mutex_unlock(&sdcardfs_super_list_lock);
|
||||
return;
|
||||
}
|
||||
|
||||
static void remove_userid_exclude_entry_locked(const struct qstr *key, userid_t userid)
|
||||
@@ -447,7 +449,6 @@ static void remove_userid_exclude_entry(const struct qstr *key, userid_t userid)
|
||||
remove_userid_exclude_entry_locked(key, userid);
|
||||
fixup_all_perms_name_userid(key, userid);
|
||||
mutex_unlock(&sdcardfs_super_list_lock);
|
||||
return;
|
||||
}
|
||||
|
||||
static void packagelist_destroy(void)
|
||||
@@ -456,6 +457,7 @@ static void packagelist_destroy(void)
|
||||
struct hlist_node *h_t;
|
||||
HLIST_HEAD(free_list);
|
||||
int i;
|
||||
|
||||
mutex_lock(&sdcardfs_super_list_lock);
|
||||
hash_for_each_rcu(package_to_appid, i, hash_cur, hlist) {
|
||||
hash_del_rcu(&hash_cur->hlist);
|
||||
@@ -603,7 +605,7 @@ static struct configfs_attribute *package_details_attrs[] = {
|
||||
};
|
||||
|
||||
static struct configfs_item_operations package_details_item_ops = {
|
||||
.release = package_details_release,
|
||||
.release = package_details_release,
|
||||
};
|
||||
|
||||
static struct config_item_type package_appid_type = {
|
||||
@@ -659,6 +661,7 @@ static struct config_item *extension_details_make_item(struct config_group *grou
|
||||
struct extension_details *extension_details = kzalloc(sizeof(struct extension_details), GFP_KERNEL);
|
||||
const char *tmp;
|
||||
int ret;
|
||||
|
||||
if (!extension_details)
|
||||
return ERR_PTR(-ENOMEM);
|
||||
|
||||
@@ -713,6 +716,7 @@ static struct config_group *extensions_make_group(struct config_group *group, co
|
||||
static void extensions_drop_group(struct config_group *group, struct config_item *item)
|
||||
{
|
||||
struct extensions_value *value = to_extensions_value(item);
|
||||
|
||||
printk(KERN_INFO "sdcardfs: No longer mapping any files to gid %d\n", value->num);
|
||||
kfree(value);
|
||||
}
|
||||
@@ -847,6 +851,7 @@ static int configfs_sdcardfs_init(void)
|
||||
{
|
||||
int ret, i;
|
||||
struct configfs_subsystem *subsys = &sdcardfs_packages;
|
||||
|
||||
for (i = 0; sd_default_groups[i]; i++) {
|
||||
config_group_init(sd_default_groups[i]);
|
||||
}
|
||||
@@ -877,7 +882,7 @@ int packagelist_init(void)
|
||||
}
|
||||
|
||||
configfs_sdcardfs_init();
|
||||
return 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
void packagelist_exit(void)
|
||||
|
||||
@@ -87,11 +87,11 @@
|
||||
} while (0)
|
||||
|
||||
/* OVERRIDE_CRED() and REVERT_CRED()
|
||||
* OVERRID_CRED()
|
||||
* backup original task->cred
|
||||
* and modifies task->cred->fsuid/fsgid to specified value.
|
||||
* OVERRIDE_CRED()
|
||||
* backup original task->cred
|
||||
* and modifies task->cred->fsuid/fsgid to specified value.
|
||||
* REVERT_CRED()
|
||||
* restore original task->cred->fsuid/fsgid.
|
||||
* restore original task->cred->fsuid/fsgid.
|
||||
* These two macro should be used in pair, and OVERRIDE_CRED() should be
|
||||
* placed at the beginning of a function, right after variable declaration.
|
||||
*/
|
||||
@@ -114,27 +114,29 @@
|
||||
/* Android 5.0 support */
|
||||
|
||||
/* Permission mode for a specific node. Controls how file permissions
|
||||
* are derived for children nodes. */
|
||||
* are derived for children nodes.
|
||||
*/
|
||||
typedef enum {
|
||||
/* Nothing special; this node should just inherit from its parent. */
|
||||
PERM_INHERIT,
|
||||
/* This node is one level above a normal root; used for legacy layouts
|
||||
* which use the first level to represent user_id. */
|
||||
PERM_PRE_ROOT,
|
||||
/* This node is "/" */
|
||||
PERM_ROOT,
|
||||
/* This node is "/Android" */
|
||||
PERM_ANDROID,
|
||||
/* This node is "/Android/data" */
|
||||
PERM_ANDROID_DATA,
|
||||
/* This node is "/Android/obb" */
|
||||
PERM_ANDROID_OBB,
|
||||
/* This node is "/Android/media" */
|
||||
PERM_ANDROID_MEDIA,
|
||||
/* This node is "/Android/[data|media|obb]/[package]" */
|
||||
PERM_ANDROID_PACKAGE,
|
||||
/* This node is "/Android/[data|media|obb]/[package]/cache" */
|
||||
PERM_ANDROID_PACKAGE_CACHE,
|
||||
/* Nothing special; this node should just inherit from its parent. */
|
||||
PERM_INHERIT,
|
||||
/* This node is one level above a normal root; used for legacy layouts
|
||||
* which use the first level to represent user_id.
|
||||
*/
|
||||
PERM_PRE_ROOT,
|
||||
/* This node is "/" */
|
||||
PERM_ROOT,
|
||||
/* This node is "/Android" */
|
||||
PERM_ANDROID,
|
||||
/* This node is "/Android/data" */
|
||||
PERM_ANDROID_DATA,
|
||||
/* This node is "/Android/obb" */
|
||||
PERM_ANDROID_OBB,
|
||||
/* This node is "/Android/media" */
|
||||
PERM_ANDROID_MEDIA,
|
||||
/* This node is "/Android/[data|media|obb]/[package]" */
|
||||
PERM_ANDROID_PACKAGE,
|
||||
/* This node is "/Android/[data|media|obb]/[package]/cache" */
|
||||
PERM_ANDROID_PACKAGE_CACHE,
|
||||
} perm_t;
|
||||
|
||||
struct sdcardfs_sb_info;
|
||||
@@ -142,9 +144,9 @@ struct sdcardfs_mount_options;
|
||||
struct sdcardfs_inode_info;
|
||||
|
||||
/* Do not directly use this function. Use OVERRIDE_CRED() instead. */
|
||||
const struct cred * override_fsids(struct sdcardfs_sb_info* sbi, struct sdcardfs_inode_info *info);
|
||||
const struct cred *override_fsids(struct sdcardfs_sb_info *sbi, struct sdcardfs_inode_info *info);
|
||||
/* Do not directly use this function, use REVERT_CRED() instead. */
|
||||
void revert_fsids(const struct cred * old_cred);
|
||||
void revert_fsids(const struct cred *old_cred);
|
||||
|
||||
/* operations vectors defined in specific files */
|
||||
extern const struct file_operations sdcardfs_main_fops;
|
||||
@@ -221,7 +223,8 @@ struct sdcardfs_sb_info {
|
||||
struct super_block *sb;
|
||||
struct super_block *lower_sb;
|
||||
/* derived perm policy : some of options have been added
|
||||
* to sdcardfs_mount_options (Android 4.4 support) */
|
||||
* to sdcardfs_mount_options (Android 4.4 support)
|
||||
*/
|
||||
struct sdcardfs_mount_options options;
|
||||
spinlock_t lock; /* protects obbpath */
|
||||
char *obbpath_s;
|
||||
@@ -332,7 +335,7 @@ static inline void sdcardfs_put_reset_##pname(const struct dentry *dent) \
|
||||
{ \
|
||||
struct path pname; \
|
||||
spin_lock(&SDCARDFS_D(dent)->lock); \
|
||||
if(SDCARDFS_D(dent)->pname.dentry) { \
|
||||
if (SDCARDFS_D(dent)->pname.dentry) { \
|
||||
pathcpy(&pname, &SDCARDFS_D(dent)->pname); \
|
||||
SDCARDFS_D(dent)->pname.dentry = NULL; \
|
||||
SDCARDFS_D(dent)->pname.mnt = NULL; \
|
||||
@@ -348,17 +351,17 @@ SDCARDFS_DENT_FUNC(orig_path)
|
||||
|
||||
static inline bool sbinfo_has_sdcard_magic(struct sdcardfs_sb_info *sbinfo)
|
||||
{
|
||||
return sbinfo && sbinfo->sb && sbinfo->sb->s_magic == SDCARDFS_SUPER_MAGIC;
|
||||
return sbinfo && sbinfo->sb && sbinfo->sb->s_magic == SDCARDFS_SUPER_MAGIC;
|
||||
}
|
||||
|
||||
/* grab a refererence if we aren't linking to ourself */
|
||||
static inline void set_top(struct sdcardfs_inode_info *info, struct inode *top)
|
||||
{
|
||||
struct inode *old_top = NULL;
|
||||
|
||||
BUG_ON(IS_ERR_OR_NULL(top));
|
||||
if (info->top && info->top != &info->vfs_inode) {
|
||||
if (info->top && info->top != &info->vfs_inode)
|
||||
old_top = info->top;
|
||||
}
|
||||
if (top != &info->vfs_inode)
|
||||
igrab(top);
|
||||
info->top = top;
|
||||
@@ -368,11 +371,11 @@ static inline void set_top(struct sdcardfs_inode_info *info, struct inode *top)
|
||||
static inline struct inode *grab_top(struct sdcardfs_inode_info *info)
|
||||
{
|
||||
struct inode *top = info->top;
|
||||
if (top) {
|
||||
|
||||
if (top)
|
||||
return igrab(top);
|
||||
} else {
|
||||
else
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
static inline void release_top(struct sdcardfs_inode_info *info)
|
||||
@@ -380,21 +383,24 @@ static inline void release_top(struct sdcardfs_inode_info *info)
|
||||
iput(info->top);
|
||||
}
|
||||
|
||||
static inline int get_gid(struct vfsmount *mnt, struct sdcardfs_inode_info *info) {
|
||||
static inline int get_gid(struct vfsmount *mnt, struct sdcardfs_inode_info *info)
|
||||
{
|
||||
struct sdcardfs_vfsmount_options *opts = mnt->data;
|
||||
|
||||
if (opts->gid == AID_SDCARD_RW) {
|
||||
if (opts->gid == AID_SDCARD_RW)
|
||||
/* As an optimization, certain trusted system components only run
|
||||
* 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
|
||||
* the user boundary enforcement for the default view. The UIDs
|
||||
* assigned to app directories are still multiuser aware. */
|
||||
* assigned to app directories are still multiuser aware.
|
||||
*/
|
||||
return AID_SDCARD_RW;
|
||||
} else {
|
||||
else
|
||||
return multiuser_get_uid(info->userid, opts->gid);
|
||||
}
|
||||
}
|
||||
static inline int get_mode(struct vfsmount *mnt, struct sdcardfs_inode_info *info) {
|
||||
|
||||
static inline int get_mode(struct vfsmount *mnt, struct sdcardfs_inode_info *info)
|
||||
{
|
||||
int owner_mode;
|
||||
int filtered_mode;
|
||||
struct sdcardfs_vfsmount_options *opts = mnt->data;
|
||||
@@ -403,17 +409,18 @@ static inline int get_mode(struct vfsmount *mnt, struct sdcardfs_inode_info *inf
|
||||
|
||||
if (info->perm == PERM_PRE_ROOT) {
|
||||
/* Top of multi-user view should always be visible to ensure
|
||||
* secondary users can traverse inside. */
|
||||
* secondary users can traverse inside.
|
||||
*/
|
||||
visible_mode = 0711;
|
||||
} else if (info->under_android) {
|
||||
/* Block "other" access to Android directories, since only apps
|
||||
* belonging to a specific user should be in there; we still
|
||||
* leave +x open for the default view. */
|
||||
if (opts->gid == AID_SDCARD_RW) {
|
||||
* leave +x open for the default view.
|
||||
*/
|
||||
if (opts->gid == AID_SDCARD_RW)
|
||||
visible_mode = visible_mode & ~0006;
|
||||
} else {
|
||||
else
|
||||
visible_mode = visible_mode & ~0007;
|
||||
}
|
||||
}
|
||||
owner_mode = info->lower_inode->i_mode & 0700;
|
||||
filtered_mode = visible_mode & (owner_mode | (owner_mode >> 3) | (owner_mode >> 6));
|
||||
@@ -438,7 +445,7 @@ static inline void sdcardfs_get_real_lower(const struct dentry *dent,
|
||||
/* in case of a local obb dentry
|
||||
* the orig_path should be returned
|
||||
*/
|
||||
if(has_graft_path(dent))
|
||||
if (has_graft_path(dent))
|
||||
sdcardfs_get_orig_path(dent, real_lower);
|
||||
else
|
||||
sdcardfs_get_lower_path(dent, real_lower);
|
||||
@@ -447,7 +454,7 @@ static inline void sdcardfs_get_real_lower(const struct dentry *dent,
|
||||
static inline void sdcardfs_put_real_lower(const struct dentry *dent,
|
||||
struct path *real_lower)
|
||||
{
|
||||
if(has_graft_path(dent))
|
||||
if (has_graft_path(dent))
|
||||
sdcardfs_put_orig_path(dent, real_lower);
|
||||
else
|
||||
sdcardfs_put_lower_path(dent, real_lower);
|
||||
@@ -460,7 +467,7 @@ extern struct list_head sdcardfs_super_list;
|
||||
extern appid_t get_appid(const char *app_name);
|
||||
extern appid_t get_ext_gid(const char *app_name);
|
||||
extern appid_t is_excluded(const char *app_name, userid_t userid);
|
||||
extern int check_caller_access_to_name(struct inode *parent_node, const struct qstr* name);
|
||||
extern int check_caller_access_to_name(struct inode *parent_node, const struct qstr *name);
|
||||
extern int open_flags_to_access_mode(int open_flags);
|
||||
extern int packagelist_init(void);
|
||||
extern void packagelist_exit(void);
|
||||
@@ -481,7 +488,7 @@ extern void get_derived_permission_new(struct dentry *parent, struct dentry *den
|
||||
extern void fixup_perms_recursive(struct dentry *dentry, struct limit_search *limit);
|
||||
|
||||
extern void update_derived_permission_lock(struct dentry *dentry);
|
||||
void fixup_lower_ownership(struct dentry* dentry, const char *name);
|
||||
void fixup_lower_ownership(struct dentry *dentry, const char *name);
|
||||
extern int need_graft_path(struct dentry *dentry);
|
||||
extern int is_base_obbpath(struct dentry *dentry);
|
||||
extern int is_obbpath_invalid(struct dentry *dentry);
|
||||
@@ -491,6 +498,7 @@ extern int setup_obb_dentry(struct dentry *dentry, struct path *lower_path);
|
||||
static inline struct dentry *lock_parent(struct dentry *dentry)
|
||||
{
|
||||
struct dentry *dir = dget_parent(dentry);
|
||||
|
||||
mutex_lock_nested(&d_inode(dir)->i_mutex, I_MUTEX_PARENT);
|
||||
return dir;
|
||||
}
|
||||
|
||||
@@ -36,7 +36,7 @@ static void sdcardfs_put_super(struct super_block *sb)
|
||||
if (!spd)
|
||||
return;
|
||||
|
||||
if(spd->obbpath_s) {
|
||||
if (spd->obbpath_s) {
|
||||
kfree(spd->obbpath_s);
|
||||
path_put(&spd->obbpath);
|
||||
}
|
||||
@@ -125,29 +125,33 @@ static int sdcardfs_remount_fs2(struct vfsmount *mnt, struct super_block *sb,
|
||||
* SILENT, but anything else left over is an error.
|
||||
*/
|
||||
if ((*flags & ~(MS_RDONLY | MS_MANDLOCK | MS_SILENT | MS_REMOUNT)) != 0) {
|
||||
printk(KERN_ERR
|
||||
"sdcardfs: remount flags 0x%x unsupported\n", *flags);
|
||||
pr_err("sdcardfs: remount flags 0x%x unsupported\n", *flags);
|
||||
err = -EINVAL;
|
||||
}
|
||||
printk(KERN_INFO "Remount options were %s for vfsmnt %p.\n", options, mnt);
|
||||
pr_info("Remount options were %s for vfsmnt %p.\n", options, mnt);
|
||||
err = parse_options_remount(sb, options, *flags & ~MS_SILENT, mnt->data);
|
||||
|
||||
|
||||
return err;
|
||||
}
|
||||
|
||||
static void* sdcardfs_clone_mnt_data(void *data) {
|
||||
struct sdcardfs_vfsmount_options* opt = kmalloc(sizeof(struct sdcardfs_vfsmount_options), GFP_KERNEL);
|
||||
struct sdcardfs_vfsmount_options* old = data;
|
||||
if(!opt) return NULL;
|
||||
static void *sdcardfs_clone_mnt_data(void *data)
|
||||
{
|
||||
struct sdcardfs_vfsmount_options *opt = kmalloc(sizeof(struct sdcardfs_vfsmount_options), GFP_KERNEL);
|
||||
struct sdcardfs_vfsmount_options *old = data;
|
||||
|
||||
if (!opt)
|
||||
return NULL;
|
||||
opt->gid = old->gid;
|
||||
opt->mask = old->mask;
|
||||
return opt;
|
||||
}
|
||||
|
||||
static void sdcardfs_copy_mnt_data(void *data, void *newdata) {
|
||||
struct sdcardfs_vfsmount_options* old = data;
|
||||
struct sdcardfs_vfsmount_options* new = newdata;
|
||||
static void sdcardfs_copy_mnt_data(void *data, void *newdata)
|
||||
{
|
||||
struct sdcardfs_vfsmount_options *old = data;
|
||||
struct sdcardfs_vfsmount_options *new = newdata;
|
||||
|
||||
old->gid = new->gid;
|
||||
old->mask = new->mask;
|
||||
}
|
||||
@@ -235,7 +239,8 @@ static void sdcardfs_umount_begin(struct super_block *sb)
|
||||
lower_sb->s_op->umount_begin(lower_sb);
|
||||
}
|
||||
|
||||
static int sdcardfs_show_options(struct vfsmount *mnt, struct seq_file *m, struct dentry *root)
|
||||
static int sdcardfs_show_options(struct vfsmount *mnt, struct seq_file *m,
|
||||
struct dentry *root)
|
||||
{
|
||||
struct sdcardfs_sb_info *sbi = SDCARDFS_SB(root->d_sb);
|
||||
struct sdcardfs_mount_options *opts = &sbi->options;
|
||||
|
||||
Reference in New Issue
Block a user