1 ext4 crypto: inherit encryption policies on inode and directory create
3 From: Michael Halcrow <mhalcrow@google.com>
5 Change-Id: Ibeeafc70352b39d1d5b3b17158a41d8fb54ed136
6 Signed-off-by: Michael Halcrow <mhalcrow@google.com>
7 Signed-off-by: Theodore Ts'o <tytso@mit.edu>
9 fs/ext4/namei.c | 20 +++++++++++++++++++-
10 1 file changed, 19 insertions(+), 1 deletion(-)
12 diff --git a/fs/ext4/namei.c b/fs/ext4/namei.c
13 index 9939db9..ea945dc 100644
16 @@ -2249,9 +2249,20 @@ retry:
17 inode->i_op = &ext4_file_inode_operations;
18 inode->i_fop = &ext4_file_operations;
20 - err = ext4_add_nondir(handle, dentry, inode);
22 +#ifdef CONFIG_EXT4_FS_ENCRYPTION
23 + if (!err && ext4_encrypted_inode(dir))
24 + err = ext4_inherit_context(dir, inode);
27 + err = ext4_add_nondir(handle, dentry, inode);
28 if (!err && IS_DIRSYNC(dir))
29 ext4_handle_sync(handle);
32 + unlock_new_inode(inode);
37 ext4_journal_stop(handle);
38 @@ -2430,6 +2441,13 @@ retry:
39 err = ext4_init_new_dir(handle, dir, inode);
42 +#ifdef CONFIG_EXT4_FS_ENCRYPTION
43 + if (ext4_encrypted_inode(dir)) {
44 + err = ext4_inherit_context(dir, inode);
46 + goto out_clear_inode;
49 err = ext4_mark_inode_dirty(handle, inode);
51 err = ext4_add_entry(handle, dentry, inode);