コード例 #1
0
/**
 * ecryptfs_interpose
 * @lower_dentry: Existing dentry in the lower filesystem
 * @dentry: ecryptfs' dentry
 * @sb: ecryptfs's super_block
 *
 * Interposes upper and lower dentries.
 *
 * Returns zero on success; non-zero otherwise
 */
static int ecryptfs_interpose(struct dentry *lower_dentry,
			      struct dentry *dentry, struct super_block *sb)
{
	struct inode *inode = ecryptfs_get_inode(lower_dentry->d_inode, sb);

	if (IS_ERR(inode))
		return PTR_ERR(inode);

	d_instantiate(dentry, inode);
	if(d_unhashed(dentry))
		d_rehash(dentry);

#ifdef CONFIG_SDP
	if(S_ISDIR(inode->i_mode) && dentry) {
		if(IS_UNDER_ROOT(dentry)) {
			struct ecryptfs_mount_crypt_stat *mount_crypt_stat  =
					&ecryptfs_superblock_to_private(inode->i_sb)->mount_crypt_stat;
			int engineid;
			printk("Creating a directoy under root directory of current partition.\n");

			if(is_chamber_directory(mount_crypt_stat, dentry->d_name.name, &engineid)) {
				printk("This is a chamber directory engine[%d]\n", engineid);
				set_chamber_flag(engineid, inode);
			}
		} else if(IS_SENSITIVE_DENTRY(dentry->d_parent)) {
			/*
			 * When parent directory is sensitive
			 */
			struct ecryptfs_crypt_stat *crypt_stat =
					&ecryptfs_inode_to_private(inode)->crypt_stat;
			struct ecryptfs_crypt_stat *parent_crypt_stat =
					&ecryptfs_inode_to_private(dentry->d_parent->d_inode)->crypt_stat;

			//TODO : remove this log
			DEK_LOGE("Parent %s[id:%d] is sensitive. so this directory is sensitive too\n",
					dentry->d_parent->d_name.name, parent_crypt_stat->engine_id);
			crypt_stat->flags |= ECRYPTFS_DEK_IS_SENSITIVE;
			crypt_stat->engine_id = parent_crypt_stat->engine_id;
		}
	}
#endif

	return 0;
}
コード例 #2
0
ファイル: inode.c プロジェクト: sawdoctor/Googy-Max-N4-Kernel
/**
 * ecryptfs_interpose
 * @lower_dentry: Existing dentry in the lower filesystem
 * @dentry: ecryptfs' dentry
 * @sb: ecryptfs's super_block
 *
 * Interposes upper and lower dentries.
 *
 * Returns zero on success; non-zero otherwise
 */
static int ecryptfs_interpose(struct dentry *lower_dentry,
			      struct dentry *dentry, struct super_block *sb)
{
	struct inode *inode = ecryptfs_get_inode(lower_dentry->d_inode, sb);

	if (IS_ERR(inode))
		return PTR_ERR(inode);
	d_instantiate(dentry, inode);

#ifdef CONFIG_SDP
	if(S_ISDIR(inode->i_mode) && dentry) {
	    if(IS_UNDER_ROOT(dentry)) {
	        struct ecryptfs_mount_crypt_stat *mount_crypt_stat  =
	                &ecryptfs_superblock_to_private(inode->i_sb)->mount_crypt_stat;
	        printk("Creating a directoy under root directory of current partition.\n");

	        if(is_chamber_directory(mount_crypt_stat, (char *)dentry->d_name.name)) {
	            printk("This is a chamber directory\n");
	            set_chamber_flag(inode);
	        }
	    } else if(IS_SENSITIVE_DENTRY(dentry->d_parent)) {
	        /*
	         * When parent directory is sensitive
	         */
	        struct ecryptfs_crypt_stat *crypt_stat =
	                &ecryptfs_inode_to_private(inode)->crypt_stat;

	        printk("Parent %s is sensitive. so this directory is sensitive too\n",
	                dentry->d_parent->d_name.name);
	        crypt_stat->flags |= ECRYPTFS_DEK_IS_SENSITIVE;
	    }
	}
#endif

	return 0;
}
コード例 #3
0
ファイル: inode.c プロジェクト: sawdoctor/Googy-Max-N4-Kernel
/**
 * ecryptfs_lookup_interpose - Dentry interposition for a lookup
 */
static int ecryptfs_lookup_interpose(struct dentry *dentry,
				     struct dentry *lower_dentry,
				     struct inode *dir_inode)
{
	struct inode *inode, *lower_inode = lower_dentry->d_inode;
	struct ecryptfs_dentry_info *dentry_info;
	struct vfsmount *lower_mnt;
	int rc = 0;

	dentry_info = kmem_cache_alloc(ecryptfs_dentry_info_cache, GFP_KERNEL);
	if (!dentry_info) {
		printk(KERN_ERR "%s: Out of memory whilst attempting "
		       "to allocate ecryptfs_dentry_info struct\n",
			__func__);
		dput(lower_dentry);
		return -ENOMEM;
	}

	lower_mnt = mntget(ecryptfs_dentry_to_lower_mnt(dentry->d_parent));
	fsstack_copy_attr_atime(dir_inode, lower_dentry->d_parent->d_inode);
	BUG_ON(!lower_dentry->d_count);

	ecryptfs_set_dentry_private(dentry, dentry_info);
	ecryptfs_set_dentry_lower(dentry, lower_dentry);
	ecryptfs_set_dentry_lower_mnt(dentry, lower_mnt);

	if (!lower_dentry->d_inode) {
		/* We want to add because we couldn't find in lower */
		d_add(dentry, NULL);
		return 0;
	}
	inode = __ecryptfs_get_inode(lower_inode, dir_inode->i_sb);
	if (IS_ERR(inode)) {
		printk(KERN_ERR "%s: Error interposing; rc = [%ld]\n",
		       __func__, PTR_ERR(inode));
		return PTR_ERR(inode);
	}
	if (S_ISREG(inode->i_mode)) {
		rc = ecryptfs_i_size_read(dentry, inode);
		if (rc) {
			make_bad_inode(inode);
			return rc;
		}
	}

#ifdef CONFIG_SDP
	if (S_ISDIR(inode->i_mode) && dentry) {
	    if(IS_UNDER_ROOT(dentry)) {
	        struct ecryptfs_mount_crypt_stat *mount_crypt_stat  =
	                &ecryptfs_superblock_to_private(inode->i_sb)->mount_crypt_stat;
	        printk("Lookup a directoy under root directory of current partition.\n");

	        if(is_chamber_directory(mount_crypt_stat, (char *)dentry->d_name.name)) {
	            /*
	             * When this directory is under ROOT directory and the name is registered
	             * as Chamber.
	             */
	            printk("This is a chamber directory\n");
	            set_chamber_flag(inode);
	        }
	    } else if(IS_SENSITIVE_DENTRY(dentry->d_parent)) {
	        /*
	         * When parent directory is sensitive
	         */
	        struct ecryptfs_crypt_stat *crypt_stat =
	                &ecryptfs_inode_to_private(inode)->crypt_stat;

	        printk("Parent %s is sensitive. so this directory is sensitive too\n",
	                dentry->d_parent->d_name.name);
	        crypt_stat->flags |= ECRYPTFS_DEK_IS_SENSITIVE;
	    }
	}
#endif

	if (inode->i_state & I_NEW)
		unlock_new_inode(inode);
	d_add(dentry, inode);

	return rc;
}