diff options
author | Michael Halcrow <mhalcrow@google.com> | 2015-04-12 00:55:09 -0400 |
---|---|---|
committer | Theodore Ts'o <tytso@mit.edu> | 2015-04-12 00:55:09 -0400 |
commit | dde680cefc842e58524772099a3b8219e5abf551 (patch) | |
tree | 72d0983526c7797f69dd10daf601ac822c2b8779 /fs/ext4/namei.c | |
parent | d9cdc903318171571f1cd1e5737fd0cab94186be (diff) | |
download | op-kernel-dev-dde680cefc842e58524772099a3b8219e5abf551.zip op-kernel-dev-dde680cefc842e58524772099a3b8219e5abf551.tar.gz |
ext4 crypto: inherit encryption policies on inode and directory create
Signed-off-by: Michael Halcrow <mhalcrow@google.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Diffstat (limited to 'fs/ext4/namei.c')
-rw-r--r-- | fs/ext4/namei.c | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/fs/ext4/namei.c b/fs/ext4/namei.c index acd79198..77a63ff 100644 --- a/fs/ext4/namei.c +++ b/fs/ext4/namei.c @@ -2253,7 +2253,19 @@ retry: else inode->i_fop = &ext4_file_operations; ext4_set_aops(inode); - err = ext4_add_nondir(handle, dentry, 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 @@ retry: 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); |