Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit dde680ce authored by Michael Halcrow's avatar Michael Halcrow Committed by Theodore Ts'o
Browse files

ext4 crypto: inherit encryption policies on inode and directory create

parent d9cdc903
Loading
Loading
Loading
Loading
+20 −1
Original line number Diff line number Diff line
@@ -2253,6 +2253,18 @@ static int ext4_create(struct inode *dir, struct dentry *dentry, umode_t mode,
		else
			inode->i_fop = &ext4_file_operations;
		ext4_set_aops(inode);
		err = 0;
#ifdef CONFIG_EXT4_FS_ENCRYPTION
		if (!err && ext4_encrypted_inode(dir)) {
			err = ext4_inherit_context(dir, inode);
			if (err) {
				clear_nlink(inode);
				unlock_new_inode(inode);
				iput(inode);
			}
		}
#endif
		if (!err)
			err = ext4_add_nondir(handle, dentry, inode);
		if (!err && IS_DIRSYNC(dir))
			ext4_handle_sync(handle);
@@ -2437,6 +2449,13 @@ static int ext4_mkdir(struct inode *dir, struct dentry *dentry, umode_t mode)
	err = ext4_init_new_dir(handle, dir, inode);
	if (err)
		goto out_clear_inode;
#ifdef CONFIG_EXT4_FS_ENCRYPTION
	if (ext4_encrypted_inode(dir)) {
		err = ext4_inherit_context(dir, inode);
		if (err)
			goto out_clear_inode;
	}
#endif
	err = ext4_mark_inode_dirty(handle, inode);
	if (!err)
		err = ext4_add_entry(handle, dentry, inode);