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 | 16 ++++++++++++++++
10 1 file changed, 16 insertions(+)
12 diff --git a/fs/ext4/namei.c b/fs/ext4/namei.c
13 index 12d2592..262aa1c 100644
17 #define NAMEI_RA_BLOCKS 4
18 #define NAMEI_RA_SIZE (NAMEI_RA_CHUNKS * NAMEI_RA_BLOCKS)
20 +static int ext4_unlink(struct inode *dir, struct dentry *dentry);
22 static struct buffer_head *ext4_append(handle_t *handle,
25 @@ -2247,6 +2249,13 @@ retry:
26 err = ext4_add_nondir(handle, dentry, inode);
27 if (!err && IS_DIRSYNC(dir))
28 ext4_handle_sync(handle);
29 +#ifdef CONFIG_EXT4_FS_ENCRYPTION
30 + if (!err && ext4_encrypted_inode(dir)) {
31 + err = ext4_inherit_context(dir, inode);
33 + ext4_unlink(dir, dentry);
38 ext4_journal_stop(handle);
39 @@ -2445,6 +2454,13 @@ out_clear_inode:
40 d_instantiate(dentry, inode);
42 ext4_handle_sync(handle);
43 +#ifdef CONFIG_EXT4_FS_ENCRYPTION
44 + if (ext4_encrypted_inode(dir)) {
45 + err = ext4_inherit_context(dir, inode);
47 + ext4_unlink(dir, dentry);